Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Best practice for paths - arcpy.env.workspace vs os.path.join

$
0
0
Hi,

I've recently had an odd error and found it was due to the way I set up the input. The really odd thing is that some tools worked, but another (arcpy.CalculateStatistics_management) failed with the error:

Failed to execute. Parameters are not valid.
ERROR 000840: The value is not a Mosaic Dataset.
ERROR 000840: The value is not a Mosaic Layer.
ERROR 000840: The value is not a Raster Dataset.

Even though checking the input showed it to be valid raster dataset.

Here's the code that failed:

Code:

arcpy.CalculateStatistics_management("demExtract","1","1","#","OVERWRITE")
If I put the full path, it worked. Seems that setting arcpy.env.workspace didn't work for this tool. Using this worked:

Code:

arcpy.CalculateStatistics_management((os.path.join(gdbPath, "demExtract")),"1","1","#","OVERWRITE")
Is os.path.join something that should be used by default?

Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images