@@ -26,115 +26,224 @@ Once installed, the plugin tools can be reached in different places:
2626- _ Processing_ toolbox (see below, "Using Conefor inside QGIS" paragraph)
2727
2828
29- ??? note
29+ ??? note "QGIS toolbars"
3030
3131 In QGIS the toolbars can be activated/deactivated by using the following menu:
3232
33- _View > toolbars_
33+ _View > toolbars_
3434
35- The content of a toolbar may vary depending on what tools/plugins are installed/active in a specific QGIS installation
35+ The content of a toolbar may vary depending on what tools/plugins are installed/active in a specific QGIS
36+ installation. The Conefor plugin is part of the _Vector Toolbar_ toolbar.
3637
3738
3839## Usage
3940
40- This plugin has two main intended usage workflows:
41+ [ // ] : # ( This plugin has two main intended usage workflows: )
4142
42- 1 . As a means for generating the Conefor input files (nodes and connections) from geospatial layers and then running
43- the standalone Conefor application with the tese input files. For this you can either:
43+ [ // ] : # ( )
44+ [ // ] : # ( 1. As a means for generating the Conefor input files ( ; nodes and connections) ; from geospatial layers and then running )
45+
46+ [ // ] : # ( the standalone Conefor application with the these input files. For this you can either: )
47+
48+ [ // ] : # ( )
49+ [ // ] : # ( - Use the plugin's main dialog )
50+
51+ [ // ] : # ( - Use the Processing algorithms present in _Processing toolbox > Conefor > Prepare input files_ )
52+
53+ [ // ] : # ( )
54+ [ // ] : # ( 2. As way to run the Conefor application from inside QGIS. In this workflow you can both prepare the Conefor input files )
4455
45- - Use the plugin's main dialog
46- - Use the Processing algorithms present in _ Processing toolbox > Conefor > Prepare input files_
56+ [ // ] : # ( and run the Conefor analysis by combining the Processing algorithms present in _Processing toolbox > Conefor_ )
4757
48- 2 . As way to run the Conefor application from inside QGIS. In this workflow you can both prepare the Conefor input files
49- and run the Conefor analysis by combining the Processing algorithms present in _ Processing toolbox > Conefor _
58+ This plugin is used for generating the Conefor input files (nodes and connections) from geospatial layers and then
59+ running the standalone Conefor application with the these input files. For this you can either:
5060
61+ - Use the plugin's main dialog
62+ - Use the Processing algorithms present in _ Processing toolbox > Conefor > Prepare input files_
5163
52- ## Preparing the inputs for post-processing with Conefor
5364
54- The icon/shortcut available in the _ Vector > conefor inputs_ menu or in the _ Vector_ toolbar provides access to an
55- interface that allows you to create the input files to be then processed with the Conefor application. For information
56- on how to use the Conefor application, see the
57- [ Conefor user manual] ( http://www.conefor.org/files/usuarios/Manual_Conefor_26.pdf ) .
65+ ## Preparing inputs for Conefor
5866
59- The tool allows to compute distance analysis and node (feature) queries:
6067
61- - Distance from edges (for polygon layers)
62- - Distance from centroids (for polygon layers)
63- - Compute area of polygons (for polygon layers)
68+ ### Using the dedicated Conefor plugin dialog
69+
70+ The icon/shortcut available in the _ Vector > Conefor inputs_ menu or in the _ Vector_ toolbar provides access to a
71+ dialog that allows you to create the input files to be then processed with the Conefor application.
72+
73+ The dialog allows to compute distance analysis and node (feature) queries:
74+
75+ - Distance from edges
76+ - Distance from centroids
77+ - Compute area of polygons
6478- Extract one attribute
6579
6680The results are placed into (separate) text files (with the .txt file extension) inside an output folder.
6781
68- For distance queries is available the option to compute also a vector layer that represents
69- the segments with the minimum distance between the input features.
82+ !!! tip
83+ For information on how you would use the plugin-generated files as inputs to Conefor, please see the
84+ [ Conefor user manual] .
85+
86+
87+ [ Conefor user manual ] : http://www.conefor.org/files/usuarios/Manual_Conefor_26.pdf
88+
89+ The dialog looks like this:
7090
71- Upon opening the tool, it will load all currently selected vector layers. Additional layers can also be selected by
72- adding rows to the tool's main table.
91+ ![ main-dialog-tour] ( images/qgisconefor-main-dialog.png )
7392
74- {Insert image of the dialog}
93+ 1 . ** Layer selector** - When clicked, this turns into a combobox, allowing you to select one of the layers that are
94+ currently loaded in QGIS as the target for Conefor inputs generation;
7595
76- The options are described here below:
7796
78- - ** Layer ** : the list of loaded layers to be analyzed/queried. If the user mistakenly loads a layer that is not to be
79- used, then it can double click on its name and a dropdown will show, allowing to choose any other proper layer
80- loaded in the QGIS project.
97+ 2 . ** Node ID selector ** - Select one of the attributes of the layer to be used as the Conefor node identifier. Only
98+ attributes of type integer are acceptable. Moreover, in order for the attribute to be usable as a node identifier,
99+ each feature in the input layer must have a unique value.
81100
82- - ** NODE ID** : this option allows to choose what is the attribute to be used as unique ID. The plugin is also
83- able to autogenerate an ID
101+ Alternatively to selecting an existing layer attribute, you may also choose the ` <AUTOGENERATE> ` option. This will
102+ result in the creation of a new in-memory layer named ` {layer-name}_conefor ` (in which ` {layer-name} ` is the name
103+ of the original layer), which is a copy of the original input layer, with the addition of a new column
104+ named ` conefor_node_id ` . This will allow you to match the node ids generated by the plugin to their
105+ corresponding layer features.
84106
85- - ** Node Attribute** : this option allows the user to query (extract) one attribute from the table of attributes of the
86- input layer. Results will be placed in a text file beside the "NODE ID" values.
107+ !!! tip
108+ Don't forget to save this new layer if you want to keep it, as in-memory layers are
109+ deleted when QGIS closes!
87110
88- If you select the _ <GENERATE_FROM_AREA>_ value, the plugin will the area of each feature as the node attribute.
89- Areas are computed using the ellipsoid and units defined in the QGIS Project. You can manage them by going to the
90- QGIS main menu _ Project > Properties... > General > Measurements_
91111
92- - ** Remove layer/Add layer** buttons: These buttons allow you to remove/add layers to be processed
112+ 3 . ** Node attribute selector** - Select one of the attributes of the layer to be used as the Conefor attribute. Only
113+ numeric attributes are acceptable.
93114
94- - ** Calculate node connections as** :
115+ Similarly to the Node ID selector, you may choose the ` <GENERATE_FROM_AREA> ` option, which will result in the
116+ creation of a new in-memory layer with a new column named ` conefor_node_attribute(area) ` . This column has the area
117+ of each feature, which is then used as the Conefor node attribute.
95118
96- - ** Edge distances** - When this option is active an output text file will be created and it will contain the
97- minimum distance between the edges (boundaries) of each feature.
119+ !!! tip
120+ You can combine both the autogeneration of a node id and the autogeneration of a node attribute, which would
121+ result in the generation of a single in-memory QGIS layer with a copy of the original layer and the addition of
122+ the two ` conefor_node_id ` and ` conefor_node_attribute(area) ` columns.
123+
124+ ??? info
125+ Autogeneration of the Conefor node attribute by using feature areas reuses the following QGIS Processing
126+ toolbox algorithms:
127+
128+ - [Add geometry attributes](https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#add-geometry-attributes) - Area is calculated using the `ellispoidal` option
129+ - [Drop field(s)](https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectortable.html#qgisdeletecolumn)
130+ - [Rename field](https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectortable.html#qgisrenametablefield)
131+
132+
133+ 4 . ** Nodes to add selector** - You can optionally select one of the input layer's attributes that should be used as the
134+ Conefor _ nodes to add_ field. This attribute must only have integer values of ` 0 ` and ` 1 ` . Read more this feature on
135+ the [ Conefor user manual] .
136+
137+
138+ 5 . ** Add/Remove layer buttons** - These buttons allow you to add and remove layers to be processed. Note that the
139+ ` Remove layer ` button always removes the last layer of the list
140+
141+
142+ 6 . ** Node distance method selector** - These radio buttons allow you to select one distance calculation method, which
143+ will be used to generate the Conefor distances file. Choose one of:
144+
145+ - ` Edge distances ` - Calculates distances between pairs of features by measuring the distance between their
146+ closest edges
147+ - ` Centroid distances ` - Calculates distances between pairs of features by measuring the distance between their
148+ geometric centroids
98149
99- - ** Centroid distances** - When this option is active an output text file will be created and it will contain the
100- minimum distance between the centroids of features.
150+ !!! info "Distance calculation and Coordinate Reference Systems (CRS)"
151+ When calculating distances it is a good idea to ensure that layers use a projected CRS.
152+
153+ In this plugin, if the input layer's CRS is projected, then distance calculation uses it directly. On the
154+ contrary, if the CRS of the layer is geographic, the plugin will fallback to using the CRS of the QGIS
155+ project - it simply transforms each input feature into the QGIS project's CRS (expecting it to be projected,
156+ but without checking) perform distance calculations.
157+
158+ If your input layers use a geographic CRS, such as WGS84 (EPSG:4326), you should either reproject them first
159+ or set an appropriate CRS in the QGIS project settings.
160+
101161
162+ 7 . ** Lock field names to first layer selector** - If you add a large number of layers with similar names for
163+ their corresponding attributes, you can opt to specify the ` node id ` /` node attribute ` /` nodes to add ` values for the
164+ first layer and have this selection be automatically replicated to all layers in the list.
102165
103- - ** Only use selected features** : If a selection is made in the QGIS canvas (in one or more input layers) and this
104- option is checked, then the analysis/queries will be run only using the selected features.
105166
106- - ** Lock field names to first layer** : before running any analysis/query, for each layer it is mandatory to select
107- a few options (a unique ID among the others, see below for details). If the number of layers to be analyzed/queried
108- is high then this can become a tedious operation. By checking this option the user can force the tool to assume
109- that the same analysis/queries have to be run for all the layers. The tool will also assume that all the layers
110- have a unique ID with the same name.
167+ 8 . ** Only use selected features selector** - Restrict the Conefor input files to contain information related to the
168+ currently selected features
111169
112- - ** Output directory** : the folder where output Conefor nodes and connections files will be placed. The output file
113- names contain the type of query and the layer name. For example, if the input file name is "espacios_natura2000"
114- then all the possible outputs will be:
115170
116- - distances_centroids_espacios_natura2000.txt
117- - distances_edges_espacios_natura2000.txt
118- - nodes_calculated_area_espacios_natura2000.txt
119- - nodes_NODE_ATTRIBUTE_espacios_natura2000.txt
120-
121- !!! note
171+ 9 . ** Output directory selector** - Choose the output directory for the generated Conefor node and connection files.
172+ The output files will be put inside the selected directory and will be named like:
173+
174+ - ` nodes_{node-column-name}_{layer-name}[_{increment}].txt `
175+ - ` distances_{edges | centroids}_{layer-name}[_{increment}].txt `
122176
123- When running multiple times the same analysis/query then the output files will not be overwritten, instead an
124- underscore and a progressive number is added at the end of the output file name, for example:
125-
126- - distances_centroids_espacios_natura2000_2.txt
127- - distances_centroids_espacios_natura2000_2.txt
128- - distances_centroids_espacios_natura2000_3.txt
129- - ...
177+ Where ` _{increment} ` may be present if there is already another file with the same name, in which case the increment
178+ is simple numeric increment, used to diferentiate between them.
179+
180+ For example, if a layer is named ` espacios_natura2000 ` , the possible output name combinations will be:
181+
182+ - ` nodes_conefor_node_attribute_(area)_espacios_natura2000.txt `
183+ - ` nodes_NODE_ATTRIBUTE_espacios_natura2000.txt `
184+ - ` nodes_NODE_ATTRIBUTE_espacios_natura2000_2.txt `
185+ - ` distances_centroids_espacios_natura2000.txt `
186+ - ` distances_edges_espacios_natura2000.txt `
187+ - ` distances_edges_espacios_natura2000_2.txt `
188+
189+
190+ 10 . ** Plugin help button** - Press the ` Help ` button to be taken to the homepage of the plugin, where you can find
191+ this user guide
192+
193+ 11 . ** OK/Cancel button** - Use the ` OK ` button to proceed with the generation of the Conefor input files or the ` Cancel `
194+ button to close the plugin dialog without performing any further action
195+
196+
197+ #### Plugin execution
198+
199+ When running, the plugin dialog will close itself and the processing will be taking place as a background task,
200+ with the progress being displayed in QGIS status bar (number 1 in the image below).
201+
202+ ![ qgisconefor-execution] ( images/qgisconefor-execution.png )
203+
204+ Clicking on the progress indicator opens up a small pop-up dialog where you can inspect the progress with a bit
205+ more detail (see number 2 in the image) and cancel ongoing calculations (number 3 in the image).
206+
207+ When finished, the plugin displays a notification in the main QGIS message bar to let you know its work is done.
208+ If something went wrong, it will show an error description.
209+
210+ ![ processing-done] ( images/qgisconefor-done.png )
211+
212+
213+ ### Using the Processing toolbox algorithms
214+
215+ This plugin's execution code is implemented as set of QGIS Processing algorithms. Therefore, regardless of if you are
216+ using the custom plugin dialog, or the dialogs shown via the Processing toolbox, the code runs in the same way. This
217+ means that execution options are mostly the same, with the notable difference that running via Processing uses a generic
218+ dialog that gets automatically created by QGIS.
219+
220+ !!! tip
221+
222+ Running via Processing also unlocks integrating this plugin with other algorithms, perhaps by creating complex
223+ Processing workflows with its Model Designer, or via custom scripts.
224+
225+ The [QGIS documentation has a comprehensive section on Processing](https://docs.qgis.org/3.34/en/docs/user_manual/processing/index.html).
226+
227+
228+ Looking at the QGIS Processing Toolbox panel, you will find a section named ** Conefor** . Expanding it will show the
229+ following structure:
230+
231+ - ` Prepare input files -> Generate input files from point layer `
232+
233+ - ` Prepare input files -> Generate input files from polygon layer `
234+
235+ Note that even though the custom dialog only allows the processing of vector layers that have _ Polygon_ geometries,
236+ which is the main use case for this plugin, using the Processing toolbox allows you to make use of layers with _ Point_
237+ geometries too, if needed.
238+
239+ ![ toolbox-structure] ( images/qgisconefor-processing-toolbox.png )
130240
131- - ** Run ** button: to run the analysis/queries.
241+ !!! tip
132242
133- When running, the plugin dialog will close itself and the processing will be taking place as a background task.
134- The progress is displayed in QGIS status bar. You can also cancel the execution by clicking on the progress
135- indicator and then clicking the cancel button.
243+ You can enable the Processing toolbox by navigating to _Processing -> toolbox_ in the QGIS main menu
136244
137- When finished, the plugin displays a notification to let you know its work is done.
245+ When choosing any of these two algorithms a new dialog pops up, with a set of user interface controls that mimick what
246+ has been described above in the [ section about the custom plugin dialog] ( #using-the-dedicated-conefor-plugin-dialog )
138247
139248
140249[ // ] : # ( ## Using Conefor inside QGIS )
0 commit comments