Last active
February 9, 2021 20:16
-
-
Save bixb0012/15f6596f3f02cee36cc8cf205e63c3e6 to your computer and use it in GitHub Desktop.
ArcPy: Describe Geodatabase Contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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