I have many .ncf files that I read as raster layers and then do zonal statistics to have mean and sd values over each of 3108 CONUS counties. But the final standalone table is missing 245 counties. This is how the raster layer and the counties look together. You see that the raster covers all the polygons
And the picture below shows missing counties from the resulted zonal statistics in red color.
This is my code that loops over different files with same rasters only different values in cells and the same shape file for zonal boundaries.
# Set the analysis environments env.workspace = r"C:\ArcGIS_projects\PM25" rasrtersFolder = r"C:\ArcGIS_projects\PM25\V4NA03\\" zonalOutFolder = r"C:ArcGIS_projects\PM25\zonal_stats\\" variable = "PM25" XDimension = "LON" YDimension = "LAT" outRasterLayer = "PM25" bandDimmension = "" dimensionValues = "" valueSelectionMethod = "" cellRegistration = "" # for zonal statistics inZoneData = 'CONUS_counties_2016_WGS1984' zoneField = 'GEOID' inValueRaster = 'PM25' for fileName in files: # Reading netcdf file into raster layer inNetCDFFile = rasrtersFolder + fileName # Execute MakeNetCDFRasterLayer arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension, outRasterLayer, bandDimmension, dimensionValues, valueSelectionMethod, cellRegistration) # Now doing zonal statistics outName = fileName.split('.') outTable = zonalOutFolder + outName+'.dbf' outZSaT = ZonalStatisticsAsTable(inZoneData, zoneField, inValueRaster, outTable, "DATA", "MEAN_STD") # Set local variables inTable = outName outLocation = r"C:\Users\babak.jfard\ArcGIS_projects\PM25\zonal_stats_csv" outTable = outName.split('-') + ".csv" # Execute TableToTable arcpy.TableToTable_conversion(inTable, outLocation, outTable) arcpy.management.Delete('PM25') arcpy.management.Delete(outName) arcpy.management.Delete(outTable)
the files to reproduce can be found here: (All projection are set to WGS1984 to align with the ncd files)
Is it possible to be related to my updated ArcGIS pro (2.8.2)? two weeks ago I did the very same with an older version of ArcGIS pro and worked perfectly. Last night I updated my ArcGIS pro, and the very same raster and feature have missing zones in the results
Solved! Go to Solution.
Thanks, can you please also share the shapefile
Sure. I just corrected its link in the original question. Now everyone clicking it can get access to the file.
For a workaround, please use the new MakeMultidimensionalRasterLayer tool to add the PM25 layer to your analysis in Pro. This tool creates a raster layer from a netCDF file with specified variables and dimensions: Try, arcpy.md.MakeMultidimensionalRasterLayer(r"C:\data\V4NA03_PM25_NA_200007_200007-RH35.nc", "PM25_MMRL", "PM25")
Then use the raster layer in your Zonal tool, as you have done above. Your new output should contain the same number of zones, as in your CONUS counties dataset.