HOW TO

Check validity of features for all feature classes in a database

Last Published: April 25, 2020

Summary

GIS administrators sometimes need to perform quality assurance checks for the validity of features.

Instructions provided describe an example of how to use a Python script to do this for all the feature classes in a database.

Procedure



  1. Modify the following parameters according to the appropriate environment for the Python script in Step 2:

    A) Set the workspace equal to the spatial database connection:

    Code:
    arcpy.env.workspace = r"Database Connections\sde_geodatabase.sde"


    B) Give the logName parameter a name:

    Code:
    logName = "FeatureInfo.txt"


    C) Set a file location for the output log file for parameter logWorkspace:

    Code:
    logWorkspace = r"C:\logs"


    D) Set the direct connect string or application service connection port for the instance parameter:

    Code:
    instance = 'sde:oracle10g:ora10gr2'


    E) Set the user:

    Code:
    user = 'sde'


    F) Set the password:

    Code:
    psswd = 'sde'


  2. Code:
    import os, subprocess, arcpy, string, sys, os

    arcpy.env.workspace = r"Database Connections\sde_geodatabase.sde"


    def describeFeatures(sdeWorkspace,logWorkspace, logName,instance,user,psswd):

    logfile = open(os.path.join(logWorkspace, logName), 'w')

    for dataset in arcpy.ListDatasets():

    arcpy.env.workspace = sdeWorkspace + os.sep + dataset

    for fc in arcpy.ListFeatureClasses():

    args = ['sdelayer', '-o', 'feature_info', '-l', str(fc) + ',SHAPE','-i', instance, '-u', user, '-p', psswd]

    p = subprocess.Popen(args, stdout=subprocess.PIPE)
    output = p.stdout.read()
    logfile.write(dataset)
    logfile.write(fc)
    logfile.write(output)
    logfile.write("\n")

    print dataset, fc, output
    logfile.close()

    if __name__=="__main__":

    sdeWorkspace = arcpy.env.workspace
    logName = "FeatureInfo3.txt"
    logWorkspace = r"C:\logs"
    instance = 'sde:oracle10g:ora10gr2'
    user = 'sde'
    psswd = 'sde'
    describeFeatures(sdeWorkspace,logWorkspace, logName,instance,user,psswd)


Article ID:000011657

Software:
  • ArcMap
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic