I have a shapefile which contains 10.000 polygons and I want to know how many of them falls on a specific land use. Unfortunately, the land use map that I have to use is a raster map and not a vector map.

I created a mask from the raster map with 0-1 values for the land use I'm interested in, and I thought to convert the mask to a vector file: this way I can obtain the information that I want with simple vector processing tools.

However, I'm struggling to convert the raster to a polygon (maybe it's because it is a large raster, 10940 rows x 11404 columns with 20m pixel size). I've tried several methods, namely:

  1. Raster to Vector tool in QGIS;
  2. rasterToPolygons function in R;
  3. gdal_polygonize using the OSGeo4W shell);

This far, 1 and 2 literally crashed my computer after a while; 3 is running since 20 hours and it's around 70% complete, but after all this time I don't even know what to expect and I certainly do not have the time to re-run the script.

Is there a faster way to convert this raster?

  • 1
    Does "how many of them falls on a specific land use" mean at least one pixel of that land use type is in the polygon? No point vectorising the raster - that can make things very complicated. Simpler to compute the locations of the raster points in the polygon and sample from the raster. – Spacedman Mar 26 '19 at 11:51
  • what do you mean by "fall in a specific landuse" ? containing a small part ? havec their center in ? being fully covered by ? The raster based solution are probably more efficient than a vector-based solution, but the solution depends on your definition of "falling on landuse". The fastest method (if it is suitable for you) being the extraction of raster land cover value for each centroid. – radouxju Mar 26 '19 at 11:51
  • Didn't think about it. My smallest polygon covers about 5000 square meters, which is way bigger than one pixel surface (400); I solved calculating the sum of the pixel classified as 1 from the mask for each polygon with the zonal statistics. – D.K. Mar 26 '19 at 13:22
  • if you create smaller raster tiles from your raster you can test wether one algorithm gives you the desired ouput in much less processing time. when your result is ok, repeat it for the rest of the tiles! – sn1ks Sep 2 '20 at 9:13

After you already ran the raster calculator you have to use the contour lines tool (raster -> extraction), set the interval to 0.9 and you get lines, which you may polygonise using vector -> geometry tools -> lines to polygons.

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.