Convert data type in Euclidean distance calculation script

1116
5
04-17-2012 06:29 AM
AndrewOrr
Occasional Contributor
Hi all,
I have a python script where I'm trying to perform a Euclidean distance on a feature class to generate a raster. The map units are meters so it outputs the cell size in meters as an integer format. I want it in miles, so I multiply by a constant to convert to miles. This, however, does not change the integer data format to a floating point. Is there any way to specify or convert the output Euclidean distance data format to FP so I can get an output as FP?

Here is the line of code I'm using in the script:

OutEucDistance = (EucDistance(src_layer, "", resolution, "")*0.000621371192)


Thanks for the help,
-Andy
0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus
according to the help
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000001p000000.htm
the output raster is supposed to be floating point, perhaps trying to multiply that raster by a constant raster outside you euclidean distance might work
0 Kudos
AndrewOrr
Occasional Contributor
That's an idea! I'll look into it. Thanks!
-Andy
0 Kudos
curtvprice
MVP Esteemed Contributor
This, however, does not change the integer data format to a floating point. Is there any way to specify or convert the output Euclidean distance data format to FP so I can get an output as FP?


As Dapper Dan pointed out, the output of EucDistance should be floating point. And, (integer * float) should always give you float. But if you want to make triple sure, you can always convert a grid to float using the Float tool.

One thing that may be messing you up is the artificial ArcGIS designation of a raster as "discrete" or "continuous", which is used for symbology but can be unrelated to the pixel data type.

from arcpy.sa import *
...
OutEucDistance = Float(EucDistance(src_layer, "", resolution, "")) * 0.000621371192
0 Kudos
curtvprice
MVP Esteemed Contributor
This, however, does not change the integer data format to a floating point. Is there any way to specify or convert the output Euclidean distance data format to FP so I can get an output as FP?


As was pointed out, the output of EucDistance should be floating point. And, integer * float should give you float. But if you want to make triple sure, you can always convert a grid to float using the Float tool.

from arcpy.sa import *
...
OutEucDistance = Float(EucDistance(src_layer, "", resolution, "")) * 0.000621371192
0 Kudos
AndrewOrr
Occasional Contributor
Excellent, that worked very well curtvprice.

Thanks!
-Andy
0 Kudos