Hellow
i try to extent to xy coordinate with arcpy? i using this code:
import arcpy, os, sys
from arcpy import env
env.workspace = r"C:\Project"
pnt = '178434 ,662446'
for mxdname in arcpy.ListFiles("*.mxd"😞
print mxdname
mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname)
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
df.extent = pnt
print 'extent'
mxd.save()
del mxd
but i get en error: ValueError: Invalid string value for Extent argument
any help would be great
Solved! Go to Solution.
Your extent needs to be a rectangle so you would need to find out the width and height of your data frame to be able to create an AOI from your point, i.e. if your point is the bottom left corner:
xmapdistance = df.extent.XMax - df.extent.XMin
ymapdistance = df.extent.YMax - df.extent.YMin
extentxmin = 178434
extentxmax = 178434 + xmapdistance
extentymax = 662446
extentymin = 662446 + ymapdistance
df.panToExtent(arcpy.Extent(extentxmin,extentymax,extentxmin,extentymax))
Your extent needs to be a rectangle so you would need to find out the width and height of your data frame to be able to create an AOI from your point, i.e. if your point is the bottom left corner:
xmapdistance = df.extent.XMax - df.extent.XMin
ymapdistance = df.extent.YMax - df.extent.YMin
extentxmin = 178434
extentxmax = 178434 + xmapdistance
extentymax = 662446
extentymin = 662446 + ymapdistance
df.panToExtent(arcpy.Extent(extentxmin,extentymax,extentxmin,extentymax))