# Euclidean Distance and Extent

1291
9
Jump to solution
06-25-2018 05:11 AM
Occasional Contributor II

Hi,

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")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
Tags (3)
1 Solution

Accepted Solutions
Occasional Contributor II

It works like this:

arcpy.env.extent = arcpy.Extent(-18040095.1961317, -9020047.34806998, 18039904.8038683, 9019952.65193002)

Mollweide projection

9 Replies
Esri Esteemed Contributor

What coordinate system are you working with?

Occasional Contributor II

Projected Coordinate System: World_Mollweide
Projection: Mollweide
False_Easting: 0.00000000
False_Northing: 0.00000000
Central_Meridian: 0.00000000
Linear Unit: Meter

Geographic Coordinate System: GCS_WGS_1984
Datum: D_WGS_1984
Prime Meridian: Greenwich
Angular Unit: Degree

MVP Legendary Contributor

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

Occasional Contributor II

Thanks Dan.

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")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
Occasional Contributor II

As I previously mentioned, no problem at all when using the tool in ArcMap and setting the  global Extent

Esri Esteemed Contributor

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.

Occasional Contributor II

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

Occasional Contributor II

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")‍‍‍‍‍‍‍‍‍‍``````
Occasional Contributor II

It works like this:

arcpy.env.extent = arcpy.Extent(-18040095.1961317, -9020047.34806998, 18039904.8038683, 9019952.65193002)

Mollweide projection