confusion with setting extents

المشرف العام

Administrator
طاقم الإدارة
I'm not understanding fully how extent is supposed to work in arcpy/python. I cant seem to get it to work in a function so i can filter it through my FCs. I have read the ESRI help files, but remain confused.

Below is a description of what I am trying to accomplish, followed by the little code i have so far. I think it is an issue with my understanding of how this operation works, but any/all advice is welcome.

A script that will prompt for the name of a File Geodatabase and an XMIN, YMIN, XMAX, YMAX set of coordinates. Then loop over each Featureclass and determine if the extent of each Featureclass overlaps this extent. If so, it will also determine how many features are within that extent.*** Note: It should report 0 for any featureclasses that process through the extent but have no features in the extent. Also, check if any of the following geometry operations exist: within, contains, or overlaps.

import arcpy, os from arcpy import env arcpy.env.overwriteOutput = True #Set user-defined inputs #gdb = raw_input(r"Please insert the full pathname of the Input Geodatabase :") #XMIN = raw_input("XMIN coordinate:") #YMIN = raw_input("YMIN coordinate:") #XMAX = raw_input("XMAX coordinate:") #YMAX = raw_input("YMAX coordinate:") #print gdb,XMIN,YMIN,XMAX,YMAX gdb = r"F:\....\Corvallis.gdb" XMin = 1260000 YMin = 337000 XMax = 1280000 YMax = 360000 # Set extent def Extent(): #XMIN = raw_input("XMIN coordinate:") #YMIN = raw_input("YMIN coordinate:") #XMAX = raw_input("XMAX coordinate:") #YMAX = raw_input("YMAX coordinate:") #print gdb,XMIN,YMIN,XMAX,YMAX XMin = 1260000 YMin = 337000 XMax = 1280000 YMax = 360000 try: arcpy.env.extent = arcpy.Extent(XMIN,YMIN,XMAX,YMAX) extent = arcpy.env.extent return extent except: print ("An Error has occured in Extent().") extent = Extent() print extent #List available Feature Classes in a List def FCs_in_GDB(gdb): try: arcpy.env.workspace = gdb print (arcpy.env.workspace) fcs = [] for fds in arcpy.ListDatasets('','feature') + ['']: for fc in arcpy.ListFeatureClasses('','',fds): fcs.append(os.path.join(fds, fc)) return fcs except: print ("An Error has occured in FCs_in_GDB().") fcs = FCs_in_GDB(gdb) for fc in fcs: print fc

أكثر...
 
أعلى