Running multiple Spatial Analyst processes

2400
3
09-22-2015 07:47 AM
EvanBlaisdell
New Contributor III

Hello.  I am using a Python script to run the SegmentMeanShift tool of Spatial Analyst, via arcpy:

arcpy.CheckOutExtension("Spatial")

seg_raster = SegmentMeanShift(in_raster, "20", "15", "10")

seg_raster.save(segments)

Running one instance of the tool works just fine.  However, calling a new instance (on a different dataset) immediately fails.

Does anyone know how to successfully kick off multiple processes?  It needs to be such that the script is called independently for each dataset (i.e., I can't know ahead of time how many datasets I will need to process; a second, or third, etc., process may be called at any time after the first one).  Thanks.

0 Kudos
3 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Hmmm some questions

  • where is in_raster defined?
  • where is segments defined?
  • what are you going to call the output file?
  • is your environment location defined somewhere?
  • What do you to call you output files?
  • are you satisfied just to have a changing number appended to a base filename?

That's all for now

0 Kudos
EvanBlaisdell
New Contributor III

Dan Patterson:

Hmmm some questions

  • where is in_raster defined?
  • where is segments defined?
  • what are you going to call the output file?
  • is your environment location defined somewhere?
  • What do you to call you output files?
  • are you satisfied just to have a changing number appended to a base filename?

That's all for now

in_raster, seg_raster, and the output file (segements) are defined in the script before the three lines I provided. They are simple file locations on the local disk (e.g., D:\\path\\to\\dir\\raster.img)

Which environment settings are you referring to?  I have experimented with setting arcpy.env.workspace and scratchWorkspace.  I assume the scratch workspace should be different for each process?

The output files need to be named based on the input file, not an incrementing number.

Thanks!

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Ok it would be best to provide code sample you are working with so that it can be incorporated within a for loop

0 Kudos