Skip to main content

I am attempting to find the file sizes for each Feature Class within a FGDB, both within a Feature Dataset and at the root of the FGDB.  All research yields that the file size is not available via the PythonCaller and we are trying to isolate the FC filesize output via:

PythonCaller > getFeatureClassSize

import os
 
def getFeatureClassSize(feature):
    fc_path = feature.getAttribute("FC_path")
    total_size = 0
 
    # Common file extensions in a File Geodatabase
    valid_extensions = {'.gdbtable', '.gdbtablx', '.atx', '.spx', '.freelist', '.gbx', '.cat', '.gdbindexes'}
 
    if os.path.exists(fc_path):
        if os.path.isfile(fc_path):
            ext = os.path.splitext(fc_path)o1].lower()
            if ext in valid_extensions:
                total_size = os.path.getsize(fc_path)
        else:
            for dirpath, dirnames, filenames in os.walk(fc_path):
                for f in filenames:
                    ext = os.path.splitext(f)n1].lower()
                    if ext in valid_extensions:
                        fp = os.path.join(dirpath, f)
                        if os.path.exists(fp):
                            total_size += os.path.getsize(fp)
 
    # Store formatted size in MB
    size_mb = round(total_size / (1024 * 1024), 2)
    feature.setAttribute("FC_Size_MB", size_mb)
 
    return feature

The values for Size yields 0.

Any help or guidance would be greatly appreciated.

 

Are you trying to determine the size of the whole file geodatabase? or just a specific feature type within the file goedtabase?

Are you just trying to caculate all the file sizes for a given rootname? e.g., a0000000a.gdbtable, a0000000a.gdbtablx and a0000000a.spx

I think this should also be able to be done with a Path reader and a statistics calculator grouping by path_rootname. 

 


Thank you for the response - I am attempting to calculate the file size for a specific Feature Class (feature type) within the File Geodatabase.


Thank you for the response - I am attempting to calculate the file size for a specific Feature Class (feature type) within the File Geodatabase.



From a quick look online, It doesn’t seem like this will be possible without building an AddIn for Pro - https://community.esri.com/t5/arcgis-pro-sdk-questions/get-feature-class-raster-file-size-in-file/td-p/1316153

 

What is the purpose/driver for wanting to know the size of each feature class?


Understood.

We are undertaking a multi-TB / multi-network drive / agency-wide GIS data housekeeping effort to migrate data into Enterprise and subsequent network drive cleanup.  We are attempting to collect an as-is state for this effort and feature class size is one of the parameters that would be helpful for our assessment.


For vector data, a feature count per featureclass is probably a sufficient metric on volume, you could combine this with vertex count per feature to give a proxy on size


jkingsbury - thank you


Reply