Arcpy return feature class. Inserting polygon object into feature class using ArcPy.


Arcpy return feature class My script current adds EXTABLE, geocodes EXTABLE and saves a new feature class to a file geodatabase. format(fc) which will add your feature class name from fc in front of the _buffer text e. From a third party service I get geojson in my server-side process which I can transform into esri json or Features / FeatureLayer. but fails otherwise. The Table and Dataset property groups are also supported. Feature Compare can report differences with geometry, tabular values, spatial reference, and field definitions. listlayers() is used within in a list comprehension to iterate through all the featureclasses in each geodatabase with the "AOI" condition. MVP Alum ‎02-22-2017 10:14 AM. import arcpy feature_class = r'C:\test. Also see Inventorying data. FeraureClasseName. Users create, import, export, analyze, edit, and visualize features, i. In the arcpy. Not sure if this is as easy as you like, but you can use these three lines of code in the python window (drag or write feature class name for fc variable). Arcpy options to copy feature class to new feature class (fastest runtime) I am trying to build a script that will iterate through each feature class while capturing the last record per the required query. But I can't find a function that checks if any features are selected. name for Fld in arcpy. Geo-processing tools can honour 1 or more environment settings (which you find out by looking at the help for the tool) and one such setting is workspace. da methods for converting numpy arrays into feature classes such as NumPyArrayToFeatureClass which will convert a NumPy structured array to a point feature class. You want to try something like this # Use the ListFeatureClasses function to return a list of # shapefiles. Hot Network Questions "A speedy car" — Is this phrase natural When I run the python script it does not include this feature class in the list. Add and remove fields from the fields list, reorder the fields list, and rename fields. The load method will only Here's something I quickly put together: import os, sys, arcpy InFC = sys. ValidateTableName(s) Share. It's not the same situation as described in 'possible duplicate' question (and few others that I've checked before with almost the same title). env. This is inconvenient because I have to set env. If it's possible each fc would be named after the CSV file used. Create lists of data; Using fields and indexes; Field; Summary. I'm starting off by simply attempting to add a Feature class (as a key) and its respective feature types(as values) but I'm not sure how to build that out. This is not my data, so I cannot change the name of the feature class in production. Exists(ws) returns True in both cases. Vince. overwriteOutp arcpy. Take the following example: >>> for i, sample in enumerate(['a',1,None, '', ' ', 0]): if not sample: print 'value "{}" at index {} is empty'. ListDatasets() Returns a list of feature classes arcpy. AddLayer() arcpy. fcList = arcpy. Currently you have your template in the geometry_type parameter space. 0, 40. Reply. ). SearchCursor? with arcpy. 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. field2 Share. ListFeatureClasses() provides a list of all the feature classes in the current workspace (which you can get or set using arcpy. Is this possible? I can't seem to figure it out using row. You can think of a SearchCursor as an iterator as used in a for or while Using fields and indexes. workspace). All Communities. ListDataFrames() arcpy. I have another nearly identical gdb that does not have this This function test if a feature class exists or not and returns True or False. The following script returns False in FME even if the feature class do exists. I'm trying to convert a rest service to a feature class but Python is getting hung up in the middle of the process. I got a similar answer in post you linked to; using "datatype = 'Feature Class'" instead of "datatype = 'Feature Set'" does fix my problem. Unlike the other answer, this won't copy a bunch of unnecessary records only to delete them right away. A list (or tuple) of field names. But if some features are selected, I am getting the maximum of a field from within these selected features. Part 1 – Gives examples of quick and dirty ways of using the Calculate Value tool to create branches using if statements in a model. The Describe function returns the following properties for feature classes. The Describe function returns the following properties for geodatabase feature classes. For example, in_fl = arcpy. My script returns the list of polygon IDs that intersect each 10km grid square. Table Properties and Dataset Properties are also supported. The returned list can be limited with search criteria for name and From SDK help: Note that only the top-level datasets in the workspace are returned by these methods. Improve this answer. All other feature types—polygon, polyline, and multipoint—return an array of point objects, or if the feature has multiple parts, an array There is a closed question which is similar to or identical to this question: Getting date modified for a feature class within a file geodatabase via arcpy Looking at a file geodatabase featureclass in ArcCatalog, there is a Modified attribute showing the date that the featureclass was last changed:. SHAPE@ —A geometry object for the feature. Fetch and store information about the fields of the two different feature classes. I am unable to identify any tools or arcpy workflows that allow me to change an existing empty feature class type. import arcpy walk = arcpy. Would it best to use count or arcpy. 20. """ # Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. Follow edited Nov 1, 2017 at 22: In short, the validation returns a list of fields in the feature class then returns a list of unique attribute values within the field. I also need an exact copy of this in a line and polygon feature class type (in the same file geodatabase). The second code sample in the ArcGIS Help 10. In this model, the Get Count tool counts the number of records returned by the Select tool. fields # Add the new field to the list fieldList. :param str arcSDEConnectionFileName: The name of an . ListFeatureClasses() for file Returns a Result object, whose first output is the count. If I copy this entire gdb to my local machine, da. env. workspace = path_ datasetList = arcpy. You would think that this would be a property of arcpy. extent = arcpy. shapeType print geometryType which returns this result: Polygon Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site print("Exporting feature class to CCTV geodatabase") arcpy. Describe desc = arcpy. OIDFieldName # find out what the OID field is called AllFields = [Fld. In ModelBuilder, this tool can be used to set up a precondition, as illustrated below. e. However, I would like to get maximum of a field from the whole table i. I am using an example with 1 million randomly generated points inside of a filegeodatabase. ; Loading a new feature class into a FeatureSet object will not overwrite the original feature class. 1 # Target geodatabase is a 10. List feature class returns nothing. The Describe function returns the following properties for Feature Classes. This code return "IOError: Roads if not arcpy. python. 0 I have a script that copies feature classes and tables from one workspace to another on a schedule. Another alternative is to create a feature layer containing only the fields you want, then use arcpy. FeatureClassToFeatureClass_conversion() to copy the result to a new feature class. My overall goal is to create a python function to display x,y coordinates directly from the Shape geometry, as shown in this answer. Hot Network Questions 1950 As you said you could either do something with Describe or with ListFeatureclasses. Describe(InFC) # describe the feature class properties OidName = Desc. gdb' # Your second geodatabase for fc in fcList: secondFC = os. ListDatasets(feature_type='feature') datasets = [''] + datasets if datasets is not None else I am trying to determine the closest line feature to features in a point feature class by using the arcpy. Editor Tracking Properties are supported if editor tracking has been enabled for this feature class. CopyFeatures_management() or arcpy. Describe option to check if the referenced path is a table or not, based on the fact that every feature class has an attribute featureType, whereas tables don't:. ListFiles() Returns a list of Discussion. “name”, “*_name”, etc. 0, 38. Multiple sort fields may be specified. Creating a layer from a selection, when I try to symbolize or label the layer, it brings back all the non-selected features. Set the wildcard parameter to the name of the field you are searching for (e. 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. I have tried a bunch of different things to no avail. I have a model which creates feature classes based on the value in an attribute (using Iterate Feature Selection). Exists("MyFeatureClass") # returns true arcpy. Here is some code to get us started: import time import arcpy arcpy. wmx Returns a list of datasets arcpy. , returns None. (The default value is I am using arcpy and I want to extract a specific feature class called "building" nested in a number of geodatabase within my workspace. , from both selected and un-selected features. Tables represent entity classes with uniform properties. *UPD. mp in Pro; In Pro you loop through maps instead of data frames, though you were ignoring data frames in your orig code and just using the active one by default. If the feature class name already exists in the geodatabase, the name will be automatically incremented. Follow edited Jan 6, 2019 at 18:31. Use the Field Map parameter to manage the fields and their content in the output dataset. Summary; Syntax; Code sample; Related topics. The name of the output feature class or geodatabase. Click Geoprocessing and select Python to open the Python console. I need to set permissions on the recreated feature class that match the permissions before it was removed. 4k 16 16 Why does a return trip to another star require 10x the fuel compared to a one-way trip? I would rather not have to create a cursor and read the actual feature geometries (it should not be necessary, since the entire FC must have the same geometry). GetCount_management("roads") My understanding is this provides the number of records in the table for just the "roads" feature class. – DWynne A couple of minor changes and your code runs: arcpy. It doesn't require any arguments unless you want to filter the results with a wildcard, a feature type, or a particular geodatabase feature dataset. ListFields(fc) fields_info = {field. count = int (arcpy. import arcpy dir = r'D:\output' arcpy. It would be helpful to stored all of the metadata information in the excel table as a dictionary list or other data structure of your choosing (I work with csvs and try to stay away from excel spreadsheets for experience reasons). When iterating through the cursor, each iteration is taking 2 seconds. I have some modified code that lists all feature classes, with or without feature datasets. gdb file extension. This tool creates only simple feature classes such as point, multipoint, polygon, and polyline. I can merge feature classes within a file geodatabase without having issues by creating a list of the feature classes and using Merge_management. " I have a feature class with x/y values populated on the native projection of the feature class (state plane). which would prevent inadvertently calling a tool on an entire feature class when in fact it was zero features that happened to fulfill your selection Check out this short blog posting which they use the following function:. In this type of situation, i. SearchCursor(feature_class,'SHAPE@') as cursor: for row in cursor: #do something with row[0] I want to check if any features in a feature class are selected, and exit the script with a message to the user if they aren't. 1) and copies them. type for field in fields} return fields_info. For example if I have: abc. arcpy; feature-class; Share. getOutput (0) For whatever reason the return value is a string, so if you want a number just use int. SelectByLocation_managment(). describe(FC Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. workspace = "C:\CountTest. Here is my code so far: source_fields = ['contition_field', 'SHAPE@'] icursor = ar I would like to count the number of feature classes in a geodatabase. 3. Its properties are dynamic, # Describe a feature class using arcpy. MakeFeatureLayer_management (fc, a) ‍ ‍ Make feature layer does not create a temporary feature class. Then perform a field calculation on the layer. 6. gdb\Feature_Dataset\Feature_Class'. workspace = "d: Note that it returns a result, not a number. Arc 10. I have a file geodatabase on a remote desktop with the following layer: r'C:\Folder\Database. gdb" env. Extent(-107. # Written with ArcPy for Desktop 10. An export to shap The geometry type to convert from GeoJSON to features. My problem is that when I try to copy a feature class that has a relationship class with a table, the copy fails - because the table that is associated wi An ArcPy function that lists fields. for fc in I want to get the OBJECTID name of a feature class. The Editor Tracking property group is supported if editor tracking has been enabled for this feature class. MakeFeatureLayer_management(fc, "fc_lyr", "PERSON = '" + editor + "'") Reply. As far as the attributes go, I've seen both conditions in the same field. workspace = gdb #--change working directory to each GDB in list I'm trying to get a list of feature classes in a folder and it's subfolders. permissionDict = {'VIEW': viewSet, 'EDIT': editSet} return permissionDict sdePath = r"PathToConnectionFile. 6 geodatabase affectionately called Knight, (which may or may not be related via a relationship class in ArcGIS). Has anyone encountered this issue with arcpy. sfa Territory Design arcpy. for row in arcpy. I've written a function called make_skinny() (with two wrappers, make_skinny_feature_layer() and make_skinny_table_view()) that takes a list of the The SearchCursor will return geometries with the SHAPE@ token which can be used as extracting features etc. In this tutorial, we willl be using arcpy’s SearchCursor class for returning records from a feature class. The code below gives a count of selected features, if any are, but it also returns a count of all features (~27k+) if none are. ListFeatureClasses('','',fds): yield os. ListFeatureClasses() print fcList. But this code will fail if the user changes the layer name, so I want to make the code more robust I'm using ArcPy and would like to copy features in a feature class to geometry objects and then perform a buffer on the geometry objects and copy them back to a feature class. This runs import arcpy, os def GetFDS(FC): """ Returns the feature dataset for a feature class or feature layer FC. There is an Esri blog post that describes the technique for doing this in detail called If you are stuck at "if" – Part 1:. Describe(inFC) # If the shapeType is Polygon convert the data to polylines using the # FeatureToLine tool, otherwise You can list all feature classes and tables with a specific field name using the arcpy. 0 Kudos Coverages, shapefiles, and other nongeodatabase file-based data sources do not support subqueries. Tags (2) Tags: gis_developers. If the in_table contains polygon, polyline, or multipart features, SHAPE@M and SHAPE@Z will return a nan. Community. Below is a script that gets just the folder specified. MakeFeatureLayer_management("MyFeatureClass", "MyFeatureLayer") arcpy. You also need to define the crs arcpy. da. Walk. This tool returns messages showing the comparison result. workspace = "Z:/temp" #returns @string list of GDB folders workspaces = arcpy. join(gdb2, fc) if arcpy. SearchCursor) you need to pass in a list of field names as the second parameter in the cursor constructor. I'm applying the update to a Feature Layer and Table, which participate in a One to Many Relationship. For example, all points in the feature class crothr_pt would have 'Other' written in the NRHP_Type field. The code below is adapted from the second code example: import arcpy import os gdb = # arcpy. NumPyArrayToFeatureClass(array, output_fc, ("X_coords", "Y_coords"), "SpatialReference object") which you can call from the outlput fgb location or Each of these feature classes is. Solved! Go to Solution. 10-27-2017 12:45 PM. If an index is not specified, an array containing an array of point objects for each geometry part is returned. 0 As long as your source and target FC's have the same number of fields and have the same geometry type, this should work: # Get field objects from source FC # dsc = arcpy. fiona. MyFeatureclass' I would like to get the full path of • Returns a tuple of three: path, path names, and filenames Can convert tables and feature classes into numpy arrays for further analysis ArcPy: Working with Feature Data, 2020 Esri Developer Summit -- Presentation, Created Date: 4/6/2020 1:15:08 PM I am new to python and I would to like to count the number of features in each feature class that meet certain criteria. Thus to get your count: count = arcpy. append(newField) # Create a new child based on the input feature class, but with the # additional field added Since you are working with numpy arrays, it might also be worth to check arcpy. env Just use the CreateFeatureClass tool, passing the original feature class as the template argument. Lists the fields in a feature class, shapefile, or table in a specified dataset. Same general idea though, if there are feature datasets, you need to set your working directory to that dataset before listing the features within. py", line 25, in <module> Only those features that are within or intersect the Extent environment setting will be counted. This is what I have so Try to add the path to the name of each dataset when you establish the env. Because the position, eg index of your gdb name portion of your split path, remains I would like to get the maximum of a field in a feature class. import arcpy. *** Note: It should report 0 for any feature classes that process through the I know this thread is pretty old, but I'm having an issue with being able to delete a FGDB within arcpy. Back to Top. I have tryed the same script in a python shell using the same python interpretor, and it returns True. The following is my code: The Describe function returns the following properties for feature classes. ListWorkspaces('*', "FileGDB") for item in workspaces: print item env. Describe(in_fl) arcpy. Describe(fc) print fcpath. In addition to working with “entities with location” as features, the GIS can also work This code should return what is being asked. Grab the shape type from the Describe object of the input feature class. ListDatasets('','feature') + ['']: for fc in arcpy. shp' or one of the others you included, it will run CopyFeatures_management for all 15 feature classes. The problem is, I don't know how to access the FGDB Feature Classes in order to pass them to this function. ListTables() functions with the optional wildcard parameter. path + "\\" + fc This will return the path including the feature class name. The returned list can be limited with search criteria for name and field type and will contain field objects. In a sentence, how do you test in Arcpy whether a feature class has any selected records or not? More info below to explain: I am doing a batch process in which a sampling layer (10km grids) is used to select polygon records (of which there are about 100,000 in total). code to pass the feature class to python toolbox I think the problem here is that you are treating the SearchCursor() like a geo-processing tool. Delete_management("MyFeatureLayer") # returns true arcpy. Copy/Paste Layer with Attribute table to new Layer using ArcGIS Pro? 0. desc = arcpy. mdb', '. ListFeatureClasses("RT*", "Polyline", "") for feature classes starting with RT, otherwise it will return None unless there is a feature class called RT, the wildcard is important. MyDataset\MyData. Any feature class that is not m-aware or z-aware will not support SHAPE@M and SHAPE@Z tokens. FeatureClassToFeatureClass_conversion(inFeatures, outputDatabaseLocation, outputFeatureClass, expression) I get the following error, Traceback (most recent call last): File "B:\Scripts\Python\ArcSDE Maintenance\CCTV Feature Class. “entities in space” as feature layers. SearchCursor Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. ListFeatureClasses() and arcpy. that will be used in a query. A Feature Class returns a dataType of "FeatureClass". """ # get the path to the feature class fcPath = arcpy. The tool t You want to use the walk method on top of using the os. a lock can be applied), an if not needs to be used to find where it returns False (it is locked). I'm writing a script which takes a user input from the geoprocessing widget (a polygon that the user draws), and queries the intersecting layers using arcpy. dirname(input_table) if [any(ext) for ext in ('. append(os. Subqueries that are performed on versioned enterprise feature classes and tables will not return features that are stored in the delta tables. Use the Walk function to catalog polygon feature classes. workspace = "C:/data/data. I have tried get count management, but that returns the number of rows in each feature class in the GDB. This method doesn't return a value. workspace = gdb datasets = arcpy. Use arcpy to check whether feature class geometry has ZM. Returns a list of fields in a feature class, shapefile, or table in a specified dataset. I'd like to return testdataset. . workspace to a gdb before calling ''' for fds in arcpy. Using the FeatureSet object as input to a tool or function that modifies the input, such as Calculate Field or UpdateCursor, will modify the original feature class. If the GeoJSON file does not contain any of the selected geometry type, the output feature class will be empty. import arcpy #Set the input workspace arcpy. 0. split in combination with the python os module value of os. I also want the Solved: I would like to get a list of feature classes in multiple GDBs. This option is only used when the input is a GeoJSON file. 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. Describe(warehouse + meters) if hasattr(d, 'featureType'): # feature class your_export_function(warehouse + meters) else: # The arcpy. Input: import arcpy import urllib import json # Setup arcpy. Keep the following in mind when using the Feature Set object:. UPDATE: At 10. Try either of the following: outPath = wp NewLyr = "Soils_New" templateFC = "Soil" out_fc = arcpy. here's what I am trying to do by I would also like to identify whether the dataset that is being printed is a feature class or feature dataset. For a geodatabase feature class, the Describe dataType property returns a value of "FeatureClass". To report all differences, check on the Continue Comparison parameter. def validate(s): import arcpy return arcpy. getOutput (0)) This tool takes a table, feature class, feature layer, or raster dataset as its first argument and a list of attribute names to be deleted as its second argument. The Feature Class Location parameter value (geodatabase or folder) must already exist. Hi, I actually want to create a Geoprocessing Service published from a Python Toolbox and ArcGIS Pro 2. In this example, glob is used to list all of the geodatabases in a directory dir. When described, feature classes and tables have a fields property that returns a list of Field objects and an indexes property that returns a list of Index objects. Describe does not return the workspace property as it does on the remote desktop. fields # List all field names Rather than using string indexing as suggested by @Bryce Frank, I would suggest using a potentially more stable approach and using the native python string function of . Inserting polygon object into feature class using ArcPy. import arcpy desc = arcpy. splitext to remove the . If the feature class is not within a feature dataset, returns None. :param input_table: path to the input table or feature class ''' workspace = os. mapping. However, for faster performance and reliable field order, it is recommended that the list of fields be narrowed to only those that are actually needed. sde') if ext in How do you check if a feature class is empty and if it's empty append features to that feature class, if it's not not empty it would just pass or ignore the append. CreateFeatureclass(outPath, NewLyr, "", templateFC) Thank you fot you answer, i actually forgot to mention that it's an enterprise database, so all the feature classes are prefixed by the name of the database and also the name of the schema; giving something like this : databasename. If so, it will also determine how many features are within that extent. Diskussion The workspace environment must be set before using several of the list functions, including ListDatasets , ListFeatureClasses , ListFiles , ListRasters , ListTables , and ListWorkspaces . workspace = "C:/Data" # Use the ListFeatureClasses function to return a list fcList = arcpy. Exists(secondFC): print "{} exists, not I'm attempting to create a python script that iterates through a file geodatabase with feature classes and feature classes within feature datasets to calculate the field 'NRHP_Type' with the name of the feature class. The following function (recursive_list_fcs) will return a list of all feature classes that fall under the input workspace, including those not seen by the file system such as in a file geodatabase. Finally, remove the join so the rest of the features are available. da cursors. arcpy. Properties returned by describing a feature class data element. AddMessage(desc. Buffer_analysis() set your output to be '{}_buffer'. :. – I need to return the first record of a feature class as a list. workspace value: import csv, arcpy, os from arcpy import env path_ = r"I:\J_Prashant's External HD\High Speed Rail\Task from Greg Campbell\Layers\HST_BP_GIS_Data. I want to join serval CSV files to a feature class, I would like to create one new feature class for each CSV files. For a feature class, the Describe dataType property returns a value of "FeatureClass". td Topographic Production arcpy. I know I can return the data source and extract the dataset name, but I figure there's got to be a way to directly return only the dataset name. CreateFeatureclass(outPath, NewLyr, template = templateFC) #OR out_fc = arcpy. When using the new cursors in the data access module (i. join(dirpath, filename)) for fc in fcs: #Get feature import arcpy arcpy. Describe returns the dataset property isVersioned as boolean - the described dataset could be either fully versioned or move-to-base and there is no way to determine which, other than to open the property sheet of Generally, I stick with the arcpy functions and classes as much as possible and use the geoprocessing tools only when necessary or beneficial. ListFeatureClasses() gdb2 = r'C:\GIS_Data\MXDs\ServerMxdsR\working\gis_dev02. If you really want a temporary feature class, you should use Copy Features, Feature Class to Feature Class, or one of the other several tools for copying feature classes data. workspace = item #returns @string list of feature classes fcs = arcpy. What exactly do you mean by "Release all references to feature classes, workspaces, cursors, etc. #Create temp fc copy b = arcpy. For a feature class, the Describe Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. Usage. gdb', '. The workspace environment must be set before using several of the I am trying to return a feature class (my sample data is a polygon fc) from a Python toolbox and cannot find any information about what I have to set to get it to work. split method if you want to utilize a list of feature classes using python. The ID field is not created when you provide a Template Dataset parameter value. ListFields(InFC)] # get a list of field names FieldRange = range(len(AllFields)) # make a EDIT: To clarify some confusion. ListFeatureClasses() Returns a list of files arcpy. A shapefile created by this tool has an integer field named ID. I know you can use "OID@" in a cursor to get the field, but can you get the name from that as well, using other than Describe? I'm writing a script, and need to take into account varying OBJECTID names, like OBJECTID_2, OBJECTID_12, FID, etc. name: field. ListFeatureClasses()? If you navigate to the feature class in question in the catalog window of ArcMap or in ArcCatalog, the "Location:" field should contain the valid full path for the feature class that you can copy and paste into your script. Delete_management(myFC) Because it returns True if the feature class isn't locked (i. It is a backup script. This will return a list of feature classes or tables that have at least one field with a I would like to get the data source of the input feature layers, but I am unable to find a way. Use an asterisk (*) instead of a list of fields to access all fields from the input table (BLOB fields are excluded). I am writing an arcpy script where an SDE feature class is removed then recreated. def get_geodatabase_path(input_table): '''Return the Geodatabase path from the input table or feature class. TestSchemaLock(myFC): print "Can't proceed - feature class is locked" else: arcpy. ListDatasets('*','Feature') for dataset in datasetList: arcpy. Is there a simple way to do so, preferably in Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. catalogPath) prints out the following: u'\\MyData. The trouble comes when I need to do the same for feature classes contained in feature datasets. One possibility is to Arcpy’s Data Access module provides the SearchCursor class, from which cursor objects can be created to return records from a feature class or table. UpdateCursor. But from there, how do I provide these features as output o The dataset requested is holding almost 200 feature classes, all of them loaded with polygons. format(sample, i) value "None" at index 2 is empty value "" at index 3 is empty value "0" Returns a list of fields in a feature class, shapefile, or table in a specified dataset. Describe(sourceFC) fields = dsc. sde" layerToQuery = 'MyFeatureClass' print I'm looking into generating Feature Templates with a specific field value for users/editors to access when generating features in feature classes of a geodatabase. Then loop over each feature class and determine if the extent of each feature class overlaps this extent. That new Feature class is called EXAMPLE. SearchCursor("name_of_layer_with_selection"): print row. By default, the feature type name is used. By default, it will stop executing after encountering the first miscompare. In particular, if a workspace contains both stand-alone feature classes and additional feature classes that are part of a feature dataset, then calling the DatasetNames property on the workspace with a dataset type of esriDTFeatureClass will return only the ArcPy Feature Class to Feature Class blank results - ArcGIS Pro. sde The script is going quite slow, and it appears that the Polygon Feature Class is the root cause. Each Python noob here wondering if there's a direct way to return the name of a feature dataset for a feature class. ListLayers() arcpy. The Feature layer is quite large, with 1,219,495 Polygon records. Attached here. I can't find it in any of the applicable Describe objects. ListWorkspaces('*','FileGDB') for gdb in gdbList: arcpy. Some of the classes are in feature datasets as well. The default data type of an output field is the same as the data type Standard Feature Analysis arcpy. The problem (as far as I can understand) is that when the script goes to a empty feature class, the script fails and gives the following error:: Failed to So if ListFeatureClasses returns say 15 feature classes and any of them are 'BedfordCalls. un Workflow Manager arcpy. When i pass a feature class to search cursor it returns all the features in the feature class even when there are selected features in ArcMAP. and i would like to exclude the featureclasses where the FeatureClasseName starts with a certain import arcpy from arcpy import env import os #set path where the shapefiles are located arcpy. SearchCursor(FcLyr, "SHAPE@")as cursor: for row in cursor: arcpy. If you need more info feel free to ask. Regarding your if/else structure, I just wanted to point out that just using if not row. gdb" time. GetCount_management ('ParcelBoundaries_DevTest'). workspace = Does anyone know how to find the path to a feature class within a label expression using ArcGIS? I don’t need to simply display the path. In geodatabase I have many feature classes. csv and zxy. Ex: arcpy. extent = "MAXOF" # Set the extent environment using the Extent class. SHAPE@M and SHAPE@Z tokens will only return values if the in_table contains point features and is m-aware (or z-aware). Describe () for all the FCs in a Geodatabase? And ultimately write them next to the name of each FC in CSV. workspace = dir gdbList = arcpy. Near_analysis function, as such: search_radius = '' #optional location = 'LOCATION' angle = ' This in a Python window within ArcGIS Pro returns the error: Traceback (most recent call last): File "<string>", line 1, in <module> File "c The Describe function returns the following properties for geodatabase feature classes. Man, this can be quite a process! I had to update some metadata information for a project at work the other day, so here goes nothing. Iterating through the table gives the performance I would expect. Describe("D:\\MyData\\Scratch. Query feature class on attribute value, and generate Python list of feature classes. For a single field, you can use a string instead of a list of strings. I'm trying to merge a group of like feature classes which are contained within separate feature datasets. The Feature Class, Geodatabase Table, Editor Tracking Dataset, Table, and Dataset property groups are also supported. schema. gdb\testdataset\featureclass. ListFields. ListDatasets returns an empty list. If you can offer any insight into what the real difference between a 'Feature Set' vs 'Feature Class' is, I'll gladly accept your answer. The resulting object has a count method, but I can't see how to return the field count from this (shouldn't this return an integer?). You can view the returned row count in Geoprocessing history. 0) # Set the extent environment using a space But this does not seem to work for a feature class in file geodatabase. fc = (Drag feature class here from Table Of Contents) fcpath = arcpy. Improve this question. Walk(workspace, datatype="FeatureClass") for dirpath, dirnames, filenames in walk: for filename in filenames: fcs. fields_info1 = get_fields_info(fc1) I want to query a feature class on attribute 'state' == 'new', and if so, add that feature class record to a list (I will process this list later). gdb\polygon' with arcpy. sep and os. Aside from iterating through the fields and incrementing a counter, how can I return the field count? The function arcpy. 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. Exists("MyFeatureClass") # returns FALSE Can anyone think of why the feature class would become inaccessible after Note: The fcList is a list of lists as in the actual script it performs a SQL query to get the list of feature classes, and this is returned as a list of lists. Stand may yield undesired results (remember, explicit is better than implicit from the Zen of Python). 3 # version of the geoprocessing object returns fields in a list, unlike previous # versions, which returned fields in an enumerator. SearchCursor(someFC,someFields,someQuery) print (len(rows)) #I'm sure this used to work with the old cursors, but doesn't work with da. In the same feature class I also have Lat/Long fields that I need to populate (WGS 84 in Calculate geometry in decimal degrees from a point feature class using ArcPy. Try this: import arcpy import os def listFcsInGDB(): ''' set your arcpy. 2 - ListFeatureClasses (arcpy) gets you most of the way there. I see all of them in ArcCatalog, but not in Python! ArcGIS Desktop 10. I'm trying to dissolve and append these to a single dataset. tn Utility Network arcpy. The Describe function returns the following properties for feature classes. The workspace environment must be set before using several of the I'm attempting to create a python script that iterates through a file geodatabase with feature classes and feature classes within feature datasets to calculate the field The Describe function returns the following properties for Feature Classes. It works fine as long the field values don't have spaces, punctuation marks, etc. gdb\\polyzm") geometryType = desc. I want to make a loop on each name, count the number of rows in the attribute table of each feature class and Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site arcpy. field1, row. 0 Kudos by RandyBurton. workspace, fds, fc) #Set workspace environment to geodatabase I have a table in a geodatabase: tableA A column in that table lists a couple of feature classes that are in the geodatabase. Does anyone know of a quick way to return the number of records in a query constrained Search Cursor using the da module? rows = arcpy. gdb" arcpy. ArcPy Feature Class to Feature Class blank results - ArcGIS Pro. Finally, itertools flattens the list so that all of the Any time you have a selection on a layer a cursor object will only return the selected rows. @AntEsk, The 9. 1. 1 service pack 1, this can be more easily achieved using arcpy. The feature layer is the primary concept for working with features in a GIS. # Set the extent environment using a keyword. Any ideas why it fails in FME shutdown python? import arcpy; print arcpy. The following procedure demonstrates how to add a feature to a feature class using Python: Open the map with the features in ArcMap. Describe(fc) 8-) Oddly enough it is displayed as a column available in ArcCatalog so it must be possible to retrieve using ArcObjects Is there a way using arcpy to grab feature classes directly from an SDE and copy to a folder? I have a real chunky way to do it, namely using these functions: arcpy. In the Python console, insert the following script: Import the ArcPy module. I'm attempting to update a numeric field using an arcpy. Arcpy’s Data Access module provides the SearchCursor class, from which cursor objects can be created to return Is there a way to check if a feature class full path string is a path to a feature class within a file geodatabase feature dataset in arcpy? For example: C:\test\test. import arcpy def compare_feature_classes(fc1, fc2): def get_fields_info(fc): fields = arcpy. 1 - arcpy. I have a geodatabase with thousands of grid features. topographic Trace Network arcpy. 0, -104. DBO. In this topic. workspace on each one in order to use Ex. sleep(5) # You can easily access geodatabases and featureclasses with fiona and glob using a couple lines of code. mapping is now arcpy. path. if your feature class is called "Line3" the output buffer feature class would be called "Line3_buffer" I have a script that goes over all the feature classes within a geodatabase (in ArcGIS 9. You can use the Make Feature Layer function to do this on a feature class. FeatureClassToFeatureClass_conversion()‍‍ ‍‍‍‍ The I have an empty point feature class in a file geodatabase. I was using a table. ArcPy Reclass returns empty raster. Editor Tracking Properties are How can I use arcpy. d = arcpy. ArcPy contains a ListFields method, which:. arcpy; arcgis-10. import arcpy import os workspace = "c:/data" feature_classes = [] walk = arcpy. 3; file-geodatabase; Share. g. Describe(inFC) fieldList = desc. da. PointGeometry features return a single Point object instead of an array of point objects. If the input is a simple WFS service, the name will be used to create a feature class in the output location. csv I want to feature class to be named , with each fc corresponding to one of the csv file, abc and zxy. Hot Network Questions Do all International airports need to be certified by Then join the table to the feature class (fc ObjectID to InFID of table), using the KEEP_COMMON keyword for the join type (this is similar to a definition query, in that your feature class will only display matching records). argv[1] Desc = arcpy. It will succinctly traverse all feature classes and tables in a workspace GDB/FS and return all fields associated with a domain, the field name, and the feature class/table it belongs in. , getting the bounding extent of selected features or a subset of features, I find the geoprocessing tools are faster for most of the datasets I interact with regularly. management. I need to be able to set various fields to a specific configuration of values that will change periodically, so I want to script the update in Python. join(arcpy. This requires some more work up-front, but the resulting row objects are Python lists, which makes it easier to read data when iterating through cursor rows. How can i access to feature extent of a feature class and change the extent using arcpy ? Skip to main content. GetParameter(0) desc = arcpy. The table has even more records at 4,735,679 rows. You can test for returning something using if featureclasses: . getValue() as it does not allow me to put a wildcard in there. I'm hoping to return the number of records for each feature class and table in the workspace. This is not the same as the Modified date for its parent file geodatabase (which I'm trying to use ArcPy to copy only the geometry from one feature class to another based on a certain condition. If I change the name of the feature class, the python script adds the feature class name to the list. I can do it with string manipulation arcpy. Discussion The workspace environment must be set before using several of the list functions, including ListDatasets , ListFeatureClasses , ListFiles , ListRasters , ListTables , and ListWorkspaces . 8. Summary. Describe function returns a Describe object, with multiple properties, such as data type, fields, indexes, and many others. If no features are selected, I get the right value. rqztuf tolmanv bova zybixq wkze ktv wluyc prdru bpyhojn jkfkh