I have a file geodatabase that contains polygons as feature classes. Here is the description of my dataset. It contains vegetation data for each polygon.
I have found this Python script online that reads the domains from the geodatabase. And this seems to work fine.
from __future__ import print_function
import json
import xml.etree.ElementTree as ET
import ogr
gdb_path = r'S_USA.EVMid_R05_CentralCoast.gdb'
ds = ogr.Open(gdb_path)
res = ds.ExecuteSQL('select * from GDB_Items')
res.CommitTransaction()
for i in range(0, res.GetFeatureCount()):
item = json.loads(
res.GetNextFeature().ExportToJson())['properties']['Definition']
if item:
xml = ET.fromstring(item)
if xml.tag == 'GPCodedValueDomain2':
print(xml.find('DomainName').text)
print(xml.find('Description').text)
print(xml.find('FieldType').text)
for table in xml.iter('CodedValues'):
for child in table:
print(child.find('Code').text, child.find('Name').text)
print()
if xml.tag == 'GPRangeDomain2':
print(xml.find('DomainName').text)
print(xml.find('Description').text)
print(xml.find('FieldType').text)
print(xml.find('MinValue').text)
print(xml.find('MaxValue').text)
But I want to view each separate polygon and its associated attributes (including the boundary of the polygon itself) so that, given a coordinate, I am able to view the bounding polygon and therefore fetch the vegetation data associated with a given coordinate. Apologies if my terminology is wrong, I am new to GIS. But as I understand, I wish to view the feature classes. How can I do this using Python GDAL?