11 Processing: Data Merging and Stitching Rasters
Contents
© Alexander Jüstel, Fraunhofer IEG, Institution for Energy Infrastructures and Geothermal Systems, RWTH Aachen University, GNU Lesser General Public License v3.0
11 Processing: Data Merging and Stitching Rasters#
This notebook illustrates how to merge and stitch the resulting heat demand rasters to get one final heat demand map.
Importing Libraries#
[1]:
import rasterio
import os
from pyheatdemand import processing
C:\Users\ale93371\Anaconda3\envs\pygeomechanical\lib\site-packages\numpy\_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:
C:\Users\ale93371\Anaconda3\envs\pygeomechanical\lib\site-packages\numpy\.libs\libopenblas.FB5AE2TYXYH2IJRDKGDGQ3XBKLKTF43H.gfortran-win_amd64.dll
C:\Users\ale93371\Anaconda3\envs\pygeomechanical\lib\site-packages\numpy\.libs\libopenblas64__v0.3.23-246-g3d31191b-gcc_10_3_0.dll
warnings.warn("loaded more than 1 DLL from .libs:"
Get List of all Raster Files#
Loading the rasters from a folder.
[2]:
raster_list = os.listdir('../../../test/data/rasters/')
raster_list = [os.path.join(os.path.abspath('../../../test/data/rasters/'), path) for path in raster_list]
raster_list
[2]:
['C:\\Users\\ale93371\\Documents\\pyhd2\\test\\data\\rasters\\HD_Test1.tif',
'C:\\Users\\ale93371\\Documents\\pyhd2\\test\\data\\rasters\\HD_Test2.tif']
[3]:
rasterio.open(raster_list[0]).crs
[3]:
CRS.from_epsg(3035)
Merging the Datasets#
The datasets can be merged using the merge_rasters(...)
function.
[4]:
processing.merge_rasters(raster_list, '../../../test/data/Raster_merged.tif')
Raster successfully merged
Plotting result#
[5]:
from rasterio.plot import show
mosaic = rasterio.open('../../../test/data/Raster_merged.tif')
show(mosaic)
[5]:
<Axes: >