2

There are many reasons one might like to store temporal information in association with a shapefile. In my case I want a manually accessible timestamp so I can request temporally relative updates to a dataset.

Is there a proper way to do this in the shapefile standard? (or perhaps another QGIS accessible file standard)

I've had a look and the most appropriate place I could find seemed to me to be the geospatial metadata file (suffix .shp.xml) but I can't see how or if one can actually read or write a time stamp to that file.

The next thing I thought was to store a time stamp directly into the file name but that seems a little hacky for such an important factor.

To be clear I don't want to store a time stamp attribute for features in my shapefile as in GIS file format for space and time data? That would be straight forward but not appropriate. I want to store a timestamp for THE shapefile.

Using a timestamp assigned to the files by the OS (e.g.: file creation date or file access date) is also possible but that doesn't give me enough control and may be changed inappropriately by the OS later.

I use QGIS, but if there's no option available to QGIS, then writing my own XML (or similar) reader in Python is a viable solution too.

  • 1
    You can conceptually put anything into the .shp.xml sidecar, but I'd be interesting in knowing if there is any existing implementation of this particular aspect. – BradHards Sep 4 '16 at 7:25
2

The native way would be to use the "Date of last update" data field of the dbf file https://en.wikipedia.org/wiki/.dbf. However, it is formatted as YYMMDD and can not hold time. If that is accurate enough you can control the value of the field with GDAL through the shapefile driver http://www.gdal.org/drv_shapefile.html with the layer creation option (-lco) DBF_DATE_LAST_UPDATE.

DBF_DATE_LAST_UPDATE=YYYY-MM-DD: (OGR >= 2.0) Modification date to write in DBF header with year-month-day format. If not specified, current date is used. Note: behaviour of past GDAL releases was to write 1995-07-26

GDAL can naturally also read the value of DBF_DATE_LAST_UPDATE and for example ogrinfo shows it.

  • It's a shame that the current QGIS (2.16) is GDAL/OGR<2.0 because I can imagine a pyQGIS implementation from here using GDAL and it's python bindings. While running more than one version of GDAL in a single system might be possible it's problematic. Perhaps hacking a workaround until the hard working people who support QGIS catches it up would be best. It's certainly worked before! – Mr Purple Sep 6 '16 at 1:50
  • QGIS 2.18 is compiled and running against gdal 2.1.2 – Mr Purple Feb 11 '18 at 21:43
1

In the US for shapefile data the standard has been to put this information in the shp.xml file. The Federal Geographic Data Committee (FGDC) has been the lead in setting these standards. The data time stamp info could be stored in either the Identification Information or Maintenance Information section (see Geospatial Metadata Fact Sheet pdf). As far as metadata editors in QGIS you may a quick search turns up Metatools. FDGC also has a page on available metadata editing tools.

Geospatial Metadata Tools

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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