Is there a way to extract the XMin, YMin, XMax and YMax coordinate values from a feature without using ArcMap's Field Calculator? Is there a tool or other way to programmatically pull out these particular coordinates?
I'm in ArcGIS 10.2, working with multipoint features. I also have an ASCII text file with coordinates of each point, if that helps.
This demo I posted recently, but can't find it now, so I will repost.
It is a demo,
hope this gives you some ideas
import arcpy input_shp = 'c:/your_path_here/your_shapefile.shp' arr = arcpy.Array() with arcpy.da.SearchCursor(input_shp,['FID','SHAPE@']) as cur: for row in cur: ext = row[1].extent p0 = ext.lowerLeft; p1 = ext.upperRight print('Extent of shape... {}: '.format(row[0])) print(' X min/max {}, {}'.format(ext.XMin,ext.XMax)) print(' Y min/max {}, {}'.format(ext.YMin,ext.YMax)) arr.add(p0) arr.add(p1) mp = arcpy.Multipoint(arr) print('Extent of all {}'.format(mp.extent))
If your objective is to create 4 fields with the extent values in it for each feature, you could use this:
import arcpy fc = r"C:\Path\To\Your\fgdb.gdb\FeatureclassName" flds = ["XMin", "YMin", "XMax", "YMax"] # add fields to output featureclass for fld in flds: if len(arcpy.ListFields(fc, wild_card=fld)) == 0: arcpy.AddField_management(fc, fld, "DOUBLE") flds.insert(0, "SHAPE@") with arcpy.da.UpdateCursor(fc, flds) as curs: for row in curs: ext = row[0].extent for fld in flds[1:]: row[flds.index(fld)] = eval("ext.{0}".format(fld)) curs.updateRow(row)