I need to calculate some Euclidean Distances out of a list of FCs in a GDB.
I notice that when using an extent (in this case a global extent - see script) it does not work. It does work without specifying an extent but I do need to use one otherwise the resulting raster is a bit cut out at the edges.
When using the tool in ArcMap and specifying the extent in the Environments it does work.
Any help/suggestions will be greatly appreciated.
import arcpy from arcpy import env arcpy.env.overwriteOutput=True from arcpy.sa import* arcpy.CheckOutExtension("Spatial") arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0) env.workspace = r"H:\OUTPUT.gdb" fcdist = arcpy.ListFeatureClasses("") for fc in fcdist: output = EucDistance(fc, 250000, 10000, "") output.save(env.workspace + "\\" + fc + "_250km")
Solved! Go to Solution.
Projected Coordinate System: World_Mollweide
Linear Unit: Meter
Geographic Coordinate System: GCS_WGS_1984
Prime Meridian: Greenwich
Angular Unit: Degree
Euclidean distance requires projected coordinates, it performs no projection during the process, you have to project the input data before using the tool, if the data are in geographic. Setting your extent to geographic is going to cause issues as you have found.
Euclidean - planar - projected …. otherwise things are .... spherical or geodesic
The Euclidean Distance calculation is the end part of a larger script. In the previous step I do project the FCs to Mollweide. It is just when using the Extent that does not work but I guess it may still be related with the problem?
# reproject to Mollweide and create 250km buffer fcprj = arcpy.ListFeatureClasses() for fc in fcprj: mollweide = arcpy.SpatialReference("Mollweide (world)") arcpy.BatchProject_management(fc, OUTworkspace, mollweide, "", "") fcdist = arcpy.ListFeatureClasses("*1") for fc in fcdist: output = EucDistance(fc, 250000, 10000, "") output.save(OUTworkspace + "\\" + fc + "_250km")
If I look at the domain property of the Mollweide (world) spatial reference I see this:
-18040200 -9020200 900701885274,099 900710905274,099
When you work inside a session of for instance ArcMap, a number of environment setting will be set based on your current dataframe settings. When you run a standalone script these settings are not there, so behavior will be different.
To be more precise when using the tool in ArcMap session:
It works when I use the "same as layer..." (in this case I use a Bathymetry raster layer) in the Processing Extent option within Environment Settings.
If I use " As specified Below" option and I enter the extent manually it does not work.
I don't quite get it to be honest
Just to add:
The script works with the FCs in Geographic Coordinates (degrees) using the global extent (below)
I would expect the same in Mollweide Projected (meters) especially as you are measuring distances...
arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0) env.workspace = r"H:\OUTPUT.gdb" fcdist = arcpy.ListFeatureClasses("") for fc in fcdist: output = EucDistance(fc, 5, 0.5, "") output.save(env.workspace + "\\" + fc + "_250km")