I'm very new to GIS but have been asked to parse through any given ESRI GDB file-folder without using any ESRI product. I've been trying to focus on using Fiona and Shapely as these seem to be mentioned the most as alternatives.
I am trying to determine if one particular feature in one layer of the GDB is WITHIN another feature of another layer of the SAME GDB.
As it stands right now the below sample code takes over 5.5 hours to parse through an 80MB GDB file-folder. I was told by the GDB owner it takes ~ 5 minutes via arcpy.
Is there anything that looks obvious to a GIS veteran that I should / should not be doing that is causing execution to be unnecessarily longer?
I tried using the next() command to try and get the next layer of the GDB as I traversed the GDB, but this would crash my script. Using Fiona's listlayers worked around this problem.
with fiona.drivers(): #The GDB full path is: sourceDatabaseFile numBLDGinPerennialWaters = 0 for i, featureName in enumerate(fiona.listlayers(sourceDatabaseFile)): for j, bldgName in enumerate(fiona.listlayers(sourceDatabaseFile)): with fiona.open(sourceDatabaseFile, 'r', layer=i) as gdb: with fiona.open(sourceDatabaseFile, 'r', layer=j) as gdbStructures: for feature in gdb: if ((featureName == "HydrographySrf") and ('ZI024_HYP' in feature['properties']) and (feature['properties']['ZI024_HYP'] > 0)): for buildings in gdbStructures: if (bldgName == "StructureSrf"): if (('WID' in buildings['properties']) and (buildings['properties']['WID'] > 0)): if shape(buildings['geometry']).within(shape(featureName['geometry'])): numBLDGinPerennialWaters = numBLDGinPerennialWaters + 1 print "Finished parsing GDB file."