1

I have inherited a file geodatabase containing a number of feature classes (points, lines and polygons), where many fields are common. For example all feature classes contain the following fields, and the fields should have the same settings:

  1. Asset_ID - should all be long numeric format with alias Asset ID
  2. GIS_ID - should all be Text with length 30 with alias GIS ID
  3. Asset_Class should be Text with length 20, alias Asset Class and Domain cvdAssetClass

I want a way to export to the field properties (Field Name, Alias, Data Type, Allow NULL, Number format, Domain, Default and Length) to a CSV or spreadsheet so I can check that all the layers are correct.

I am using ArcGIS Pro to look at the geodatabase. I have tried the "Table to Excel" command previously and combined the files and identified errors in Field Names, but I cant figure out how to confirm all the the settings are exactly the same.

Typically we export the feature classes for use in non-spatial programs, and it is important that the schemas are perfect to avoid errors when importing to the other software

2 Answers 2

1

If you are familiar with ArcPy/Python you can use ListFields. Create a list of field objects and use their properties/methods. Then create some logic to check all properties you want. Example how to access names, types, alias, etc.:

import arcpy
fc = r'C:\GIS\ArcMap_default_folder\Default.gdb\jl_sample_copy'

fields_to_check = ['KKOD','KATEGORI','Shape_Length']

fields = [f for f in arcpy.ListFields(fc)] #Create a list of field objects
#[<Field object at 0x27379ebc848[0x27303311e30]>, <Field object at 0x27379dd5f48[0x27303311d70]>, <Field object at 0x27379dd5f88[0x27303311e70]>, <Field object at 0x27379de00c8[0x273033113d0]>, <Field object at 0x27379ebe208[0x273033114b0]>, <Field object at 0x27379ebe948[0x27303311630]>]

#Filter
fields = [f for f in fields if f.name in fields_to_check]
#[<Field object at 0x273032bd9c8[0x27303311270]>, <Field object at 0x2730349ffc8[0x27303311310]>, <Field object at 0x27303841948[0x27303311cf0]>]

names = [f.name for f in fields] #They have properties, like name
#['KKOD', 'KATEGORI', 'Shape_Length']

aliases = [f.aliasName for f in fields]
#['KKOD', 'KATEGORI', 'Shape_Length']

lengths = [f.length for f in fields]
#[4, 50, 8]

types = [f.type for f in fields]
#['Integer', 'String', 'Double']

nullable = [f.isNullable for f in fields]
#[True, True, True]

domains = [f.domain for f in fields]
#['', '', ''] #No domains
0

Based on @BERA's answer, I used the following in ArcGIS Pro.

import os
import arcpy
from datetime import datetime
from pathlib import Path
import pandas as pd
from arcpy import env
import csv

#Check current directory
currentdir=os.getcwd()

#Set Save location and filenames for the schema and domain
TimeOfRun=datetime.now().strftime("%Y%m%d_%H%M%S")
fileName=TimeOfRun+'_Schema'
fileNamePath=f'{currentdir}\{fileName}.csv'

#Check Variables
print(currentdir)
print(TimeOfRun)
print(nameFileExcel)
print(fileNamePath)

#Set location of file
arcpy.env.workspace=r'S:\Water and Sewer\Water and Sewer Asset Management Information System\Geodatabase\WS_AMIS.gdb'

#Create blank list
list=[]
    
#Cycle through GDB and put each fields details in list
datasets = arcpy.ListDatasets(feature_type='feature')
i=0
for ds in datasets:
#    print(ds)
    for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
#        print(fc)
        for field in arcpy.ListFields(fc):
            i=i+1
            list.append([i,fc,ds,field.name,field.aliasName,field.length,field.type,field.isNullable,field.domain])

#Create Data frame from list, display it and then save to file
df=pd.DataFrame(list,columns=["Count","Feautre","Dataset","Name","Alias","Length","Type","isNullable","Domain"])
df
df.to_csv(fileNamePath)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.