6

I want to polygonize a raster file with GDAL. I only want to rasterize cells with a value of 0. Is it possible to specify that within the polygonize function or do I have to modify my raster before hand?

11

No, it's not possible directly in the function. You can either a) reclassify the raster first (probably fastest and easiest), or 2) convert to vector then delete all non-zero polygons, or 3) create a mask, and pass that to gdal_polygonize using -mask (see manual.)

1
  • 4
    Thank for suggestions. I tested the first and third methods, and the third one works for me. The reason why the first one did not work was that even if I reclassified the raster (1 for the part, which I want to polygonize, nodata for the part, which I want to delete), the GDAL polygonize function still converted the whole raster into polygons. So, just classify raster into 1 and 0 for the mask, and you should be good to go. – Vicky Liau Apr 23 '15 at 0:17

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.