Select to view content in your preferred language

Projection with cursors

1656
10
08-09-2011 01:26 AM
RogerLoweth
Emerging Contributor
According to the ArcGIS 10 help, one should be able to re-project using cursors thus:

#update cursor to fc and input lat lon
    rows = arcpy.UpdateCursor(fc, inCRS)
    for row in rows:
        pnt = arcpy.Point()
        pnt.X = lon_value
        pnt.Y = lat_value
        row.shape = pnt
        row.shape = pnt
        rows.updateRow(row)
    del row, rows
    #project to outGEOGCS
    rows = arcpy.SearchCursor(fc, outGEOGCS)
    for row in rows:
        feat = row.shape
        coord = feat.getPart()
        longitude = coord.X
        latitude = coord.Y
    del row, rows
    #project to outPROJCS
    rows = arcpy.SearchCursor(fc, outPROJCS)
    for row in rows:
        feat = row.shape
        coord = feat.getPart()
        easting = coord.X
        northing = coord.Y
    del row, rows

This code attempts to read in a point in one CRS and transform it to a different datum and then to another projection.

I get no errors but the re-projection simply does not work. Unfortunately I can't use the GDAL/OGR libraries in my corporate environment (I wish I could!!).

Anyone know of a workaround please??

Also, this is DESPERATELY slow!!

Roger
Tags (2)
0 Kudos
10 Replies
MathewCoyle
Honored Contributor
I don't see anything in the documentation that indicates you cannot send the results of a arcpy.Project_management operation to an in-memory feature class. 

Just specify your output as "in_memory\\reprojected" or something similar.  When you're done with it, if you want to manually clear it out of memory, just use the arcpy.Delete_management tool, specifying it exactly as in the project tool.

Of course, just because the documentation doesn't say anything about requiring a physical storage output doesn't mean it isn't true.  You're just gonna have to try it!


http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000007m000000.htm
Point #4 under Usage
0 Kudos