I'd use the following approach with GDAL: Multiple input shapefiles for ogr2ogr sqlite spatial operations
In detail, considering only two different years for brevity (but they could be all the seven years all together, as well), I'd wrap the layers in a VRT
file like this (e.g. data.vrt
):
<OGRVRTDataSource>
<OGRVRTlayer name="shp2012">
<SrcDataSource>shp2012.shp</SrcDataSource>
<SrcSQL dialect="sqlite">SELECT ID, ST_AREA(geometry) AS area2012, ST_LENGTH(geometry) AS peri2012, ST_LENGTH(geometry)/ST_AREA(geometry) AS para2012 FROM shp2012</SrcSQL>
</OGRVRTlayer>
<OGRVRTlayer name="shp2013">
<SrcDataSource>shp2013.shp</SrcDataSource>
<SrcSQL dialect="sqlite">SELECT ID, ST_AREA(geometry) AS area2013, ST_LENGTH(geometry) AS peri2013, ST_LENGTH(geometry)/ST_AREA(geometry) AS para2013 FROM shp2013</SrcSQL>
</OGRVRTlayer>
</OGRVRTDataSource>
Area, perimeter and a very simple shape index, i.e. the perimeter-area ratio (PARA
) are calculated in the SrcSQL
subelement for each layer.
Then, it's possible to calculate the deltas of area, perimeter and PARA between the two years and store the results in a DBF
file:
ogr2ogr diff_2013_2012.dbf data.vrt -dialect sqlite -sql "SELECT *, area2013-area2012 AS delta_area, peri2013-peri2012 AS delta_peri, para2013-para2012 AS delta_para FROM shp2013, shp2012 WHERE shp2013.ID = shp2012.ID"
Finally, the result DBF
file could be joined with the geometries of the year you like.
Note: In case we have to consider also the shifts or rotation of geometries, we could select also their bounding box (extent) WKT representation, i.e. AsWKT(Extent(geometry))
, to be calculated in the VRT
file. Finally, we have to check if WKT are the same or not within the ogr2ogr
command. The idea is to provide a simple boolean field, e.g. DIFFERENT
, which synthesize all the considered shape indices (and extent WKT, as well).