TransWikia.com

Getting difference between two versions of Shapefile using QGIS?

Geographic Information Systems Asked by Pman on September 30, 2020

I have two shapefiles that are the same in terms of the type of information they contain (same attribute fields). One is essentially an updated version of the other, so the newer version contains all the data of the earlier version plus more.

Each data entry has a unique id field. I am looking for a way to essentially ‘subtract’ the older shapefile from the newer one. This cannot be a spatial operation, it must be based on the attributes. I use primarily OGR and QGIS.

Any ideas on how to do something like this?

3 Answers

Maybe Layers by Field QGIS Plugin could do what you need

Layers by Field QGIS Plugin

Answered by rnuryadin on September 30, 2020

I assume a situation like below:

  1. When we visited last week, there were only three (3) schools. (Layer school_layer_1)
  2. However, we found five (5) schools this week. (Layer school_layer_2)

And we want to know which schools are newly built.

enter image description here

Then we can use a Virtual Layer to find out suspicious schools.

enter image description here

The SQL query is:

SELECT * FROM school_layer_2
WHERE id
IN (
    SELECT id FROM school_layer_2
    EXCEPT
    SELECT id FROM school_layer_1
   )

The produced Virtual Layer (green circles) is a point layer with the records of difference between school_layer_1 and school_layer_2.

Answered by Kazuhito on September 30, 2020

There is a new tool which was added in QGIS 3.12 called "Detect dataset changes" that does exactly what you want. It accepts any geometry type including point. The tool

Compares two vector layers, and determines which features are unchanged, added or deleted between the two. It is designed for comparing two different versions of the same dataset.

Original point:

enter image description here

Modified point:

enter image description here

Changes happened:

enter image description here

Please refer to the help above for more detailed information.

Information in the changelog for QGIS 3.12: https://qgis.org/en/site/forusers/visualchangelog312/#feature-add-new-algorithm-detect-dataset-changes

Answered by ahmadhanb on September 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP