Using ConvertCoordinateNotation_management on geometry objects without writing files

2781
4
Jump to solution
03-05-2014 07:06 AM
FredSpataro
Occasional Contributor III
Howdy Ho All:

Has anyone been able to use the ConvertCoordinateNotation_management tool with input and output geometry objects?  I've been able to use the geometry objects in other tools be this one returns me "unable to convert coordinate".  I'd really rather not loop all my geometries write a file, then re-read the file and re-associated the coordinate with the existing data. Hopefully I'm just not getting the parameter correct for this type of usage. Example:

gcsnad83 = arcpy.SpatialReference(4269) pt = arcpy.Point() pt.X = 42.6544321 pt.Y = -143.132412 ptg = arcpy.PointGeometry(pt,gcsnad83) g = arcpy.Geometry() s = arcpy.ConvertCoordinateNotation_management(ptg, g, "#", "#", "SHAPE", "MGRS", "#", "#")   print(arcpy.GetMessages(0)) print s
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Fred,

I don't believe you will be able to use a geometry object for the output.  You could create a table in_memory.  Ex:

gcsnad83 = arcpy.SpatialReference(4269) pt = arcpy.Point() pt.X = -13.6544321 pt.Y = -123.132412 ptg = arcpy.PointGeometry(pt,gcsnad83) g = r"IN_MEMORY\table" arcpy.ConvertCoordinateNotation_management(ptg, g, "#", "#", "SHAPE", "MGRS", "#", "#")  with arcpy.da.SearchCursor(g, ["MGRS"]) as cursor:     for row in cursor:         print row[0]  del cursor

View solution in original post

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Fred,

I don't believe you will be able to use a geometry object for the output.  You could create a table in_memory.  Ex:

gcsnad83 = arcpy.SpatialReference(4269) pt = arcpy.Point() pt.X = -13.6544321 pt.Y = -123.132412 ptg = arcpy.PointGeometry(pt,gcsnad83) g = r"IN_MEMORY\table" arcpy.ConvertCoordinateNotation_management(ptg, g, "#", "#", "SHAPE", "MGRS", "#", "#")  with arcpy.da.SearchCursor(g, ["MGRS"]) as cursor:     for row in cursor:         print row[0]  del cursor
0 Kudos
FredSpataro
Occasional Contributor III
Jake:

Thanks for the quick response.  I still get the same error message so maybe it doesn't like the geometry object as an input either?

Executing: ConvertCoordinateNotation in_memory\f776A99E1_FA0B_4D1A_B0D1_081A2469BF22 IN_MEMORY\table # # SHAPE MGRS # "GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision"
Start Time: Wed Mar 05 12:01:20 2014
WARNING 001293: Coordinate conversion failed for 1 records.
Succeeded at Wed Mar 05 12:01:20 2014 (Elapsed Time: 0.03 seconds)


Probably just create an in memory table for the input as well...?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
What version of ArcGIS Desktop are you running?  I was able to get this to work using 10.2.1.
0 Kudos
FredSpataro
Occasional Contributor III
hmmm... looks like an issue with 10.2.0.  I tried both 32 and 64 bit python on this machine and get the same error.  On my laptop that has 10.2.1, the 32 bit python works correctly.  I don't have the 64 bit version installed there but will update this if there's any issue with that version.

Thanks for the help.
0 Kudos