Skip to content

Commit

Permalink
Merge pull request #9 from OnroerendErfgoed/readme_cherries
Browse files Browse the repository at this point in the history
updated README and small cleanings for script
  • Loading branch information
maarten-vermeyen authored May 30, 2024
2 parents 65d28ce + 00ec5d3 commit 472992b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
- Resulting output made available for further QGIS-modelling
- added enum - parameter to download actual GRB (adp-gbg-knw)
- added enum - parameter for od-strategy
- changes implmented for refactored brdr
- changes implemented for refactored brdr
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ You can install the latest release of `brdrQ` from
[GitHub](https://github.com/OnroerendErfgoed/brdrQ/).

### Pre-requisites
- Script is tested for QGIS on Linux and Windows. Usage of the script on Mac is not tested, and can give errors or unexpected behaviour.
- QGIS >3.28.5: The script has been developed and tested based on QGIS 3.28.5. In older versions, the script will not work)
- brdr needs Shapely 2.0.2 or higher. This version of Shapely is available by default from QGIS 3.28.5 onwards on Windows installations. On Linux and Mac this may not be the case. If the modules are not found, the script will attempt to install both brdr and shapely from Pypi.

Expand All @@ -25,7 +26,11 @@ Follow the steps below to make the script available in QGIS Processing Toolbar
2. Choose: 'Add script to Toolbox...' (see red arrow) and select the script 'autocorrectborders.py'
<img src="docs/figures/installation-step-2.png" width="100%" />
<img src="docs/figures/installation-step-2b.png" width="50%" />
3. The tool is now available in the Processing Toolbox under 'Scripts - autocorrectborders'

(While adding the script to the toolbox, the necessary python-dependencies will be installed if not yet available on your machine.
If dependencies need to be installed, a screen like below can pop up. Please wait until installation is finished. The screen will close automatically after installation.)
<img src="docs/figures/installation-step-2c.png" width="50%" />
3. The tool 'Autocorrectborders' is now available in the Processing Toolbox under 'brdrQ'
<img src="docs/figures/installation-step-3.png" width="100%" />
4. Double-click on the 'Autocorrectborders' tool, and the tool opens:
<img src="docs/figures/installation-step-4.png" width="100%" />
Expand Down Expand Up @@ -88,7 +93,16 @@ The various INPUT & OUTPUT parameters are explained in more detail below. Here a


### OUTPUT
The script generates several output layers in the layer overview. The name includes which 'RELEVANT_DISTANCE (X)' and 'OD-STRATEGY (Y)' is used
The script generates several output layers in the layer overview:

* brdrQ_RESULT_X_Y: resulting geometries after alignment
* brdrQ_DIFF_X_Y: differences (+ and -) between original and resulting geometry
* brdrQ_DIFF_MIN_X_Y:differences (-) between original and resulting geometry
* brdrQ_DIFF_PLUS_X_Y:differences (+) between original and resulting geometry
* (optional) brdrQ_RLVNT_DIFF_X_Y: relevant differences (parts to exclude), used when processing the resulting geometry
* (optional) brdrQ_RLVNT_ISECT_X_Y: relevant intersection (parts to include), used when processing the resulting geometry

The name includes which 'RELEVANT_DISTANCE (X)' and 'OD-STRATEGY (Y)' is used
<img src="docs/figures/output.png" width="100%" />

### TIPS, ASSUMPTIONS & LIMITATIONS
Expand All @@ -101,7 +115,7 @@ The script generates several output layers in the layer overview. The name inclu

This allows you to gain insight into the 'deviation' and which RELEVANT_DISTANCE value can best be applied.
- The RELEVANT_DISTANCE must be chosen according to the 'deviation' of the thematic data compared to the reference layer. If the thematic data contains different geometries that show large differences in 'deviation', it is best to split the thematic data and process it separately with an appropriate RELEVANT_DISTANCE so that the RELEVANT_DISTANCE can be kept as small as possible.
- The current version of the script assumes that both the thematic layer and reference layer are in Lambert72 (EPSG:31370)
- The current version of the script assumes that both the thematic layer and reference layer are in the same CRS: Lambert72 (EPSG:31370) or Lambert 2008 (EPSG:3812).
- Thematic boundaries consisting of 1 or a few reference polygons are processed by the script in a few seconds. If the thematic boundaries cover a very large area (~1000 and reference polygons), it may take several minutes for the OUTPUT to be calculated. It's best to let QGIS finish this processing before proceeding
- In practice, we notice that large thematic demarcations are sometimes drawn more roughly (less precisely or inaccurately), so that a high RELEVANT DISTANCE is required to shift them to the reference file. For large areas that are drawn 'roughly', it is best to use a high RELEVANT_DISTANCE (e.g. >10 meters) and:
- OD-strategy EXCLUDE: if you want to completely exclude all public domain
Expand All @@ -114,7 +128,8 @@ The script uses `brdr`, a python-package to align thematic borders to reference

- For more information about the conceptual method/algorithm consult:
<https://github.com/OnroerendErfgoed/brdr>.
-


## Comments and contributions

- Please report any issues or bugs here:
Expand Down
34 changes: 17 additions & 17 deletions autocorrectborders.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ class AutocorrectBordersProcessingAlgorithm(QgsProcessingAlgorithm):

INTERMEDIATE_LAYER_GROUP = "INTERMEDIATE_LAYER_GROUP"

LAYER_RESULT = "LAYER_RESULT"
LAYER_RESULT_DIFF = "LAYER_RESULT_DIFF"
LAYER_RESULT_DIFF_PLUS = "LAYER_RESULT_DIFF_PLUS"
LAYER_RESULT_DIFF_MIN = "LAYER_RESULT_DIFF_MIN"
LAYER_SIGNIFICANT_INTERSECTION = "LAYER_SIGNIFICANT_INTERSECTION"
LAYER_SIGNIFICANT_DIFFERENCE = "LAYER_SIGNIFICANT_DIFFERENCE"
LAYER_RESULT = "brdrQ_RESULT"
LAYER_RESULT_DIFF = "brdrQ_DIFF"
LAYER_RESULT_DIFF_PLUS = "brdrQ_DIFF_PLUS"
LAYER_RESULT_DIFF_MIN = "brdrQ_DIFF_MIN"
LAYER_RELEVANT_INTERSECTION = "brdrQ_RLVNT_ISECT"
LAYER_RELEVANT_DIFFERENCE = "brdrQ_RLVNT_DIFF"
LAYER_REFERENCE = "LAYER_REFERENCE"

SUFFIX = ""
Expand Down Expand Up @@ -212,14 +212,14 @@ def name(self):
lowercase alphanumeric characters only and no spaces or other
formatting characters.
"""
return "autocorrectBorders"
return "brdrqautocorrectBorders"

def displayName(self):
"""
Returns the translated algorithm name, which should be used for any
user-visible display of the algorithm name.
"""
return self.tr("Autocorrectborders")
return self.tr("brdrQ - Autocorrectborders")

def group(self):
"""
Expand Down Expand Up @@ -618,14 +618,14 @@ def processAlgorithm(self, parameters, context, feedback):
)
if self.SHOW_INTERMEDIATE_LAYERS:
self.create_temp_layer(
self.LAYER_SIGNIFICANT_INTERSECTION,
self.LAYER_RELEVANT_INTERSECTION,
self.INTERMEDIATE_LAYER_GROUP,
self.ID_THEME_GLOBAL,
"simple green fill",
False,
)
self.create_temp_layer(
self.LAYER_SIGNIFICANT_DIFFERENCE,
self.LAYER_RELEVANT_DIFFERENCE,
self.INTERMEDIATE_LAYER_GROUP,
self.ID_THEME_GLOBAL,
"simple red fill",
Expand Down Expand Up @@ -766,7 +766,7 @@ def processAlgorithm(self, parameters, context, feedback):
)
if self.SHOW_INTERMEDIATE_LAYERS:
self.add_geom_to_temp_layer(
self.LAYER_SIGNIFICANT_INTERSECTION,
self.LAYER_RELEVANT_INTERSECTION,
self.geom_shapely_to_qgis(
self.geom_from_dict(
relevant_intersection_merged, id_theme_global
Expand All @@ -775,7 +775,7 @@ def processAlgorithm(self, parameters, context, feedback):
id_theme_global,
)
self.add_geom_to_temp_layer(
self.LAYER_SIGNIFICANT_DIFFERENCE,
self.LAYER_RELEVANT_DIFFERENCE,
self.geom_shapely_to_qgis(
self.geom_from_dict(relevant_diff_merged, id_theme_global)
),
Expand Down Expand Up @@ -927,12 +927,12 @@ def prepare_parameters(self, parameters):
self.PROCESS_MULTI_AS_SINGLE_POLYGONS = parameters[
"PROCESS_MULTI_AS_SINGLE_POLYGONS"
]
self.SUFFIX = "_" + str(self.RELEVANT_DISTANCE) + "_OD_" + str(self.OD_STRATEGY)
self.LAYER_SIGNIFICANT_INTERSECTION = (
self.LAYER_SIGNIFICANT_INTERSECTION + self.SUFFIX
self.SUFFIX = "_" + str(self.RELEVANT_DISTANCE) + "_OD_" + str(self.OD_STRATEGY.name)
self.LAYER_RELEVANT_INTERSECTION = (
self.LAYER_RELEVANT_INTERSECTION + self.SUFFIX
)
self.LAYER_SIGNIFICANT_DIFFERENCE = (
self.LAYER_SIGNIFICANT_DIFFERENCE + self.SUFFIX
self.LAYER_RELEVANT_DIFFERENCE = (
self.LAYER_RELEVANT_DIFFERENCE + self.SUFFIX
)
self.LAYER_RESULT = self.LAYER_RESULT + self.SUFFIX
self.LAYER_RESULT_DIFF = self.LAYER_RESULT_DIFF + self.SUFFIX
Expand Down
Binary file modified docs/figures/input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file modified docs/figures/installation-step-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/installation-step-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 472992b

Please sign in to comment.