Hoping to have post this message in the right section, I reports a trouble experienced in the creation of raster from polygon feature class using the conversion tool "PolygonToRaster".
If I I set the environment extent the raster that has been created by the tool reports a "blank" area whose pixels are "nodata". If no extent is set, the raster is created with the correct representation of input polygon coverage (any "nodata" pixels ...)
The extent of the feature class is little bit grater that the output extent I have set.
I have also performed a "Check geometry" before to execute the tool.
Here is the python code that reproduces the wrong result:
arcpy.env.overwriteOutput = True
GDB_locale = r'C:\TEMP\rcwh0\scratch.gdb'
clu_fc = r'C:\TEMP\rcwh0\scratch.gdb\rcwh0'
mca_ras = os.path.join(GDB_locale, "mca_ras")
out_cellsize = 2
desc = arcpy.Describe(clu_fc)
xmin = desc.extent.XMin
xmax = desc.extent.XMax
ymin = desc.extent.YMin
ymax = desc.extent.YMax
print "Extent of %s \nxmin: %s \nxmax: %s \nymin: %s \nymax: %s" % (clu_fc, xmin, xmax, ymin, ymax)
arcpy.env.extent = "359900 5059900 370100 5070100"
xmin = arcpy.env.extent.XMin
xmax = arcpy.env.extent.XMax
ymin = arcpy.env.extent.YMin
ymax = arcpy.env.extent.YMax
print "Env extent \nxmin: %s \nxmax: %s \nymin: %s \nymax: %s" % (xmin, xmax, ymin, ymax)
arcpy.PolygonToRaster_conversion(clu_fc, "CODE_H", mca_ras, "MAXIMUM_COMBINED_AREA", "NONE", out_cellsize)
I get the same wrong raster regardless the cell assignement parameter value set in the tool.
I have attached the file GDB in which there is the polygon feature class (rcwh0) used for the conversion, and the screen shot of the wrong raster created (in red color the nodata)
This trouble was experienced in ArcMap 10.8.1
Try the code variant using a "with" statement
so there are line numbers in your code people can reference
Unfortunately the "with" variant does not fix the trouble.
I have got the same bad raster.
Here is the code with the variant:
with arcpy.EnvManager(cellSize=2, extent="359900 5059900 370100 5070100"): xmin = arcpy.env.extent.XMin xmax = arcpy.env.extent.XMax ymin = arcpy.env.extent.YMin ymax = arcpy.env.extent.YMax print "Env extent \nxmin: %s \nxmax: %s \nymin: %s \nymax: %s" % (xmin, xmax, ymin, ymax) arcpy.PolygonToRaster_conversion(clu_fc, "CODE_H", mca_ras, "MAXIMUM_COMBINED_AREA", "NONE", out_cellsize)
out_cellsize is defined elsewhere? or use
out_cellsize=cellSize from your "with" statement
What happens when you change the Cell assignment type to the default
and try a *.tif in a folder as output
It keeps failing when done manually (aka, no code)
You have thousands of tiny polygons less than a fraction of a m^2, I cleaned those out and it still fails.
I would work with the polygon file to find out what the problem is. Do it in ArcToolbox, I got a warning about the spatial index, try recreating the spatial indices after removing polygons less than your desired cell size
I have added a spatial index to the polygon feature class, having left the setting grid sizes to 0,0,0
Anyway, the converted raster again shows the nodata areas.
Without removing any tiny polygons, I have reduced the extent by the value of one cell size.
The conversion worked well !!
There aren't any tiny polygons along the "nodata" area, so I think that the tiny polygons are not responsible of this trouble. I have successfully converted other polygon coverages having thousands of tiny polygons as well.