I'm new to GIS. I want the sum of nighttime lights (DMSP) by district for some country. I'm running this arcpy.gp.ZonalStatisticsAsTable_sa(Limites_distritales, "IDDIST", rc, temp_table, "DATA", "") and then converting to .csv. However, when I check the output some districts (identified by IDDIST) are missing. I've checked all my script and they shouldn't be dropped; my guess is that they are being assigned NoData because they overlap multiple grids (and no single grid is in the polygon) and thus no statistics are being calculated for them.

One of the problematic districts is shown in the picture below.

Is there a workaround for this?

enter image description here

The Zonal Statistics as Table documentation states the following:

If the areas of single features are similar to or smaller than the area of single cells in the value raster, in the feature-to-raster conversion some of these zones may not be represented.

I suspect the algorithm assigns raster values to the zone if that zone contains the raster centroid. In your example, no raster cell centroids exist within the zone.

I had the same problem. spent a lot of time discussing it with ESRI support and the end resolution was that the code behind zonal stats looks for the center of the pixel to be contained by the polygon zone.

If the zone doesn't contain a pixel center (or if a pixel does not have its center inside a zone) - even if it overlaps with the area of the pixel, it's omitted from calculations.

My work around was to convert my raster data to polygons and then do a bunch of overlay analysis to get my totals. it takes way more time and memory, but I like that it takes partial coverage into account, which actually gave me correct averages for my coverages.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.