GeoTIFF Raster
Load a GeoTIFF raster with ak.GeoTIFF and render its band values over a map with a continuous color scale.
Python Script
python
"""GeoTIFF raster — a land surface temperature raster over Niteroi, drawn as a raster layer with a color ramp.
The file has one band per summer: `band_1` is the mean daytime temperature (in Celsius) of December to February 2001,
and `band_24` that of 2024, which the layer draws.
A raster does not frame the map, so a vector layer over the same area comes first: it sets the extent of the workspace.
"""
from __future__ import annotations
from pathlib import Path
import pyautark as ak
DATA_DIR = Path(__file__).resolve().parents[1] / "data"
# Niteroi: longitude -43.2 to -43.0, latitude -22.95 to -22.8.
area = ak.GeoJSON(
"area",
values={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[-43.2, -22.95], [-43.0, -22.95], [-43.0, -22.8], [-43.2, -22.8], [-43.2, -22.95]]],
},
}
],
},
)
temperature = ak.GeoTIFF("temperature", url=(DATA_DIR / "niteroi_lst_verao_2001_2024.tif").as_uri())
spec = ak.Spec(
metadata=ak.Metadata(title="GeoTIFF Raster"),
data=[area, temperature],
views=[
ak.Map(
camera=ak.Camera(zoom=11),
layers=[
ak.Layer(area, id="area").style(color="#dddddd", opacity=0.3),
ak.Layer(temperature, id="temperature")
.encode(color=ak.field("band_24", ak.Scale(scheme="ylorrd")))
.style(opacity=0.85),
],
)
],
)
if __name__ == "__main__":
spec.window(height="760px")Run in Jupyter or standalone HTML
Replace spec.window(...) with spec.widget() inside a Jupyter notebook (requires pip install "pyautark[widget]") or spec.save_html("out.html") to export a standalone web page.
This example comes from the pyautark repository.