Select to view content in your preferred language

With PolygonToRaster, not saving to "in_memory"

1201
7
10-31-2017 08:11 PM
YasunariMorita
Emerging Contributor

Hi,

I try to zonal statistics as Table in script.

my workflow is

  1. Copy feature to "in_memory"
  2. Make layer in "in_memory"
  3. PolygonToRaster
  4. zonal statistics as Table

In this workflow, output of  "PolygonToRaster" is temporal (finally delete).

So, I tried to save it at "in_memory" workspace, but not worked(crashed).

output raster size is about 5GB(save to gdb on HDD and check size), My memory is 32GB.Memory seems to be enough.

What should I do?

I use ArcGIS pro 1.4.1

Thanks in advance!

0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

things to try and report

  • did it fail when saved to disk instead of in_memory?
  • did you monitor system resources during a run
  • how about trying the same workflow... but use a smaller file

Also, report your cell size, extent, projection and snap raster used

JayantaPoddar
MVP Esteemed Contributor

What happens if you save the raster output to a defined workspace, and mark the Raster output as intermediate data.

A quick tour of managing intermediate data—Help | ArcGIS for Desktop 

Deleting intermediate data—Help | ArcGIS for Desktop 



Think Location
YasunariMorita
Emerging Contributor

Sorry for late reply

>Dan

  1. did it fail when saved to disk instead of in_memory?
  2. did you monitor system resources during a run
  3. how about trying the same workflow... but use a smaller file

I answer your questions.

1:No,it didn't fail.Saving to disk worked well.

2:I monitored memory consumption.When start PolygonToRaster,  it increased about 10GB,then crash.

it doesn't seem to be memory capacity problem.

3:trying some smaller polygon,it didn't fail(crash)...

it's the matter of polygon(complex shape, a lot of vertices, lots of features in polygon)?

>Jayanta

Thanks for your information!

I set scratch workspace to "in_memory".

I'm sorry that this is not the problem of model builder...

0 Kudos
YasunariMorita
Emerging Contributor

>Also, report your cell size, extent, projection and snap raster used

I add these information.

extent and snap raster are not used.

cell size and projection are below.

arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(4326)

arcpy.PolygonToRaster_conversion(feature_lyr, "OBJECTID", ras_feature, cellsize=0.00025)

0 Kudos
DanPatterson_Retired
MVP Emeritus

Beyond the issues that can arise with 'in_memory I would just recommend adding Delete_management to your workflow since you have clearly identified that things work fine when saved to disk.  It could be a combination of factors which would be hard to pin down.

YasunariMorita
Emerging Contributor

Thanks

 Though adding Delete_management , the problem still occurred.

I tried the script below.

arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"C:\Data\check.gdb"
features = arcpy.ListFeatureClasses()
feature = features[0]
feature_lyr = "in_memory\\featureLyr"
arcpy.MakeFeatureLayer_management(feature, feature_lyr)

ras_feature = "in_memory\\RasFeature"
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(4326)
arcpy.PolygonToRaster_conversion(feature_lyr, "OBJECTID", ras_feature, cellsize=0.00025)

When arcpy.PolygonToRaster_conversion,  the script crashed. Because saving to the disk work, I try the modified script.

arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"C:\Data\check.gdb"
features = arcpy.ListFeatureClasses()
feature = features[0]
feature_lyr = "in_memory\\featureLyr"
arcpy.MakeFeatureLayer_management(feature, feature_lyr)

tmp = r"C:\Data\check.gdb\tmpRas"
ras_feature = "in_memory\\RasFeature"
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(4326)
arcpy.PolygonToRaster_conversion(feature_lyr, "OBJECTID", tmp, cellsize=0.00025)
arcpy.BuildRasterAttributeTable_management(tmp, "Overwrite")
arcpy.CopyRaster_management(tmp, ras_feature)

In this script, crash happened when arcpy.CopyRaster_management....

As you said, it's hard to pin down...

0 Kudos
DanPatterson_Retired
MVP Emeritus

Sorry, I want clear... skip in_memory altogether, save interim results to disk and then add Delete_management to the workflow.  Whatever is going on hardware/software-wise, in_memory isn't working in your workflow.  In the end, you just don't want interim results kicking around (ie a purpose of in_memory useage) and Delete will handle that.

At least you can move forward with your work.

0 Kudos