cityImage.assign_elevations_from_rasters#
- cityImage.assign_elevations_from_rasters(nodes_gdf, buildings_gdf, dtm_path, surface_path=None, z_col='z', base_stat='mean', top_stat='max', all_touched=False, min_valid_elev=-50.0)[source]#
One-stop elevation assignment from rasters, for cities without height data.
Given a bare-earth DTM (terrain) and optionally a surface model (DSM — first-return elevations including rooftops; the raster often shipped under the generic name “DEM”), this assigns:
node
z(z_col): terrain elevation sampled at each point — the observer elevation used by the 3D sight lines;building
base: terrain elevation under each footprint;building
height(only whensurface_pathis given): above-ground height as top-of-surface minus base.
With a DTM alone, heights are not derivable — only
zandbaseare set; supply heights from a detailed layer or OSM tags instead.Non-destructive: results are merged back onto the full input frames, so features outside the raster extent keep their rows (with NaN elevations). Either
nodes_gdforbuildings_gdfmay beNoneto skip that side.- Returns:
tuple(GeoDataFrame or None, GeoDataFrame or None) –
(nodes_gdf, buildings_gdf)with elevations assigned.Requires the optional ``height`` extra (
rasterioandrasterstats.)