Does anyone know of a way to keep track of last added or edited features in QGIS? A kind of Editor Tracking tool.
-
Do you mean programmatically? When editing, there are undo/redo buttons.– underdarkCommented Feb 15, 2014 at 10:55
-
Interestingly, there's a tracking tool in the Composer (panels |command history) but not in the editing /layers window. Good addition - suggest it as a feature!– SimbamanguCommented Feb 15, 2014 at 13:03
-
I'm open to all suggestions. It would be to keep track of edits within a team of people modifying the same shape file.– user25976Commented Feb 16, 2014 at 9:23
5 Answers
Having your data stored in a Postgres\postgis database, you can use QGIS DBManager to create a versioning system on your tables.
Open DBManager and open you postgis database connection.
Then go to Table > Versioning.
This dialog will show:
Select the schema and table (That must be empty!) and press Ok
This tool will create new fields, a view (yourtable_current) and a few rules and triggers, to edit it. It will allow you to see what changes have been made to each feature in time and actually go back if needed.
Notice that you can run the listed code in "SQL to be executed:" directly on Postgres, and even tweak it a bit if you need. I for instance want to include a field "user" to track who made the changes.
You can keep track of edited features on shapefiles as well so you do not need PostGIS or Geoserver.
Steps: 1) Add a Edited Date Field (ESRI uses EDITED_DT). Make it a Date format. 2) Add a Created Date Field (ESRI uses CREATE_DT). make it a Date format. 3) In Layer Properties Select Attribute Form then the Edited Date field. 4) Towards the bottom change the defaults for the field to now() and apply the default value on update. 5) Once again in the Attribute Form, Open up the Created Date field. 6) Towards the bottom change the defaults for the field to now(). Unlike the edited date do not apply the default value on updates.
Note I realize this is an old post. So these instructions may have been explained elsewhere!
-
This method can apply to other file formats, e.g. geopackage. Basically, you're letting QGIS do the work through form defaults rather than PostGIS or other database/server-side tracking.– HouskaCommented May 26, 2020 at 16:36
Assuming you are using PostGIS, you may want to look into implementing your own edit tracking system in postgres.
A great tutorial can be found at this blog. The general idea is that after each edit/delete a table is updated to store details of any changes made along with user and time (all done using triggers). This system will also allow you to roll back to the previous geometry if required and adds accountability to your GIS.
Here are a couple of suggestions:
- You could maybe store your data in a database and use versioning. PostGIS announced a plugin for this (pgVersion) - though I must admit I've not used it.
- Alternatively, you could server your data via GeoServer with appropriate accounts and permissions set for your team and use GeoServer's versioning capabilities.
An alternative answer specifically for Geopackages.
I have my data in Geopackages. However, transactions can be triggered by various applications. (QGIS, FME, even directly on the database using SQLStudio as an example).
I would prefer to have these types of information implemented as database triggers - thus abstracting the capability from the end user application. For date - i was able to implement this database trigger for Inserts and Updates.
UPDATE approvals_request set date_modified = DATE();
Unfortunately though, It looks like SQLite databases have a limitation where they cannot access end user information via SQL statement. Im assuming that because SQLite db's are not running any overarching rdms software, there is no capability for the SQL to understand current user that is connecting to the database.
Therefore implementing the 'username' portion of the auditing capability was not possible at the DB level. If someone knows a way, id be very interested.