When rasterizing a vector layer I would like to achieve an output that contains 1 for areas covered by the shape and 0 for areas not covered. So far GDAL always converts areas that are not covered to nodata. I tried to change that with the following GDAL command but it does not work properly. I guess he burns nodata as zero but also the metainformation that zero = nodata so I cannot use the layer for raster algebra afterwards (all zells with nodata are excluded, however i'd like them to be zero in the algebra operation).

This is my gdal command:

gdal_rasterize -l GMW_clipped_2010 -a pxlval -tr 0.000269959 0.000269959 -init -999999999.0 -a_nodata 0.0 -te -94.9017777777779 10.918977291452409 -78.1278774106337 23.2768888888896 -ot Byte -of GTiff /home/GMW_clipped_2010.shp /tmp/processing_46ba07b600a54c5581ad63a22017470a/b2dc5cbedbf746a2b9dbbdb406bd35e8/OUTPUT.tif

You are specifically telling gdal_rasterize to set 0 to nodata with the -a_nodata 0.0 parameter you use.

You also specify -init -999999999.0 which doesn't make much sense as your output type is Byte (and you only want 0s and 1s)


gdal_rasterize -init 0.0 etc...
  • 1
    And if you have many files already with nodata set in the metadata you can clean just the metadata with gdal.org/programs/gdal_edit.html by using -unsetnodata.
    – user30184
    Sep 11 '20 at 9:41
  • both worked. thanks guys!
    – joaoal
    Sep 11 '20 at 13:43

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.