Python arcpy.ListFeatureClasses() Examples
The following are 5
code examples of arcpy.ListFeatureClasses().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
arcpy
, or try the search function
.
Example #1
Source File: s57_2_chart.py From maritime-charting-sample-scripts with Apache License 2.0 | 5 votes |
def getFC(ws, fc_name, fds=""): fc_list = arcpy.ListFeatureClasses("*" + fc_name, feature_dataset=fds) if not fc_list: fc = "" arcpy.AddWarning(fc_name + " not found in " + ws + ".") else: fc = os.path.join(ws, fds, fc_list[0]) return fc
Example #2
Source File: SSURGO_CheckgSSURGO2.py From geo-pit with GNU General Public License v2.0 | 5 votes |
def GetFieldInfo(gdb): # Not being used any more. # # Assumption is that this is all dictated by the XML Workspace document so schema problems # should not occur as long as the standard tools were used to create all databases. # # Create standard schema description for each geodatabase and use it in comparison # to the rest of the tables try: env.workspace = gdb tblList = arcpy.ListTables() tblList.extend(arcpy.ListFeatureClasses()) tblList.extend(arcpy.ListRasters()) dSchema = dict() arcpy.SetProgressorLabel("Reading geodatabase schema...") arcpy.SetProgressor("step", "Reading geodatabase schema...", 0, len(tblList), 1) for tbl in tblList: tblName = tbl.encode('ascii').upper() arcpy.SetProgressorLabel("Reading schema for " + os.path.basename(gdb) + ": " + tblName ) desc = arcpy.Describe(tblName) fields = desc.fields stdSchema = list() for fld in fields: stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper())) #stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper(), fld.aliasName.encode('ascii').upper())) dSchema[tblName] = stdSchema arcpy.SetProgressorPosition() arcpy.ResetProgressor() return dSchema except: errorMsg() return dict() ## ===================================================================================
Example #3
Source File: SSURGO_CheckgSSURGO.py From geo-pit with GNU General Public License v2.0 | 5 votes |
def GetFieldInfo(gdb): # Not being used any more. # # Assumption is that this is all dictated by the XML Workspace document so schema problems # should not occur as long as the standard tools were used to create all databases. # # Create standard schema description for each geodatabase and use it in comparison # to the rest of the tables try: env.workspace = gdb tblList = arcpy.ListTables() tblList.extend(arcpy.ListFeatureClasses()) tblList.extend(arcpy.ListRasters()) dSchema = dict() arcpy.SetProgressorLabel("Reading geodatabase schema...") arcpy.SetProgressor("step", "Reading geodatabase schema...", 0, len(tblList), 1) for tbl in tblList: tblName = tbl.encode('ascii').upper() arcpy.SetProgressorLabel("Reading schema for " + os.path.basename(gdb) + ": " + tblName ) desc = arcpy.Describe(tblName) fields = desc.fields stdSchema = list() for fld in fields: stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper())) #stdSchema.append((fld.baseName.encode('ascii').upper(), fld.length, fld.precision, fld.scale, fld.type.encode('ascii').upper(), fld.aliasName.encode('ascii').upper())) dSchema[tblName] = stdSchema arcpy.SetProgressorPosition() arcpy.ResetProgressor() return dSchema except: errorMsg() return dict() ## ===================================================================================
Example #4
Source File: csvexport.py From utilities-solution-data-automation with Apache License 2.0 | 4 votes |
def WriteCSV(self): # This function writes the CSV. It writes the header then the rows. This script omits the SHAPE fields. try: env.workspace = self._tempWorkspace #fc = arcpy.ListFeatureClasses(self._layers) # for fcs in self._layer: fcs = self._layer if arcpy.Exists(fcs): with open(self._CSVLocation, 'wb') as outFile: print "%s create" % self._CSVLocation linewriter = csv.writer(outFile, delimiter = ',') fcdescribe = arcpy.Describe(fcs) flds = fcdescribe.Fields # skip shape fields and derivatives attrs = ("areaFieldName", "lengthFieldName", "shapeFieldName") resFields = [getattr(fcdescribe, attr) for attr in attrs if hasattr(fcdescribe, attr)] header,fldLst = zip(*((fld.AliasName, fld.name) for fld in flds if fld.name not in resFields)) linewriter.writerow([h.encode('utf8') if isinstance(h, unicode) else h for h in header]) linewriter.writerows([[r.encode('utf8') if isinstance(r, unicode) else r for r in row] for row in arcpy.da.SearchCursor(fcs, fldLst)]) print "CSV file complete" return True except arcpy.ExecuteError: line, filename, synerror = trace() raise ReportToolsError({ "function": "create_report_layers_using_config", "line": line, "filename": filename, "synerror": synerror, "arcpyError": arcpy.GetMessages(2), } ) except: line, filename, synerror = trace() raise ReportToolsError({ "function": "create_report_layers_using_config", "line": line, "filename": filename, "synerror": synerror, } )
Example #5
Source File: _geodatabase.py From registrant with MIT License | 4 votes |
def get_feature_classes(self): """Get geodatabase feature classes as ordered dicts.""" fcs = [] if self.arcpy_found: arcpy.env.workspace = self.path # iterate feature classes within feature datasets fds = [fd for fd in arcpy.ListDatasets(feature_type='feature')] if fds: for fd in fds: arcpy.env.workspace = os.path.join(self.path, fd) for fc in arcpy.ListFeatureClasses(): od = self._get_fc_props(fc) od['Feature dataset'] = fd fcs.append(od) # iterate feature classes in the geodatabase root arcpy.env.workspace = self.path for fc in arcpy.ListFeatureClasses(): od = self._get_fc_props(fc) fcs.append(od) else: ds = ogr.Open(self.path, 0) fcs_names = [ ds.GetLayerByIndex(i).GetName() for i in range(0, ds.GetLayerCount()) if ds.GetLayerByIndex(i).GetGeometryColumn() ] for fc_name in fcs_names: try: fc_instance = FeatureClassOgr(self, fc_name) od = OrderedDict() for k, v in GDB_FC_PROPS.items(): od[v] = getattr(fc_instance, k, '') # custom props od['Row count'] = fc_instance.get_row_count() fcs.append(od) except Exception as e: print(e) return fcs # ----------------------------------------------------------------------