Skip to content

Instantly share code, notes, and snippets.

@bixb0012
Last active February 9, 2021 20:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bixb0012/15f6596f3f02cee36cc8cf205e63c3e6 to your computer and use it in GitHub Desktop.
Save bixb0012/15f6596f3f02cee36cc8cf205e63c3e6 to your computer and use it in GitHub Desktop.
ArcPy: Describe Geodatabase Contents
#!python
# Reference: 1) https://pro.arcgis.com/en/pro-app/arcpy/data-access/walk.htm
# 2) https://pro.arcgis.com/en/pro-app/arcpy/functions/describe.htm
# 3) https://docs.python.org/3/library/os.path.html
import arcpy
import os
gdb = # Path to geodatabase
# Example 1a: Data Types and Geometry Storage using ArcPy Walk
walk = arcpy.da.Walk(gdb)
for dirpath, dirnames, filenames in walk:
if dirpath != gdb:
filenames.insert(0, "")
for file in filenames:
path = os.path.join(dirpath, file)
desc = arcpy.Describe(path)
print("{},{},{}".format(
path,
desc.datatype,
desc.geometryStorage if hasattr(desc, "geometryStorage") else ""
))
# Example 1b: Data Types and Geometry Storage using ArcPy Describe
full_path = False # Specify whether dataset name should be full or relative
desc = arcpy.Describe(gdb)
for child in desc.children:
datasets = [child] + child.children
for ds in datasets:
print("{},{},{}".format(
ds.catalogPath.replace("" if full_path else gdb + os.path.sep, ""),
ds.datatype,
ds.geometryStorage if hasattr(ds, "geometryStorage") else ""
))
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment