Database MetadataΒΆ

Frequently, derived data products may have additional metadata stored in a database. This module supports access to data in a way that is synonymous with the other data containers. The DatabaseMetadata object is currently implemented to just get an objects geometry. In the future this functionality will be expanded.

Here is an example usage:

 1sql = f"""
 2WITH cte_geoms AS
 3    (
 4    SELECT id, geom FROM kaguyatc
 5    WHERE
 6        kaguyatc.name LIKE ANY (array ['{image_a}%%', '{image_b}%%'])
 7    )
 8SELECT ST_AsText(ST_Extent(ST_Intersection(A.geom, B.geom))) FROM cte_geoms as A, cte_geoms as B
 9WHERE A.id > B.id AND A.id != B.id
10"""
11db = DbMetadata(database, 'postgresql://uname:password@host:port', sql=sql)

Lines 1-10 define an SQL query that will look for two images in a table named kaguyatc and return the well-known-text representation of the intersection geometry. In line 11, the DatabaseMetadata object is created. When one accesses a geometry on the object (for example via UnifiedMetadata.geometry), the database query is executed and - in the case of this example - the GeoJSON representation of the footprint is returned.

Note

In future iterations of the library we plan to extend support for arbitrary attribute lookups via SQL.