I'm trying to calculate the "real height" of a region, meaning I want to sum the elevation value and building height value, if there is any building, for a region.
I know I can simply use Raster Calculator in ArcGIS and do a rasterA + rasterB
, but I'm wondering if I can do it using Python.
I have generated two input raster files for this step:
First, Elevation raster
import rasterio
file1 = r"L:\lvpcgis\BowenLiuTemporary\ExtendLinesToLayer\Starry\allentown_elevation.tif"
elevation = rasterio.open(file1)
show(elevation, cmap = 'terrain')
It shows up like this:
Second, Building raster with building height as pixel value:
file2 = r"L:\lvpcgis\BowenLiuTemporary\ExtendLinesToLayer\Starry\BuildingRasterTry2.tif"
bldg = rasterio.open(file2)
show(bldg)
It shows up like:
Now I'm wondering if I can add up these two layers so that the end result can reflect the sum of the values from the two rasters. It shall be doable but I haven't found any method online to achieve this with rasterio.
Other methods with Python will also suffice for me. I mentioned rasterio as it's the only module that I know can deal with raster files in Python.