How do I use GDAL tools to rasterise a shapefile, while also reprojecting to a different target coordinate system?

The gdal_rasterize documentation says on-the-fly re-projection is supported in recent versions, but doesn't explain how to perform it. It seems not to document any projection related arguments except -a_srs (which it says is for overriding not reprojecting). Do I need to first create an empty destination file with the target attributes, and if so then what tool do I use to do so?


If the target image already exists then re-projection happens automatically. However, GDAL must recognize the coordinate system of vectors. Check that with ogrinfo. Is source projection is not found (for example because shapefile does not have the .prj part) you can tell it manually by using the -a_srs parameter http://www.gdal.org/gdal_rasterize.html.

Unfortunately it is not possible to create a new target image that is in another coordinate system than vector data. See GDAL issue https://trac.osgeo.org/gdal/ticket/7197.

You can create a blank GeoTIFF to be used as a receiving raster for you vectors with Python as described in https://trac.osgeo.org/gdal/wiki/FAQRaster#HowcanIcreateablankrasterbasedonavectorfilesextentsforusewithgdal_rasterize. I can't discover how to create such an empty raster with any of the GDAL command line tools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.