0

I am working on a script tool to create watersheds. Part of my process requires a distance raster from various features that I use in an equation to perform local modifications to my DEM.

I have been unable to get arcpy.sa.EucDistance() to do anything when working with the in_memory workspace.

If I set the output to an FGDB it appears to work.

What am I missing to get this to work in_memory?

# convert vector points to raster points
# this output is successful
# I can do arcpy.CopyRaster_management(pp_ras, out_FGDB) and see 
# that in_memory\pp__ras looks like i expect.

arcpy.FeatureToRaster_conversion(pourpoints, "OBJECTID",r"in_memory\pp__ras", dem) 
pp_ras = r"in_memory\pp__ras"  



# when I get to this part running in IDLE, the script just terminates with no
# pessages. If I print results from every step, the last one printed is me 
# setting teh pp_ras variable
# when I run from the script tool i'm building this into, the progressor gets 
# to "saving raster" and just  sits forever and I have to kill ArcMap/Catalog

euc_dist_in = arcpy.sa.EucDistance(r"in_memory\pp__ras", "", "", "", "")
euc_dist_in.save (r"in_memory\dist")
euc_dist = r"in_memory\dist"
  • Wrong use of tool, look at script example in help. – FelixIP Nov 7 '19 at 20:05
  • I'll happily admit to being an ameture, but don't see how I'm doing anything different from the example – Zipper1365 Nov 7 '19 at 20:31
  • Remove arcpy.sa and delete one of "'. The way you use it requires explicit declaration of output raster – FelixIP Nov 7 '19 at 23:07
  • Don't forget to import * from sa at the beginning. – FelixIP Nov 7 '19 at 23:09
  • appreciate the input. but just couldn't get it. ended up running it as arcpy.gp.EucDistance_sa(inSourceData, r"in_memory\eucdist_all", "", cellSize, "", "PLANAR") it's probably not the cleanest or "correct way" but it's giving me the result I need and also appears to work with raster processing envi setting which helps me out too. Definitely a topic to move up on list of things to learn more about. – Zipper1365 Nov 12 '19 at 15:56
0

Set the default workspace setting to in_memory. Something like this.

arcpy.env.workspace = r"in_memory"

Then change the names of your outputs to from "in_memory\foo" to "foo"

See this example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.