Wednesday, 11 February 2015

raster - How to set the output extents of rasterization in QGIS


I am trying to rasterize a bunch of vector based shape files in QGIS. All these files are covering certain types of ground use in a city (houses, street, open field,...).


I need these files to be rasterized because I will be running an algorithm on them to determine the least cost path. And for this I need them to be rasterized with a certain fixed pixel size (1m x 1m in the real world). My vector files are 6 km x 10 km but when I rasterize one of the files (for ex: railroads) which isn't reaching over the total 6 km in x direction and over the 10 km in y direction but only over the first 3 km x and 10 km y, the rasterized file is also only 3 km x 10 km.



Somebody any idea how to solve this? Because in this manner, when I choose a pixel size of 6000 + 10000 I'll get pixels with a size of 0,5 m x 1 m in stead of 1 m x 1 m.



Answer



I assume that you are using the GDAL Rasterize (vector to raster) tool. Using QGIS, you can edit the gdal rasterize command and had the "xmin ymin xmax ymax" parameter:


enter image description here


Notice that you will have to adapt the coordinates to fit your case.


You can use this same command directly on the console or terminal to bash rasterize all your vector in one go.


You can also use v.to.rast.attribute GRASS tool that is available in processing. It will let you use some layer's bounding box as the output region (GRASS region extent... > Use layer Extent).


enter image description here


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...