arcpy PolygonToRaster ERROR 000918: Cannot retrieve feature class extent

2052
4
02-10-2017 06:23 AM
IsaacBoates
New Contributor

I am trying to convert a polygon feature class (created intermediately as part of a larger process) to a raster, which will have the same snap settings and cell size as another input raster. However, every time i try to run it, I get this error:

ExecuteError: ERROR 000918: Cannot retrieve feature class extent.

I cannot find any help on this issue and I don't know what to do. I have already seen this question and it did not help resolve the issue.

This is the code:

cell_size = float(GetRasterProperties(in_raster, 'CELLSIZEX').getOutput(0))  env.snapRaster = in_raster  PolygonToRaster(buffer_fc, z_field_name, stamp_raster, cellsize=cell_size)  return None

The same parameters work when I execute "Polygon To Raster" diretly from the ArcToolbox GUI.

0 Kudos
4 Replies
IsaacBoates
New Contributor

The formatting broke the code.

This is it:

cell_size = float(GetRasterProperties(in_raster, 'CELLSIZEX').getOutput(0))

env.snapRaster = in_raster

PolygonToRaster(buffer_fc, z_field_name, stamp_raster, cellsize=cell_size)
0 Kudos
IanMurray
Frequent Contributor

Here is the ESRI help for that error code:  http://pro.arcgis.com/en/pro-app/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-a...

From the help on the error code, I'd guess there is still a lock on the intermediate data after it is created, you mind posting code from where the intermediate data is created to where you run the Polygon to Raster? 

Also for code formatting on GeoNet https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting

0 Kudos
IsaacBoates
New Contributor

Hi Ian,

Someone on stackexchange GIS also suggested a schema lock issue, which turned out to be true.  I thought at first it was a problem with a da.UpdateCursor, but I used a with statement, so it should be releasing the locks.  Doing a del statement on the row and the cursor still didn't help.  In the end I was able to fix it by quickly copying the features to a new feature class and deleting it after.  Not optimal, but it works.  I think that there is some kind of schema lock applied by MultipleRingBuffer() that isn't releasing properly.  I found an old question on stackexchange that described a similar issue but it inexplicably stopped happening for them so there was no real insight to be gleaned from it.

0 Kudos
SteveLynch
Esri Regular Contributor

Please try the following:

- use CopyFeatures to create of copy of the polygon feature class

- use this copy in PolygonToRaster

and which version of ArcGIS are you using?

-Steve

0 Kudos