5

I have imported several Shapefiles into PostgreSQL+PostGIS database. However, it seems that the database doesn't support metadata. I can't find a way to visit or edit metadata for the datasets. I don't know how to add attributes for the dataset (like author, time of creation, time of last edit, creator's affiliations, telephone number, etc.).

Is it possible to add or edit these data into PostGIS database?

EDIT: This question should remain open (i.e. no answer should be accepted).
EDIT2: I strongly oppose the opinion that metadata should be handled by the database designer or maintainer. Metadata is not arbitrarily designed. It has standards, which won't change in a specified occasion. Either the GIS platform or the DBMS should help end users implement metadata handling mechanics, including database design following given national or industry standards, reading and writing metadata in a user-friendly interface, and extensibility to customize fields. Even though people are still allowed to design a metadata table all from scratch, they simply tend to use predefined metadata schemas (which will be compatible to national and industry standards, with less or no errors than designing a table from scratch).

4
  • 1
    Is this about ArcGIS metadata? In that case, you should use ArcGIS to update it.
    – Berend
    Commented Jul 10, 2018 at 7:05
  • No. I mean any kind of metadata. Also, the shapefile imported into PostgreSQL can only be updated with ArcGIS Server, which is out of our consideration. Commented Jul 10, 2018 at 9:18
  • 2
    Well, 'Any kind of metadata' could be stored in PostgreSQL, just like any other type of data. Just create a table that stores whatever you want, as @HeikkiVesanto already wrote.
    – Berend
    Commented Jul 10, 2018 at 9:43
  • 1
    Shapefiles can be loaded into PostgreSQL/PostGIS without an enterprise geodatabase since 10.4, so only ArcMap (and a compatible PG server) is necessary.
    – Vince
    Commented Jul 10, 2018 at 11:20

4 Answers 4

7

You can create a table in PostgreSQL to store your metadata. For example call it public.metadata with the columns you need for your metadata schema.

This would be the best way to store metadata in PostgreSQL.

6
  • It should not be the answer. If it must be the answer, PostGIS will be an incomplete software that cannot even fulfill such fundamental function of a GIS database. Commented Jul 10, 2018 at 9:28
  • 6
    I think you are missing the point of PostGIS being an extension of an database management system and not a software like ArcGIS or QGIS
    – blabbath
    Commented Jul 10, 2018 at 9:31
  • 2
    @AurusHuang where did you get the idea that metadata should be a fundamental function of a GIS database? PostGIS is part of a complete database, being PostgreSQL, and as such serves the function of incorporating spatial data and functions. It is up to YOU to decide how you want to store information about your data (metadata), and just because ArcGIS has a 'metadata tab' doesn't mean that is how other data systems store metadata. Commented Jul 10, 2018 at 15:45
  • @DPSSpatial Just because PostGIS doesn't have a functionality of handling metadata now doesn't mean that it should not deal with it. Commented Jul 11, 2018 at 6:59
  • 2
    @AurusHuang it is not the job of PostGIS ... it is the job of the database and the data owner/designer/maintainer! Commented Jul 11, 2018 at 14:32
5

PostgreSQL lets you store information about tables, columns, or numerous other objects using comments. If you choose, you can use the comment field to store a JSON or XML representation of attributes such as author, time of creation, measurement units, etc.

To set the comment on a table, use:

COMMENT ON TABLE my_table IS '{ "author" : "dbaston" }';

Comments can be viewed with the obj_description function:

SELECT obj_description('public.my_table'::regclass);
1
  • This is a good idea as long as you don't care about who can visit these data - which may not be the best practice. Commented Jul 12, 2018 at 0:51
0

I'm also interested in this function. I can't share the opinions of @DPSSpatial though, because the "Metadata" problem and the "layer styles" problem are similar (they are related to how you expose the layer, not how you "fill" it), and PostGIS manages only the second. If I install PostGIS, it's because I want to centralize ALL the geographical information. Nowadays, any WFS/WMS I can publish requires data, layers styles and metadata as MANDATORY. The one possible workaround I found for this missing feature is to store a table with fields and then edit it (pgadmin etc..), then I need to call a Python script whenever I want to export it. Alternatively, there's the metadata plugin but it stores metadata in qmd files (so, not on the internal DB).

Eventually, could be an idea to extend metadata plugin functionality to embrace PostGIS.

0

I have found the following text in the official document:

Metadata are currently saved in the project file. It can also be saved as an .XML file alongside file based layers or in a local .sqlite database for remote layers (e.g. PostGIS).

So QGIS does behave as ArcGIS did and provides a good complement to PostGIS. I think this is the answer I'm searching for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.