I am trying to set the extent of the ArcMap where I want to add the raster to my ArcMap but this does not work...
#Set the Scale extent arcpy.Extent(147806,3495023,584371,3899368)
I have looked at the ArcGIS 10.1 help about this but not sure which one is the correct way to display them .
Hi Robert,
Arcpy.Extent is an environment variable for geoprocessing tools. See the following help:
Output Extent (Environment setting)—Help | ArcGIS for Desktop
To update the data frame extent, you will need to use DataFrame class.
Thank you.
I tried to set the extent numbers in UTM but it would not allow me to... even I set the df as well...
#Set the df to refresh the "Set Extent"
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
arcpy.env.extent ="MAXOF"
newExtent = df.extent
newExtent.XMin, newExtent.YMin = 210000,360000
newExtent.XMax, newExtent.YMax = 550000,400000
df.extent = newExtent
What coordinate system is your Data Frame set to? Also, are you executing this code in the Python window within ArcMap?
The imagery are set to NAD 1983 UTM Zone 13 N and the code I wrote are done in Pyscripter
Since you are running the code in PyScripter, the extent will not update. You can run the code within ArcMap using the Python window. Ex:
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] arcpy.env.extent ="MAXOF" newExtent = df.extent newExtent.XMin, newExtent.YMin = 210000,360000 newExtent.XMax, newExtent.YMax = 550000,400000 df.extent = newExtent del mxd
You can update the extent in PyScripter, but you will need to save the MXD. Once you re-open the MXD, the map will be at the new extent. Ex:
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\data\vector\world\Countries.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] arcpy.env.extent ="MAXOF" newExtent = df.extent newExtent.XMin, newExtent.YMin = 210000,360000 newExtent.XMax, newExtent.YMax = 550000,400000 df.extent = newExtent mxd.save() del mxd