[GRASS-user] Error in v.distance when running from R (in a container)

Hi Everyone,
I can run the R program with no problem from a Shiny app I have in Rstudio. Although when running the program from a container, I receive an error when running the v.distance and program halts.

here is the error dump I receive, not so much informative, although I appreciate to know if you have ever seen such an issue: (FYI many other grass functions are executed before this error happens)

Warning: Error in execGRASS: The command:
v.distance --overwrite --verbose from=WM_End from_layer=1 from_type=point to=WM_start to_layer=1 to_type=point dmax=0.5 dmin=-1 upload=to_attr column=LinkedWMID to_column=WMAINID separator=tab
produced an error (1) during execution:
Finds the nearest element in vector map ‘to’ for elements in vector map ‘from’.

Usage:
v.distance [-pas] from=name [from_layer=string]
[from_type=string[,string,…]] to=name [to_layer=string]
[to_type=string[,string,…]] [output=name] [dmax=value] [dmin=value]
upload=string[,string,…] [column=name[,name,…]] [to_column=name]
[table=name] [separator=character] [–overwrite] [–help] [–verbose]
[–quiet] [–ui]

Flags:
-p Print output to stdout, don’t update attribute table
-a Calculate distances to all features within the threshold
-s Print output as square matrix (only possible for one single upload variable)

Parameters:
from Name of existing vector map (from)
from_layer Laye [… truncated]
80: stop
79: execGRASS
78: MarkTheEnds
77: GetBaseNetworkNTransform

Thanks and Kind regards,

···

Mehrdad

Mehrdad Varedi, M.A.Sc.

Waterlix Inc. Founder

www.waterlix.com

Cell: +1 (519)722-7057

Hi Mehrdad,

On Mon, May 25, 2020 at 10:24 AM Mehrdad Varedi <varedi@waterlix.com> wrote:

Hi Everyone,
I can run the R program with no problem from a Shiny app I have in Rstudio. Although when running the program from a container, I receive an error when running the v.distance and program halts.

here is the error dump I receive, not so much informative, although I appreciate to know if you have ever seen such an issue: (FYI many other grass functions are executed before this error happens)

Warning: Error in execGRASS: The command:
v.distance --overwrite --verbose from=WM_End from_layer=1 from_type=point to=WM_start to_layer=1 to_type=point dmax=0.5 dmin=-1 upload=to_attr column=LinkedWMID to_column=WMAINID separator=tab
produced an error (1) during execution:
Finds the nearest element in vector map 'to' for elements in vector map 'from'.

Usage:
v.distance [-pas] from=name [from_layer=string]
   [from_type=string[,string,...]] to=name [to_layer=string]
   [to_type=string[,string,...]] [output=name] [dmax=value] [dmin=value]
   upload=string[,string,...] [column=name[,name,...]] [to_column=name]
   [table=name] [separator=character] [--overwrite] [--help] [--verbose]
   [--quiet] [--ui]

Flags:
  -p Print output to stdout, don't update attribute table
  -a Calculate distances to all features within the threshold
  -s Print output as square matrix (only possible for one single upload variable)

Parameters:
        from Name of existing vector map (from)
  from_layer Laye [... truncated]

^--- and chance to expand this "truncated"? Exactly therein you will
find the error message :slight_smile:
It is in the last line of the truncated part.

Best,
Markus

Hi Markus,
Sorry I am getting back to a conversation we had more than a month ago. I found the error on v.distance in R.

FYI, I run the same program under GRASS 7.8.3 with no problem, although when the v.distance function is called from R under GRASS 7.9.dev I get the following error:

“ERROR: At least one of the following options is required: ,

and <-p>>”

Here is the code I use in R:

execGRASS(“v.distance”,parameters= list(
from = NewLayerName,
from_layer = “1”,
from_type = “point”,
to = BasePointLayer,
to_layer = “1”,
to_type = “point”,
dmax = -1,
dmin = -1,
upload = “to_attr”,
column = NewRefColumn,
to_column = UniqueID2BeTaken,
separator = “tab”),
flags=c(‘overwrite’,‘verbose’)
)

I still want to upload the results to the selected column, not to a new table. How can I make it work in GRASS 7.9.dev?
by the way, the GRASS 7.8.3 is on my ubuntu computer, while the GRASS 7.9.dev is running in a docker container with the same OS.

I would appreciate to learn what should I add exactly to the command to make it work with the new version of GRASS. If there is a bug that needs some work , probably I should create a new container with the previous version of GRASS. what do you recommend?

Kind regards,

Mehrdad

On Mon, May 25, 2020 at 5:12 AM Markus Neteler <neteler@osgeo.org> wrote:

Hi Mehrdad,

On Mon, May 25, 2020 at 10:24 AM Mehrdad Varedi <varedi@waterlix.com> wrote:

Hi Everyone,
I can run the R program with no problem from a Shiny app I have in Rstudio. Although when running the program from a container, I receive an error when running the v.distance and program halts.

here is the error dump I receive, not so much informative, although I appreciate to know if you have ever seen such an issue: (FYI many other grass functions are executed before this error happens)

Warning: Error in execGRASS: The command:
v.distance --overwrite --verbose from=WM_End from_layer=1 from_type=point to=WM_start to_layer=1 to_type=point dmax=0.5 dmin=-1 upload=to_attr column=LinkedWMID to_column=WMAINID separator=tab
produced an error (1) during execution:
Finds the nearest element in vector map ‘to’ for elements in vector map ‘from’.

Usage:
v.distance [-pas] from=name [from_layer=string]
[from_type=string[,string,…]] to=name [to_layer=string]
[to_type=string[,string,…]] [output=name] [dmax=value] [dmin=value]
upload=string[,string,…] [column=name[,name,…]] [to_column=name]
[table=name] [separator=character] [–overwrite] [–help] [–verbose]
[–quiet] [–ui]

Flags:
-p Print output to stdout, don’t update attribute table
-a Calculate distances to all features within the threshold
-s Print output as square matrix (only possible for one single upload variable)

Parameters:
from Name of existing vector map (from)
from_layer Laye [… truncated]

^— and chance to expand this “truncated”? Exactly therein you will
find the error message :slight_smile:
It is in the last line of the truncated part.

Best,
Markus

Hi Mehrdad,

I have the same problem (running just GRASS dev - without calling it from R).

Why can’t v.distance update the current table (I tried using --overwrite but does not work either)? I do not want to create a new vector or a new table or print to stdout. Is this an undocumented new behaviour in dev or a bug? There’s indeed an example in the manual page of v.distance that describes what we want to do; see Point-in-polygon example.

Vero

El lun., 20 jul. 2020 a las 6:23, Mehrdad Varedi (<varedi@waterlix.com>) escribió:

Hi Markus,
Sorry I am getting back to a conversation we had more than a month ago. I found the error on v.distance in R.

FYI, I run the same program under GRASS 7.8.3 with no problem, although when the v.distance function is called from R under GRASS 7.9.dev I get the following error:

“ERROR: At least one of the following options is required: ,

and <-p>>”

Here is the code I use in R:

execGRASS(“v.distance”,parameters= list(
from = NewLayerName,
from_layer = “1”,
from_type = “point”,
to = BasePointLayer,
to_layer = “1”,
to_type = “point”,
dmax = -1,
dmin = -1,
upload = “to_attr”,
column = NewRefColumn,
to_column = UniqueID2BeTaken,
separator = “tab”),
flags=c(‘overwrite’,‘verbose’)
)

I still want to upload the results to the selected column, not to a new table. How can I make it work in GRASS 7.9.dev?
by the way, the GRASS 7.8.3 is on my ubuntu computer, while the GRASS 7.9.dev is running in a docker container with the same OS.

I would appreciate to learn what should I add exactly to the command to make it work with the new version of GRASS. If there is a bug that needs some work , probably I should create a new container with the previous version of GRASS. what do you recommend?

Kind regards,

Mehrdad

On Mon, May 25, 2020 at 5:12 AM Markus Neteler <neteler@osgeo.org> wrote:

Hi Mehrdad,

On Mon, May 25, 2020 at 10:24 AM Mehrdad Varedi <varedi@waterlix.com> wrote:

Hi Everyone,
I can run the R program with no problem from a Shiny app I have in Rstudio. Although when running the program from a container, I receive an error when running the v.distance and program halts.

here is the error dump I receive, not so much informative, although I appreciate to know if you have ever seen such an issue: (FYI many other grass functions are executed before this error happens)

Warning: Error in execGRASS: The command:
v.distance --overwrite --verbose from=WM_End from_layer=1 from_type=point to=WM_start to_layer=1 to_type=point dmax=0.5 dmin=-1 upload=to_attr column=LinkedWMID to_column=WMAINID separator=tab
produced an error (1) during execution:
Finds the nearest element in vector map ‘to’ for elements in vector map ‘from’.

Usage:
v.distance [-pas] from=name [from_layer=string]
[from_type=string[,string,…]] to=name [to_layer=string]
[to_type=string[,string,…]] [output=name] [dmax=value] [dmin=value]
upload=string[,string,…] [column=name[,name,…]] [to_column=name]
[table=name] [separator=character] [–overwrite] [–help] [–verbose]
[–quiet] [–ui]

Flags:
-p Print output to stdout, don’t update attribute table
-a Calculate distances to all features within the threshold
-s Print output as square matrix (only possible for one single upload variable)

Parameters:
from Name of existing vector map (from)
from_layer Laye [… truncated]

^— and chance to expand this “truncated”? Exactly therein you will
find the error message :slight_smile:
It is in the last line of the truncated part.

Best,
Markus


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Hi,

On Mon, Jul 20, 2020 at 9:22 PM Veronica Andreo <veroandreo@gmail.com> wrote:

Hi Mehrdad,

I have the same problem (running just GRASS dev - without calling it from R).
Why can't v.distance update the current table

Because it was changed to "upload is required" in:

https://github.com/OSGeo/grass/commit/2c614dd3225294a1f9e094b06d24a0905a239333

Maybe Moritz can tell us more why this was needed?

Best,
Markus

On 20/07/20 21:41, Markus Neteler wrote:

Hi,

On Mon, Jul 20, 2020 at 9:22 PM Veronica Andreo <veroandreo@gmail.com> wrote:

Hi Mehrdad,

I have the same problem (running just GRASS dev - without calling it from R).
Why can't v.distance update the current table

Because it was changed to "upload is required" in:

https://github.com/OSGeo/grass/commit/2c614dd3225294a1f9e094b06d24a0905a239333

Maybe Moritz can tell us more why this was needed?

The issue wasn't the upload is required (v.distance always needs a variable to upload), but a change to G_required in which I added the new functionalities, but at the same time forgot the column upload option. Should be fixed in master, now.

Sorry...

Moritz

Thank you Moritz, Veronica and Markus.

···

Mehrdad