6

Rasterizing a vector (shp) I face the following problem: I want my output file (the rasterized vector) to have the same resolution and dimensions as an existing raster.

If I understand the interface correctly, the option "keep size and resolution of existing layer" should do this job. However, there is no option to choose an existing layer. Any hints?

Of course, I can achieve (at least approximately) what I want to do using the –te and –tr parameters. However it would be interesting to know if and how the "keep seize and resolution of existing layer" works.

  • The gdal_rasterize command can use an existing raster; before 1.8 the raster had to exist before running the command. If you can copy the existing raster and then supply it to the gdal_rasterize then it should do what you want. – Michael Stimson Jul 24 '14 at 0:17
  • 1
    Sorry Michael, I´m afraid I don´t understand what you mean. I currently use this parametres: gdal_rasterize -a adecuado -l vector_2 -tr 15.00 -15.00 -te 403326.00 1853140.00 461517.00 "...\\vector_2.shp" ".../output.tif" This works. However, my question would be if have to put this values (resolution, extension) manually, or can I use the "keep size and resolution of existing layer" option to load this values automatically from a given raster file? – Flo Jul 24 '14 at 0:53
  • What I am saying is that if you copy existing.tif to output.tif and then use gdal_rasterize (with no fancy options) "...\\vector_2.shp" ".../output.tif" it will use the existing raster thus keeping the cell size and extent. – Michael Stimson Jul 24 '14 at 0:56
  • 2
    Yes, that is the intent. The C function for rasterize (GDALRasterizeGeometries) must have an existing raster; if you supply a raster path to the tool that doesn't exist the first thing it does is create the raster and then rasterize using that. – Michael Stimson Jul 24 '14 at 3:16
  • 2
    It does not overwrite existing raster it just burns pixels into it. Create a background raster from a big polygon that covers your data as all white and you should be fine. – user30184 Jul 24 '14 at 9:34

Your Answer

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

Browse other questions tagged or ask your own question.