Select to view content in your preferred language

Project a geometry to another geometry in memory

5941
3
02-22-2012 02:17 PM
DarrylKlassen
Deactivated User
Hello,
Is it possible to project a geometry to another geometry in memory using ARCPY.  I am trying to take a XY coordinate and create in memory features to project the coordinate system.  I have used the following code to do so, but the project statement doesn't work.  I get ERROR 000944: Output feature class cannot be in the in_memory workspace.

import string,sys,os,arcpy

point = arcpy.Point(x_coord,y_coord)
Pnt_geom = arcpy.PointGeometry(point, in_coord_system)
Pnt_geom_out = arcpy.Geometry()

mytestlayer = arcpy.Project_management(Pnt_geom, Pnt_geom_out, out_coord_system, "#", in_coord_system)

desc = arcpy.Describe(mytestlayer)
print desc.extent.XMin
print desc.extent.YMin

# EOF

This code works if i put in a shapefile name in the place to the Pnt_geom_out variable.
My 4 variables (x_coord, y_coord, in_coord_system, out_coord_system) are all valid.

Thanks
Darryl Klassen
GIS Analyst
darryl.klassen@gmail.com
3 Replies
GraemeBrowning
Frequent Contributor
Unfortunately, this seems to be a documented software limitation of in_memory workspaces.

I say unfortunately because I just hit it too
0 Kudos
BruceHarold
Esri Regular Contributor
Hi

The workaround is to project the geometry in-place with projectAs:

http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000070000000

Regards
0 Kudos
GraemeBrowning
Frequent Contributor
Hi

The workaround is to project the geometry in-place with projectAs:

http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000070000000

Regards


This looks like an excellent workaround for the original poster but I am not sure that it will be able to help me.  The reason for that is that the feature class that I want to Project has (at a guess, because I am not onsite today to check) 10,000 or so polygons, and in this instance I cannot use arcpy.da because that client is at ArcGIS 10.0.
0 Kudos