So I have a python script that sets a dataframe extent to the extent of a particular layer and currently the user would then set the scale to something neater (i.e. 1:4,387 would become 1:5,000). I have seen ways to round up to a set increment (i.e. every 1000) but I am more interested in getting it to round up to the next interval in a list of intervals (i.e. 5000, 7500, 10000, 12500, 20000, 25000, 30000, 40000...). Can anyone recommend a way to do this?
# input parameters;
Plantation = arcpy.GetParameter(0)
mxd = mapping.MapDocument("CURRENT")
layers = mapping.ListLayers(mxd)
dflist = arcpy.mapping.ListDataFrames(mxd, "")
new_exp = "PLANTATION = '" + Plantation + "'"
for lyr in layers:
if lyr.name == "Mapping Patch":
lyr.definitionQuery = new_exp
arcpy.AddMessage(lyr.name + " definition query updated")
ext = lyr.getExtent() #gets the new extent of the Fertilser Plan
dflist.extent = ext #applies the Fertiliser Plan extent to the dataframe