Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Move Map in Cardinal Directions

$
0
0
I want to move the map by entering the distance. For example, I want to move the data frame 5 Feet North. I am using an if elif else statment to provide a statement that moves the map. The script returns no errors. I do not want to use df.extent = lyr.getSelectedExtent(), because it zooms to full extent. I want to be able to move the map. Similiar to using a pan, but by entering a specific distance in cardinal directions.

Code:

import arcpy, os, sys

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, df)[0]

North = arcpy.GetParameterAsText(0)
South = arcpy.GetParameterAsText(1)
East = arcpy.GetParameterAsText(2)
West = arcpy.GetParameterAsText(3)

if North > 0:
        whereClause = ''' "North" = '{0}' AND "South" = '{1}' AND "East" = '{2}' AND "West" = '{3}' '''.format(North, South, East, West)
elif South > 0:
        whereClause = ''' "North" = '{0}' AND "South" = '{1}' AND "East" = '{2}' AND "West" = '{3}' '''.format(North, South, East, West)
elif East > 0:
        whereClause = ''' "North" = '{0}' AND "South" = '{1}' AND "East" = '{2}' AND "West" = '{3}' '''.format(North, South, East, West)
elif West > 0:
        whereClause = ''' "North" = '{0}' AND "South" = '{1}' AND "East" = '{2}' AND "West" = '{3}' '''.format(North, South, East, West)
else:
        whereClause = ''' "North" = '{0}' AND "South" = '{1}' AND "East" = '{2}' AND "West" = '{3}' '''.format(North, South, East, West)


Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images