Select to view content in your preferred language

What is the proper way to reproject a geometry object using arcpy?

1564
3
Jump to solution
06-10-2020 10:15 AM
EricEagle
Frequent Contributor

I am working with a geometry object projected in EPSG 6455 but would like to add its extent to a feature class that is in EPSG 4326.

arcpy.Project_management() wants a feature class as input and output.

Here's what I've got so far (please note that using ZLAS is in no way an endorsement of ZLAS as a proprietary format)

### ZLAS testing ###
zlas = "C:/Data/USGS_LPC_IL_4County_Cook_2017_LAS_15008550_LAS_2019.zlas"

des = arcpy.Describe(zlas)

print(des.dataType)
print(des.spatialReference.factoryCode)
print(des.extent)

polys = []

las_extent = [
            [
                [des.extent.YMin, des.extent.XMin],
                [des.extent.YMax, des.extent.XMin],
                [des.extent.YMax, des.extent.XMax],
                [des.extent.YMin, des.extent.XMax]
            ]
        ]
for coord_ring in las_extent:
    poly = arcpy.Polygon(arcpy.Array([arcpy.Point(*coords) for coords in coord_ring]), arcpy.SpatialReference(6455))
    polys.append(poly)

How would I coerce "poly" from 6455 to 4326 without incurring the IO expense of writing feature classes?

The background, if useful: I am plowing through a directory structure with thousands and thousands of point clouds.  The intent is to gather their extents, add them to a global feature class, and then serve that feature class up as a service identifying where all of our holdings are, allowing users to browse our holdings geographically rather than trying to hunt through a directory tree.  Because many of the files are projected differently (some requiring transformation - default transformation being fine as this isn't high precision) I want to harmonize them all into a single GCS feature class.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

Like this example in

Polygon—ArcPy classes | Documentation 

projectAs (spatial_reference, {transformation_name})
ParameterExplanationData Type
spatial_reference

The new spatial reference. This can be a SpatialReference object or the coordinate system name.

SpatialReference
transformation_name

The geotransformation name.

String

... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

Like this example in

Polygon—ArcPy classes | Documentation 

projectAs (spatial_reference, {transformation_name})
ParameterExplanationData Type
spatial_reference

The new spatial reference. This can be a SpatialReference object or the coordinate system name.

SpatialReference
transformation_name

The geotransformation name.

String

... sort of retired...
EricEagle
Frequent Contributor

Thanks Dan...  Sometimes one just needs a pointer to the right doc. I tell ya, if the Esri UC was happening this year I'd hunt you down and buy you an adult beverage of your choice.  Really appreciate all the help.

DanPatterson
MVP Esteemed Contributor

I will be online    


... sort of retired...
0 Kudos