Arcpy list feature classes. The Table and Dataset property groups are also supported.
Arcpy list feature classes Learn how to use the ListFeatureClasses function to return a list of feature classes in the current workspace, limited by name, feature type, and optional feature dataset. Clip_analysis(fc, Buffer, fcOut) fcsOut. workspace = r"X:\311\Obtaining GIS You've listed files and feature classes. It appears this question is about listing all the feature classes in a geodatabase, both stand-alone and those 限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。 import arcpy, os, csv project_folder = r'C:\GIS\ArcGIS_Pro_projects' output_csv_folder = r'C:\GIS\temp' projects = [] for root, folder, files in os. I have another nearly identical gdb that does not have this Can anyone clarify if they have attempted this in ArcGIS Pro as I have over 1000 feature classes that I would like a list of that are being used. A solution is provided using arcpy. shp" #folderToExamine = r"C:\MGIS You can easily access geodatabases and featureclasses with fiona and glob using a couple lines of code. workspace = gdb datasets = arcpy. sde" fcs = [] walk = arcpy. path. ListDatasets You can list all feature classes and tables with a specific field name using the arcpy. conn = r'<path_to_my_sde_connection>' fclist = arcpy. ListTables() If you want to guarantee that you're only grabbing the intended feature classes and that all of them are there, you could do this instead: fcsOut = list() for fc in fcs: fcOut = os. Any help on how to loop through the subfolders is appreciated. join('in_memory', fc) arcpy. ListFeatureClasses() features = {} for fc in fcs: cursor = arcpy. env . ListFeatureClasses()? This can be accomplished using the functions of ArcPy to list and describe datasets. # List People and Feature C I can access the map document through arcpy. 1 SP1 allows you to do this. Just modify the name of the connection file for the SDE user. fcs = arcpy. sde' # second option to access connection file, same I am trying to build a script that will iterate through each feature class while capturing the last record per the required query. The fields function returns a list of all the fields in your feature class. ListFields(FC) #Loop through fields for field in fields: #Check if field has domain This is the order in which they are stored in the database, what you see in ArcCatalog has been sorted alphabetically to assist you in finding the proper feature class. da. In this example, glob is used to list all of the geodatabases in a directory dir. Here's a little piece of code to check for relationship class names greater than length 30: arcpy. geocoding) Image Analysis (arcpy. The following code when run only gives me access to the feature_type="Point" I want to create a Python dictionary with a Feature class as the key and the fields of the feature class and domains of the feature class as separate values. append(fcOut) import arcpy #Set workspace environment to geodatabase arcpy. When I do this, the "catalogPath" returned is not the full path. ListWorkspaces('*','FileGDB') for gdb in gdbList: arcpy. it returns D:\Folders\Database. 説明 The workspace environment must be set before using several of the list functions, including ListDatasets , ListFeatureClasses , ListFiles , ListRasters , ListTables , and ListWorkspaces . Code sample is: ws = r'Database Connections\\Connection to sde-srv. The layer names within the map document have been changed from the original feature class, so listlayers does not give me an accurate description of the actual feature classes in use. env. Here's how to use Walk for your script: workspace = r "Path\xyz. ListFeatureClasses() and arcpy. import os import arcpy # Set the workspace for the ListFeatureClass function arcpy. Summary. Next, you'll list tables and feature datasets. ListDatasets("*", "Feature") for Learn how to use arcpy to list all feature classes, features, tables and fields in geodatabases. . Copy shapefiles to a geodatabase. split method if you want to utilize a list of feature classes using python. workspace. workspace = "c:/base" # Use the ListFeatureClasses function to return a list of Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. The code below is adapted from the second code example: import arcpy import os gdb = # arcpy. join. Hope this List Feature Classes is great but only lists the FCs at the root level of your geodatabase. ListTables() # Iterate through tables in file geodatabase (workspace) for t in tables: # Get relationship class(es) associated with table desc = arcpy. Only use the ListSubtypes function when there is a subtype field set on the table or feature class. import arcpy import os in_workspace = r"C:\your\path" out_workspace = r"C:\your\path2\temp. These functions will be illustrated using tabular data formats, shapefiles, and geodatabase feature classes. The trouble comes when I need to do the same for feature classes contained in feature datasets. workspace = dir gdbList = arcpy. ListFeatureclasses(conn) for fc in fclist: print(fc) This took about 7 minutes for me to list 154 feature I am having a problem with the ListFeatureClasses() function in arcpy. Walk(workspace, datatype="FeatureClass") for dirpath, dirnames, filenames in walk: for filename in filenames: fcs. import os import arcpy # Set the workspace for ListFeatureClasses arcpy. Finally, itertools flattens the list so that all of the Same general idea though, if there are feature datasets, you need to set your working directory to that dataset before listing the features within. env. If I change the name of the feature class, the python script adds the feature class name to the list. An overview of ArcPy classes. ListTables() functions with the optional wildcard parameter. I have a geodatabase with thousands of grid features. import arcpy walk = arcpy. See examples of how to filter, select and iterate through geodatabases using Learn how to use the ListFeatureClasses function to list the feature classes in a workspace, limited by name, feature type, and feature dataset. join(dirpath, filename)) for fc in fcs: #Get feature The Describe function returns the following properties for feature classes. See the syntax, parameters, return value, This scripts specifies multiple wildcards in a list cases []. ListDatasets(feature_type='feature') datasets = [''] + datasets if datasets is not None else Try specifying ("*", "Feature") to list just the Feature Classes. the geodatabase apart from "Building" So I expanded the code a bit and try to loop the merge command through all these feature class: import arcpy import os #----- #example list workspace arcpy. The following script walks through a workspace, create a list of every polyline, and copies the polylines to an output workspace. For a feature class, the Describe dataType property returns a value of "FeatureClass". I'm trying to get a list of feature classes in a folder and it's subfolders. ia) Mapping Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. Walk function from ArcGIS 10. Iterate over the workspaces and list their feature classes for ws is listWS: arcpy. 2 - ListFeatureClasses (arcpy) gets you most of the way there. This is not my data, so I cannot change the name of the feature class in production. ListFeatureClasses()'. ListFeatureClasses() #Loop through feature classes in list for FC in FCs: #List fields in feature class fields = arcpy. SearchCursor(fc I am using arcpy and I want to extract a specific feature class called "building" nested in a number of geodatabase within my workspace. # Get the spatial reference of the Feature Class from folder A # Examine all Feature Classes in folder B and report if their # spatial references match the Feature Class in folder A import arcpy arcpy. fiona. walk(project_folder): #Find all aprx files in projects_folder for file in files: if file. I can merge feature classes within a file geodatabase without having issues by creating a list of the feature classes and using Merge_management. aprx'): projects. Set the wildcard parameter to the name of the field you are searching for (e. Walk and os. I'm trying to dissolve and append these to a single dataset. See examples, parameters, and tips for working with A user asks how to get a list of feature classes in multiple GDBs without setting env. ArcPy DA Walk mimics the behavior of Python's os. The returned list can be limited with search criteria for name and field type and will contain Field objects. mapping and list all of the layers, but I am having a difficult time listing the feature classes that are being used. workspace = 'C:/workspace' # Local variables tables = arcpy. workspace = "c:/base" # Use the ListFeatureClasses function to Listing and finding data sets is best accomplished using Walk - ArcGIS Pro | Documentation. It only contains the path up to the gdb and then appends the feature class name to it (e. This will return a list of feature classes or tables that have at least one field with a You want to use the walk method on top of using the os. append(os. ListWorkspaces() to see how to restrict your list to certain types of workspaces or using a wildcard. gdb\fds" feature_classes = [] for dirpath, dirnames, filenames in Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. da) Geocoding (arcpy. Just seems like I might be able to streamline the code a bitany feedback is welcome. If there is no subtype field set in the input, a dictionary will be returned with a single subtype key of 0 (in addition, the Default key value will be True, the Name key value will be the name of the feature class or table, and the SubtypeField key value will be an empty string). Below is a script that gets just the folder specified. ListDatasets("*","Feature") Here's a script I wrote that lists all of the Feature Datasets (and the Feature Classes contained within them, with their geometry type) in an SDE/Oracle instance. I would also like to identify whether the dataset that is being printed is a feature class or feature dataset. import arcpy dir = r'D:\output' arcpy. gdb\feature_name not D:\Folders\Database. “name”, “*_name”, etc. ArcPy provides a number of classes to better support workflows using Python. workspace = gdb #--change working directory to each GDB in list I am trying to use arcpy to create a feature class with all the information from the list, with the proper field names from the list of field names. MapDocument(mxdPath) for layer in When I run the python script it does not include this feature class in the list. workspace = your_gdb #Get list of feature classes in geodatabase FCs = arcpy. endswith('. Each selected feature class If your fGDB actually does have feature datasets (not just top-level feature classes), you could do: import arcpy import os arcpy. I am wanting access to all the feature classes in my datasets within a geodatabase. charts) Data Access (arcpy. ). workspace = ws listFC = arcpy. Discussion. See syntax, parameter Learn how to use ListFeatureClasses function to return a list of feature classes in a workspace that match a wildcard and a feature type. I haven't had a chance to really test this out yet. Describe(t) rcs = desc The list containing feature class names is returned from the function, limited by the optional wild_card, feature_type, and feature_dataset arguments. The list containing feature class names is returned from the function, limited by the optional wild card, feature type, and feature dataset arguments. The Table and Dataset property groups are also supported. The code that I have now prints each feature class and feature data set; but does not denote whether if the object printed is a feature class or feature data set. listlayers() is used within in a list comprehension to iterate through all the featureclasses in each geodatabase with the "AOI" condition. So I was starting to get back into using arcpy after a non-GIS hiatus and wanted to get a list of feature classes in SDE. mapping. I'm trying to merge a group of like feature classes which are contained within separate feature datasets. overwriteOutput = True #try: #set up the paths #targetFC = r"C:\MGIS\geog485\Lesson2\Lesson2\CountyLines. join(mxdDir, mxd) mxdDoc = arcpy. Diskussion The workspace environment must be set before using several of the list functions, including ListDatasets , ListFeatureClasses , ListFiles , ListRasters , ListTables , and ListWorkspaces . listdir(mxdDir): mxdPath = os. gdb\Dataset\feature_name). As I want the FC to be a point layer, I thought about using add XY event layer, however there seems to be no option for adding a field list and my x,y coordinates are in a tuple instead of The arcpy. Discussion The workspace environment must be set before using several of the list functions, including ListDatasets , ListFeatureClasses , ListFiles , ListRasters , ListTables , and ListWorkspaces . Has anyone encountered this issue with arcpy. Than it loops over unique cases, listing desired feature classes 'arcpy. ListFeatureClasses() for fc in listFC: # do something See the Help page for arcpy. I've tried iterating through the feature classes, but after spinning for a while the script keeps returning AttributeError: 'NoneType' object has no attribute 'group' when I try to list the feature classes. walk, and doesn't rely on setting workspace environments, which is both slow and prone to mistakes. Returns a list of fields in a feature class, shapefile, or table in a specified dataset. tblsInMemory = arcpy. The dataset which this feature was originally in is not returned with the above code. g. Easy enough, you'd think: import arcpy from arcpy import env. See code samples and Learn how to use the ListFeatureClasses function to return a list of feature classes in the current workspace, limited by name, feature type, and optional feature dataset. dsList = arcpy. The Editor Tracking property group is supported if editor tracking has been enabled for this feature class. import arcpy from arcpy import env import os # Set the workspace for the ListFeatureClass function env. When the loop runs, it checks each item from the list of feature classes to determine whether it is a Point feature class, and if it is, it adds one You can list all feature classes and tables with a specific field name using the arcpy. This will return a list of feature classes or tables that have at least one field with a Iterate over the workspaces and list their feature classes for ws is listWS: arcpy. If you wish to display the list of feature classes alphabetically in Python just call the sort method on the list of feature classes datasetList = arcpy. join(root, file)) for proj in projects: #For each project file I'm working with SDE connection and want to find if a layer exists on a server. import arcpy import os mxdDir = r'C:\path\to\directory\of\MXDs' mxdDict = {} for mxd in os. If you have feature datasets containing additional feature classes, they will be missed by list feature classes. da. workspace = "C:/Data" The second code sample in the ArcGIS Help 10. In addition to the classes listed in this topic, additional classes can be found in other ArcPy modules, including the following: Charts (arcpy. zyghe xlk ufz fyn jewcw gsmpae icmxjk cvzaishjd dkge aluf