crocovert / networks

GNU General Public License v3.0
19 stars 3 forks source link

Networks result differs in R compared to Python #16

Open sriramab opened 8 months ago

sriramab commented 8 months ago

Hi,

Problem: when using your plugin via python on build_graph, I get i, j, ij fields in the line layer. But if I use the processing_r, I do not get the i, j, ij fields in the line layer. please see details below.

I am using Networks plugin to build a graph from a line layer. Everything works well. I then built a graphical modeler model with networks build_graph. Everything works well. Saved it as python script. Running the python script works well.

Now when I wish to do the same in R, using qgisprocess, https://github.com/r-spatial/qgisprocess , it does not give the same results that I get when using the Python approach (i,j,ij).

Here is a sample code, if you wish to reproduce. You may take any line layer you may have and load it in to QGIS. Then use the following code in a R snippet. I am not sure if you use the processing_r plugin at https://plugins.qgis.org/plugins/processing_r/. If you install this and create a new Rscript and paste the following code into it, you should be able to reproduce my problem. Here are additional instructions if you need to work with this plugin. https://docs.qgis.org/3.28/en/docs/user_manual/processing/3rdParty.html#r-scripts

I am not sure if I am missing any parameter into build_graph algorithm that builds the i,j,ij

Could you please have a look.

THank you.

##Flow=group
##Layer=vector line
##Create Graph=name
##OutputNodes=output vector

a <- qgisprocess::qgis_run_algorithm(
            "Networks:build_graph",
            DECIMALES= 9,
            IDENT= 0,  
            PREFIXE= '',
            RESEAU= Layer,
            SENS= ''
)

>str(st_as_sf(a))

OutputNodes <-st_as_sf(a)