Hi
I have created the following script to select the biggest extent in the mapview using an select by attribute tool which must contain an expression for where clause.
I have also followed other posts like Kirsten 's post who has tried to solve exactly the same problem.
My problem is that the expression doesn't work.
My problem is here
How sould I write my where clause to work?
Thanks
I have created the following script to select the biggest extent in the mapview using an select by attribute tool which must contain an expression for where clause.
I have also followed other posts like Kirsten 's post who has tried to solve exactly the same problem.
My problem is that the expression doesn't work.
Code:
# Import modules
import sys,os,math,string,arcpy
from arcpy import env
# Read from current map
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Data Themes")[0]
lyr = arcpy.mapping.ListLayers(mxd, "CHS_Chart_Extents", df)[0]
#The DataFrame extent object is converted into a polygon feature so it can be used with the SelectLayerByLocation function.
dfAsFeature = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),
df.spatialReference)
# Select the extents into the df map view
arcpy.SelectLayerByLocation_management(lyr, "WITHIN", dfAsFeature, "", "NEW_SELECTION")
# Create the search cursor
#
cur = arcpy.SearchCursor(lyr)
# This list will keep the numbers
featureList = []
#This loop will go through rows to find chart Numbers
for row in cur:
featureList.append(row.CHARTSCALE)
# This is the maximum scale in mapview
MX = max(featureList)
# this message says that the script is OK so far
arcpy.AddMessage(max(featureList))
# Now I need to select only the biggest extent in the mapview with maximum extent
arcpy.SelectLayerByAttribute_management (lyr, "NEW_SELECTION", "CHARTSCALE = '" + MX + "'")
Code:
# This is the maximum scale in mapview
MX = max(featureList)
# Now I need to select only the biggest extent in the mapview with maximum extent
arcpy.SelectLayerByAttribute_management (lyr, "NEW_SELECTION", "CHARTSCALE = '" + MX + "'")
Thanks