Thursday 5 January 2017

Rasterize vector layers with different extents into identical raster grids with QGIS


I am working on a quite simple spatial potential analysis using QGIS. I have some ArcGIS knowledge, but I am new to QGIS. My task is to identify the functional inner city of a region based on different criteria like density or distance to public transport. Therefore I created polygon layers representing different criteria. All the polygons have values between 0 and 1. The next step is to rasterize the vector layers and use the raster calculator to make an additions for each raster cell.


The problem I am facing is that the layer extents are different. Therefore all the raster outputs also differ in extent and cell size. As a result I cannot use the raster calculator to make the cell calculations.


So what I need to do, is to find a way to rasterize the polygone layers into raster sets with the same extend and the same cell size. ArcGIs offers the options to set a specific “Analysis extent” and a specific “Analysis cell size” for further raster calculations, which is basically what I am looking for in QGIS. I hope you guys can help me!



Answer



Two methods come to mind: You can use the gdal utility, gdal_rasterize, with the -a option to specify the attributie column, and the -te and -tr options to set the output extents and resolution the same for each raster. See details on the GDAL website.


Alternatively, if you work in GRASS, then you first set the desired extents ("region settings" in GRASS terminology) with g.region. Then, when converting the vectors to rasters using v.to.rast, that region setting is honored for each new raster. Here's the v.to.rast manual page. Almost all GRASS raster modules work within a preset region.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...