rogerloweth

arcpy datum shift and reprojection VERY slow

Discussion created by rogerloweth on Aug 2, 2011
Latest reply on Aug 3, 2011 by rogerloweth
Good morning,

I am trying to convert coordinates in one projection to lat/lon on a different datum and also their corresponding projected easting/northing. Here is my code - which works but it is slower than GDAL/OGR/PROJ.4 method by a factor of 100!!! . Any reason why it should run so slowly??? Is there a way of doing it in pure arcpy code without using feature classes?

    """
    transform a pair of coordinates from the input crs
    to the output GEOGCS and output PROJCS
    making use of temporary feature class
    """
    global latitude, longitude, lat_value, lon_value, easting, northing

    #create temporary feature class to contain coordinate pairs
    arcpy.env.overwriteOutput = True
    cur = arcpy.InsertCursor(fc, inCRS)
    pnt = arcpy.Point()
    pnt.ID = 1
    pnt.X = lon_value
    pnt.Y =lat_value
    feat = cur.newRow()
    feat.shape = pnt
    cur.insertRow(feat)
    del cur
    #update cursor to outGEOGCS and extract lat lon
    rows = arcpy.UpdateCursor(fc, "", outGEOGCS)
    for row in rows:
        feat = row.shape
        coord = feat.getPart()
        longitude = coord.X
        latitude = coord.Y
        rows.updateRow(row)
    del row
    del rows
    #update cursor to outPROJCS and extract east north
    rows = arcpy.UpdateCursor(fc, "", outPROJCS)
    for row in rows:
        feat = row.shape
        coord = feat.getPart()
        easting = coord.X
        northing = coord.Y
        rows.updateRow(row)
    del row
    del rows


Thanks, Roger

Outcomes