Topography of a region - Python: Difference between revisions
From wikiluntti
(→11) |
(→11) |
||
| Line 52: | Line 52: | ||
row, col = dem.index(lon, lat) | row, col = dem.index(lon, lat) | ||
elevation = dem.read(1)[row, col] | elevation = dem.read(1)[row, col] | ||
</syntaxhighlight> | |||
Downsampling the GeoTIFF | |||
<syntaxhighlight lang="python"> | |||
from rasterio.enums import Resampling | |||
data = src.read( | |||
out_shape=( | |||
src.count, | |||
src.height // 10, | |||
src.width // 10 | |||
), | |||
resampling=Resampling.average | |||
) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 13:44, 4 April 2026
Introduction
An example of Alta-joki Alta river.
https://caltopo.com/map.html#ll=68.8546,23.64807&z=8&b=mbt
Mostly needs an API.
- DEM Digital elevation model
- DSM Digital surface model
- DTM Digital terrain model
Python GIS
- folium
- geopy
- GeoPandas
Earth Model
DEM files (likes SRTM data) with
- Rasterio
- GDAL
Norwegian national DEM (Kartverket). The Norwegian Mapping Authority provides very high-resolution DEM data (down to 1 meter).
Global DEMs (digital elevation model). No need super high resolution. Common datasets:
- SRTM (~30 m resolution)
- ASTER GDEM (~30 m)
Open portals. You can use
- OpenTopography
- OpenDEM
- NASA EarthData
which gives eg GeoTIFF.
Open Topo Data
Open-Elevation.com
11
import rasterio
with rasterio.open("dem.tif") as dem:
for lon, lat in track:
row, col = dem.index(lon, lat)
elevation = dem.read(1)[row, col]
Downsampling the GeoTIFF
from rasterio.enums import Resampling
data = src.read(
out_shape=(
src.count,
src.height // 10,
src.width // 10
),
resampling=Resampling.average
)