Saturday, 5 October 2019

Getting vector and raster metadata from PostGIS database?


im using php/postgres/postgis in a webapp, im wondering if its possible to get metadata from the db about all shp/geotiff table like (name, projection, type(ship/tiff), date, desc, owner etc ...) i already using geometry_columns table to get some of this data but is not enough for me.


i use this query :


SELECT f_table_catalog, f_table_schema, f_table_name, f_geometry_column, 
coord_dimension, srid, type

FROM geometry_columns;

Is that data need to be put in the file (shp/tiff) by the file owner (in production time) or is there a table that contain all this stuff ?



Answer



The short answer is at production time.


The loaders that I am aware of (shp2pgsql, for example) will load the projection (prj), geometry and attributes (dbf), but things like data and file owner are not part of the shp spec, directly, so there is no way for a loader to know about them.


For tiffs, if you look at the source code for raster2pgsql, there is no mention of metadata or attributes other than the SRID. This is to be expected, as the tiff format allows for arbitrary attributes (meta data) to be created in the header, so coding a correspondence between unknown header attributes and Postgres would be problematic -- unless you used some key/value store like hstore (as osm does for rarely used tags).


Anyway, I digress. Beyond standard metadata that is required for many spatial functions, such as the SRID, there is no mechanism within either shp or tiff loaders for arbitrary metadata and no hidden system tables containing this information. You would have to add them at load time.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...