0

I'm converting a Python script that I usually run in the ArcMap Python window into a tool for others to use - something I always struggle with more than I should.

In the original scrip I have these lines:

streamOrder = arcpy.sa.StreamOrder(riverRastBin, Flow)
arcpy.sa.StreamToFeature(streamOrder, Flow, "RiverLines.shp")
riverDist = EucDistance("RiverLines", "", 25)

This worked fine in the original but when I run it in the tool it can't find RiverLines, presumably because it doesn't add it to the map of a layer, so I added a line to declare it:

streamOrder = arcpy.sa.StreamOrder(riverRastBin, Flow)
arcpy.sa.StreamToFeature(streamOrder, Flow, "RiverLines.shp")
RiverLines = arcpy.env.workspace + "\\RiverLives.shp"
riverDist = EucDistance("RiverLines", "", 25)

But no, this doesn't make any difference - same error message:

ERROR 000865: Input raster of feature source data: RiverLines does not exist

Is there a special way I need to declare it as a shapefile, or can I take the output directly from the previous step?

1 Answer 1

1

I think the immediate issue is that you have quoted "RiverLines" rather than a non-quoted variable RiverLines

RiverLines = arcpy.env.workspace + "\\RiverLives.shp"
riverDist = EucDistance(RiverLines, "", 25)

Instead of declaring RiverLines = arcpy.env.workspace + "\\RiverLives.shp" you could set the variable as the output of your StreamToFeature. This doesn't work with every tool, so not 100% sure it will work.

RiverLines = arcpy.sa.StreamToFeature(streamOrder, Flow, "RiverLines.shp")
riverDist = EucDistance(RiverLines, "", 25)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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