1

I am very new to ArcGIS Pro and have been struggling with getting the minimum and maximum latitude/longitude of an area in ArcGIS Pro. I am looking to get four coordinates of a rectangle that encompasses each polygon I have in a shapefile.

I have tried calculating extents of the minimal bounding geometry rectangles and vertices to points, so I thought I would reach out here. This is a description of what I have done so far.

I have about 2800 polygons in a shape file that represent conservation areas across the US. I used the minimal bounding geometry method of arcpy (script below) to get rectangles that encompass each polygon:

arcpy.MinimumBoundingGeometry_management('US_IBAs_2018Feb',"G:\IBA_Update\GIS\Bounding\Output", "RECTANGLE_BY_AREA", None)

I then tried to calculate the extent geometry attributes of each rectangle. This seemed to work, but I could not figure out why the x/y min/max weren't being displayed in decimal degrees instead of meters (see photo).

min/max coordinate units

arcpy.AddGeometryAttributes_management('Output', 'EXTENT')

I tried making sure the map and the map and what is being returned from the extent were both in WGS84 or Web Mercator Aux Sphere, but had the same problem each time.

So from here I decided to just try and use the vertices to point tool. This gave me four coordinate points of each rectangle which is exactly what I need! However, all of the points have the same coordinate.

Vertices to Points Repeated Coords

How can I correct this issue?

1
  • This Add Geometry Attributes tool/function supports both output coordinate system (gp environment) and an optional coordinate system parameter. Try setting one of those first to WGS84 (4326)
    – mkennedy
    Commented Sep 16, 2019 at 18:46

1 Answer 1

-1

Import your shp to gdb.

Code below will print each polygon extent:

import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"GDB"
fc = 'feature_class'

count = int(arcpy.GetCount_management(fc)[0]) +1

for fid in range(1, count):
        arcpy.MakeFeatureLayer_management(fc, 'temp','"OBJECTID" = {}'.format(fid)))
        arcpy.CopyFeatures_management('temp', r'in_memory\temp_{}'.format(fid))
        arcpy.RecalculateFeatureClassExtent_management(r'in_memory\temp_{}'.format(fid))
        arcpy.PolygonToRaster_conversion(r'in_memory\temp_{}'.format(fid), 'OBJECTID', r"in_memory\raster_{}".format(fid))
        elevRaster = arcpy.sa.Raster(r"in_memory\raster_{}".format(fid))
        myExtent = elevRaster.extent

        print(f'OBECJTID: {fid} XMin: {myExtent.XMin}, YMin: {myExtent.YMin} XMax: {myExtent.XMax} Ymax: {myExtent.YMax}')
1
  • This is a serious kludge. The same information is available from a trivial DA SearchCursor, retrieving the Extent of the shape@ column and then accessing the XMin/YMin/XMax/YMax propertties. Such a solution doesn't require the change in format, or the risky for loop, or raster conversion (which loses corner resolution).
    – Vince
    Commented Sep 16, 2019 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.