0

I need to calculate Variety of pixels for every polygon in a shapefile but the analysis returns zero.

Polygons are much bigger than a raster cell which is 10 m. Polygons are completely covered with raster cells. Raster cells have 8 categories - from 1 to 8 (reclassified aspect). No Data from original aspect raster were converted to 0 (at least this was set in a reclassification dialog). Polygons, raster and project have the same coordinate system (EPSG 5514) and are stored on a disk, no temp layers. Polygons have valid geometry with no errors. Raster is a geoTIFF.

raster and polygons

I have searched all the questions with "Zonal stats returns zero or empty values", tried the solutions in there but with no luck. I have no idea what´s wrong.

The analysis doesn´t work for me in QGIS 3.10.4 LTR, the log says nothing wrong, it just doesn´t do what it should. When I tried the same in QGIS 2.18 the analysis fails with a KeyError:

KeyError

Any tips?

  • Saving raster to different format (I tried ESRI hdr and geopackage) doesn´t solve it. – jonlew Apr 29 at 11:03
  • Saving polygon shapefile to different format (I tried geopackage) doesn´t solve it. – jonlew Apr 29 at 12:07
  • Converting polygons to wgs84, raster to wgs84 or both to wgs84 didn´t help. – jonlew Apr 29 at 12:29
  • I´d be happy if you tested it yourself in your QGIS versions... Zip with data is here: transfernow.net/RlrNmx042020 – jonlew Apr 29 at 12:55
  • Have you made sure the polygons are valid? Try Fix geometry – BERA Apr 29 at 13:39
1

Fixing geometry in QGIS showed no issues as well as checking validity or all those fixing things in QGIS. I had to Repair geometry in ArcGIS - polygons had several self-intersections that QGIS hadn´t recognized. Zonal statistics with repaired polygons works well now.

| improve this answer | |

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.