zoran-cuckovic / QGIS-visibility-analysis

Quantum GIS plugin for visibility analysis
GNU General Public License v3.0
72 stars 18 forks source link

Make Processing version of plugin #7

Closed alexbruy closed 7 years ago

alexbruy commented 7 years ago

It would be nice to have viewshed analysis tools available in Processing. This will allow to use it in batch mode or as a part of complex workflow

zoran-cuckovic commented 7 years ago

Hello! I'm working on this: some kind of a test version will be available in a couple of weeks...

alexbruy commented 7 years ago

Great news! Let me know if I can help to speed up development

zoran-cuckovic commented 7 years ago

Hi @alexbruy I've made a new branch ( 'experimental' ) for the modified module and a new repository for QGIS scripts. In order to make functions available for calling from external scripts I need to break up the code in modules, which takes some time... And it's difficult to decide on organisation of modules...

Anyway, now you can install manually (copy-paste) the code form the experimental branch into the plugin folder (ViewshedAnalysis folder in plugins directory) and use the script provided in the scripts repo. It can produce standard (binary) viewsheds. You will notice that the script is rather complex - the algorithm is based on reuse of pre-calculated parameters, for each call (i.e. for each point) these parameters need to be passed.

There is also a new script for moving points to a higher location. I will remove this function from the plugin in the next version, it seems to make more sense as a separate script.

I would be glad to hear some comments ...

alexbruy commented 7 years ago

As I can see, in order to use scripts, one should install your plugin too. Maybe better to turn plugin into Processing provider, so after installing it users will have algorithms in Processing without need to search for scripts and installing them manually?

Regarding scripts/plugin code: maybe better operate on the entire points layer instead of calling some function for each point and passing all pre-calculated parameters to it? So function will accept input raster and vector layers as well as all other required parameters. If I understand correctly in such case overhead will be lower and script a bit simpler.

I also have some ideas about code improvements. Will try to prepare PR for them.

zoran-cuckovic commented 7 years ago

To make a processing plugin - it's a good idea, it's not that complex, but it will take some time for sure...

Code organisation - you will notice that viewshed algorithms are usually point based. That is so because typically you would want to control parameters for each point (e.g. observer height, radius etc). In ArcGis these parameters can be stored in the accompanying table, and this is the approach I implemented. The problem: it's rather fussy to handle all this. For each algo there should be several options (fixed parameters, table fields etc)... (The plugin version has hierarchical "master-settings", but such approach does not work well for processing scripts - multiple scripts are preferred to one loaded with options for different algorithms)

The idea behind the script I made last week is to catch each output (for each observer point), so that user might do something particular with it - and keep the original speed. However, we cannot loop in modeller so this is not an issue anymore ; I will keep the script for those comfortable with Python, as a side treat...

alexbruy commented 7 years ago

I'm trying to cleanup plugin code and improve it a bit. Unfortunately, code is a bit difficult to read and when I separated for example binary viewshed creation into its own routine, it produced slightly different result from the original plugin, seems something went wrong. So I can't create PR now

alexbruy commented 7 years ago

I've send and email with my code and some ideas. Hope it is ok

zoran-cuckovic commented 7 years ago

@alexbruy I've made a first relatively functional version for processing framework. Most of the code is re-organised into new classes etc. Hope it makes sense (?) Anyway, I will have to stop working on this until beginning of April - but I will be glad to answer any questions. (probably better by e-mail)

zoran-cuckovic commented 7 years ago

@alexbruy
There is now a new repository for QGIS viewshed analysis plugin - version for QGIS processing framework senspace.