[GRASS-user] Grass Graphic Model v.net.distance Not Accepting point layer in From or To fields

Moritz Lennert mlennert at club.worldonline.be
Thu Dec 30 06:40:54 PST 2021


Hi Josh,

I would really suggest that we go back to the basics in order to really 
understand where your problem lies. So first of all, are you able to do 
what you are planning to do using simple command line, or calling the 
respective modules one by one from the GUI ?

Using the basic NC demo data set, this is what I do:

# connect streets and schools (snapping the school points to the 
existing road network)
v.net -s in=streets points=schools op=connect threshold=200 
output=streets_schools_network
# copy the original schools attribute table into my current mapset
db.copy 
from_database=/home/mlennert/grassdata/nc_basic_spm_grass7/PERMANENT/sqlite/sqlite.db 
from_table=schools to_table=schools_network
# connect this table to the network map
v.db.connect streets_schools_network layer=2 table=schools_network

# Now, get the shortest path of the school with the attribute TAG = 548 
to its closest neighbor
v.net.distance in=streets_schools_network output=path_548 from_layer=2 
from_where=TAG=548 to_layer=2 to_where="TAG <> 548"

# Or get all shortest paths between all schools
v.net.allpairs streets_schools_network out=paths_all

# Get all the shortest paths of the school with TAG=548
# As the TAG attribute is not part of the shortest paths table, but the 
from category is, get that first
v.db.select paths_all layer=2 where=TAG=548 col=cat
v.db.select paths_all layer=1 where=from_cat=20

# Display only those paths, using random colors for the different paths
d.vect -c map=paths_all at user1 where=from_cat=20 color=255:165:0:255 
width=2

# To make selection using the TAG variable easier, I can add it to the 
attribute table of the paths through a table join

# Find out names of tables of the paths_all map
v.db.connect paths_all -p

# Join TAG attribute from the points layer table to the arc layer table 
using the cat of the points layer table and the from_cat of the arc 
layer table as keys
v.db.join paths_all column=from_cat 
other_table=paths_all_schools_network other_column=cat 
subset_columns=TAG

# Now select using TAG
v.db.select paths_all layer=1 where=TAG=548

If all this works for you either on command line or using the individual 
module GUIs, then we can check whether there are particular issues in 
the graphical modeler.

Moritz

Am 30.12.2021 03:52 schrieb Joshua Geoghegan:
> Happy holidays all.
> 
>  Just wondering if you were able to help with the below when you have
> a chance. I'm hoping to have it working in the new year.
> 
>  Regards,
> 
>  Josh
> 
>  		JOSHUA GEOGHEGAN | GIS Specialist
> 
>  		EMAIL: joshua.geoghegan at mornpen.vic.gov.au
> 
>  		PHONE: 03 5950 1321
> 
>  		Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud
> VIC 3939
> 
>  		Follow us on social media!
>  		 [4] [5] [6] [7]
> 
>  		 [8]
> 
> Mornington Peninsula Shire acknowledges and pays respect to the
> Bunurong/Boon Wurrung people,
>  the traditional custodians of these lands and waters.
> We are committed to carbon neutrality.
> 
> -------------------------
> 
> FROM: grass-user <grass-user-bounces at lists.osgeo.org> on behalf of
> Joshua Geoghegan <joshua.geoghegan at mornpen.vic.gov.au>
>  SENT: Wednesday, 8 December 2021 9:47 AM
>  TO: Moritz Lennert <mlennert at club.worldonline.be>;
> grass-user at lists.osgeo.org <grass-user at lists.osgeo.org>
>  SUBJECT: Re: [GRASS-user] Grass Graphic Model v.net.distance Not
> Accepting point layer in From or To fields
> 
> Hi Moritz,
> 
> Regarding the last comment in your reply, with everything I have tried
> so far when I change the From and To layers to 2 it will always
> reverts back to layer 1 when I come back in to this form.
> 
> Also, when I change it to layer 2 and try to add a where clause I am
> told there is no layer linked to layer 2.
> 
> I’ve connected the points table to the network here.
> 
> Below is the setup for the command. I couldn’t seem to output the
> script into text so here is that function in the Python output. Notice
> the layer is set to 1. I keep changing that to 2 also but it reverts
> to 1.
> 
>  run_command("v.db.connect",
> 
>  flags='o',
> 
>  overwrite = True,
> 
>  map="myroads_net_Rosebud_Meals",
> 
>  driver="sqlite",
> 
>  database="$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db",
> 
>  table="Meals_Rosebud_reproj",
> 
>  key="cat",
> 
>  layer="1",
> 
>  separator="pipe")
> 
> Regards,
> 
> JOSHUA GEOGHEGAN | GIS Specialist
> 
> EMAIL: joshua.geoghegan at mornpen.vic.gov.au
> 
> PHONE: 03 5950 1321
> 
> Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud VIC
> 3939
> 
> Follow us on social media!
> 
>  [9] [5] [6] [7]
> 
>  [8]
> 
> Mornington Peninsula Shire acknowledges and pays respect to the
> Bunurong/Boon Wurrung people,
>  the Traditional Custodians of these lands and waters.
> 
> We are committed to carbon neutrality.
> 
> FROM: Joshua Geoghegan
>  SENT: Wednesday, 8 December 2021 8:32 AM
>  TO: Moritz Lennert <mlennert at club.worldonline.be>;
> grass-user at lists.osgeo.org
>  SUBJECT: RE: [GRASS-user] Grass Graphic Model v.net.distance Not
> Accepting point layer in From or To fields
> 
> Apologies, I’ll take a look today.
> 
> Regards,
> 
> JOSHUA GEOGHEGAN | GIS Specialist
> 
> EMAIL: joshua.geoghegan at mornpen.vic.gov.au
> 
> PHONE: 03 5950 1321
> 
> Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud VIC
> 3939
> 
> Follow us on social media!
> 
>  [9] [5] [6] [7]
> 
>  [8]
> 
> Mornington Peninsula Shire acknowledges and pays respect to the
> Bunurong/Boon Wurrung people,
>  the Traditional Custodians of these lands and waters.
> 
> We are committed to carbon neutrality.
> 
> FROM: Moritz Lennert <mlennert at club.worldonline.be>
>  SENT: Tuesday, 7 December 2021 6:16 PM
>  TO: Joshua Geoghegan <joshua.geoghegan at mornpen.vic.gov.au>;
> grass-user at lists.osgeo.org
>  SUBJECT: RE: [GRASS-user] Grass Graphic Model v.net.distance Not
> Accepting point layer in From or To fields
> 
> Hi Josh,
> 
>  I sent you a reply:
> 
>  https://lists.osgeo.org/pipermail/grass-user/2021-December/082742.html
> [10]
> 
>  I don't think you sent anything since then.
> 
>  Moritz
> 
> Le 5 décembre 2021 21:50:54 GMT+00:00, Joshua Geoghegan
> <joshua.geoghegan at mornpen.vic.gov.au> a écrit :
> 
>> Hi Moritz,
>> 
>> I was wondering if you got a chance to see my reply with my current
>> Grass workflow.
>> 
>> Hope it makes sense.
>> 
>> Regards,
>> 
>> JOSHUA GEOGHEGAN | GIS Specialist
>> 
>> EMAIL: joshua.geoghegan at mornpen.vic.gov.au
>> 
>> PHONE: 03 5950 1321
>> 
>> Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud VIC
>> 3939
>> 
>> Follow us on social media!
>> 
>> Mornington Peninsula Shire acknowledges and pays respect to the
>> Bunurong/Boon Wurrung people,
>> the Traditional Custodians of these lands and waters.
>> 
>> We are committed to carbon neutrality.
>> 
>> FROM: Joshua Geoghegan
>> SENT: Friday, 26 November 2021 1:57 PM
>> TO: Moritz Lennert <mlennert at club.worldonline.be>;
>> grass-user at lists.osgeo.org
>> SUBJECT: RE: [GRASS-user] Grass Graphic Model v.net.distance Not
>> Accepting point layer in From or To fields
>> 
>> Hi Moritz,
>> 
>> Does the below make sense?
>> 
>> Perhaps I have connected the point and line vectors incorrectly?
>> 
>> Regards,
>> 
>> Josh
>> 
>> JOSHUA GEOGHEGAN | GIS Specialist
>> 
>> EMAIL: joshua.geoghegan at mornpen.vic.gov.au
>> 
>> PHONE: 03 5950 1321
>> 
>> Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud VIC
>> 3939
>> 
>> Follow us on social media!
>> 
>> Mornington Peninsula Shire acknowledges and pays respect to the
>> Bunurong/Boon Wurrung people,
>> the Traditional Custodians of these lands and waters.
>> 
>> We are committed to carbon neutrality.
>> 
>> FROM: Joshua Geoghegan
>> SENT: Wednesday, 24 November 2021 10:24 AM
>> TO: Moritz Lennert <mlennert at club.worldonline.be>;
>> grass-user at lists.osgeo.org
>> SUBJECT: RE: [GRASS-user] Grass Graphic Model v.net.distance Not
>> Accepting point layer in From or To fields
>> 
>> Hi Moritz,
>> 
>> When I set it to layer 2 (which is the point layer I connected) and
>> close the v.net.distance dialog, and reopen it I see the form reload
>> and it switches back to 1.
>> 
>> I also try to create the where clause and now it says no table
>> linked to layer 2 even though I linked it with v.db.connect.
>> 
>> I tried connecting the attribute table to the same vector for the
>> points, as well as trying connecting to the linked point/network
>> vector.
>> 
>> Am I missing a step perhaps? Is the attribute table coming straight
>> from the shapefile I am importing?
>> 
>> Below are the steps up until v.net.distance, with my network being
>> cleaned up beforehand.
>> 
>> The highlighted section is where I import the points up until the
>> v.net.distance.
>> 
>> I probably don’t need the v.db.addtable. That was there so I could
>> populate the distance for each route but I guess v.net.distance
>> outputs that.
>> 
>> It still didn’t work when I removed that.
>> 
>> Hopefully that makes sense.
>> 
>> Regards,
>> 
>> JOSHUA GEOGHEGAN | GIS Specialist | MORNINGTON PENINSULA SHIRE
>> 
>> Phone: 03 5950 1321
>> 
>> Email: joshua.geoghegan at mornpen.vic.gov.au
>> 
>> Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud VIC
>> 3939
>> 
>> www.mornpen.vic.gov.au [1] | Twitter @MornPenShire | Facebook
>> @MornPenShire
>> 
>> Mornington Peninsula Shire acknowledges and pays respect to the
>> Bunurong/Boon Wurrung people,
>> 
>> the Traditional Custodians of these lands and waters.
>> 
>> -----Original Message-----
>> From: Moritz Lennert <mlennert at club.worldonline.be>
>> Sent: Tuesday, 23 November 2021 6:07 PM
>> To: Joshua Geoghegan <joshua.geoghegan at mornpen.vic.gov.au>;
>> grass-user at lists.osgeo.org
>> Subject: RE: [GRASS-user] Grass Graphic Model v.net.distance Not
>> Accepting point layer in From or To fields
>> 
>> Hi Joshua,
>> 
>> Le 23 novembre 2021 01:45:14 GMT+01:00, Joshua Geoghegan
>> <joshua.geoghegan at mornpen.vic.gov.au> a écrit :
>> 
>>> Thanks Moritz,
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> What would be the reason behind the point layer switching back to
>> layer 1 in v.net.distance if I have linked the point and network?
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> I'll test your two options in the meantime, but it still switches
>> back to layer 1.
>> 
>> I'm not sure I understand what you mean by "switching back". Most
>> modules have layer=1as the default setting. That doesn't mean that
>> the specific layer you work on does not have other layers. Have you
>> checked whether you can set it to layer=2 ?
>> 
>> To help you, we would need some more info:
>> 
>> - What is the exact command you use to connect the lines and the
>> points ?
>> 
>> - What is the output of v.category with option=report on the
>> resulting file ?
>> 
>> Moritz
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> [cid:image001.png at 01D7E05F.93540130 [2]]
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> Regards,
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> JOSHUA GEOGHEGAN | GIS Specialist | MORNINGTON PENINSULA SHIRE
>> 
>>> 
>> 
>>> Phone: 03 5950 1321
>> 
>>> 
>> 
>>> Email: joshua.geoghegan at mornpen.vic.gov.au
>> 
>>> 
>> 
>>> Private Bag 1000, Rosebud VIC 3939 | 90 Besgrove Street, Rosebud
>> VIC 3939
>> 
>>> 
>> 
>>> www.mornpen.vic.gov.au [1] | Twitter @MornPenShire | Facebook
>> @MornPenShire
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> Mornington Peninsula Shire acknowledges and pays respect to the
>> Bunurong/Boon Wurrung people,
>> 
>>> 
>> 
>>> the Traditional Custodians of these lands and waters.
>> 
>>> 
>> 
>>> -----Original Message-----
>> 
>>> From: Moritz Lennert <mlennert at club.worldonline.be>
>> 
>>> Sent: Monday, 22 November 2021 6:32 PM
>> 
>>> To: grass-user at lists.osgeo.org; Joshua Geoghegan
>> <joshua.geoghegan at mornpen.vic.gov.au>
>> 
>>> Subject: Re: [GRASS-user] Grass Graphic Model v.net.distance Not
>> Accepting point layer in From or To fields
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> Hi Joshua,
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> Le 21 novembre 2021 22:12:42 GMT+01:00, Joshua Geoghegan
>> 
> <joshua.geoghegan at mornpen.vic.gov.au<mailto:joshua.geoghegan at mornpen.vic.gov.au>>
>> a écrit :
>> 
>>> 
>> 
>>>> Hi there,
>> 
>>> 
>> 
>>>> 
>> 
>>> 
>> 
>>>> I have been stuck on a problem and I was hoping you could help, as
>> I had no luck on GIS Stack Exchange.
>> 
>>> 
>> 
>>>> 
>> 
>>> 
>> 
>>>> I have a point and network layer connected in Grass GIS via the
>> graphic modeler.
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> What exactly do you mean by 'the graphic modeler'. I assume you
>> connect the two using v.net ?
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>>> I am trying to find the shortest path between the first point
>> (ROUND=0) and every other point (ROUND != 0) on the same point
>> layer. For some reason I can select this layer (layer 2) in both
>> From and To tabs and add category 1-500 (which is more than the
>> number of points), but when I try the where clause and test for
>> values in the ROUND field on the SQL Builder the results show up as
>> '', even though the imported shp file has values. When I hit OK and
>> come back into the form it has reverted back to layer 1 in the From
>> and To tabs, which is road network layer.
>> 
>>> 
>> 
>>>> 
>> 
>>> 
>> 
>>>> What could be the issue here?
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> As the v.net man page states: "While the arcs created with v.net
>> will retain any attribute information associated with the input
>> vector line/boundary file in data layer 1, nodes created and stored
>> in data layer 2 will not have any associated attribute information."
>> 
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> You have two options:
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> 1) Find out what to the category number of the point is that has
>> ROUND=0 and use that as from_cats, and all the others as to_cats.
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> This could be done with v.db.select using columns=cat (assuming the
>> column containing the cat values is called 'cat') and where=ROUND=0.
>> 
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> 2) Connect the attribute table of your original point map to the
>> point layer of the connected network map using v.db.connect and the
>> use the from_where and to_where parameters as you did.
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> If any of that is not clear, don't hesitate to come back to us.
>> 
>>> 
>> 
>>> 
>> 
>>> 
>> 
>>> Moritz
>> 
>>> 
>> 
>>> 
>> 
>>> DISCLAIMER: This email (and attachments) is for the intended
>> recipient only and may contain privileged, confidential or copyright
>> information. If received in error, please notify sender immediately
>> and delete. Any other use is prohibited. Shire accepts no liability
>> for damage caused by this email (and attachments) due to viruses,
>> corruption, delay, interruption, unauthorised access or use. Views
>> expressed are those of the individual and not necessarily Shire.
>> Shire will only collect personal information from you with your
>> prior consent, use it for the purpose collected or as reasonably
>> expected and not disclose without consent, except if required by
>> law/regulation. For further information see our privacy policy:
>> 
>>> [Arrow]
>> 
> mornpen.vic.gov.au/privacystatement<https://www.mornpen.vic.gov.au/privacystatement
>> [3]>
>> 
>>> 
>> 
>>> [Consider the Environment]
>> 
>> DISCLAIMER: This email (and attachments) is for the intended
>> recipient only and may contain privileged, confidential or copyright
>> information. If received in error, please notify sender immediately
>> and delete. Any other use is prohibited. Shire accepts no liability
>> for damage caused by this email (and attachments) due to viruses,
>> corruption, delay, interruption, unauthorised access or use. Views
>> expressed are those of the individual and not necessarily Shire.
>> Shire will only collect personal information from you with your
>> prior consent, use it for the purpose collected or as reasonably
>> expected and not disclose without consent, except if required by
>> law/regulation. For further information see our privacy policy:
>> mornpen.vic.gov.au/privacystatement [3]
> 
>  DISCLAIMER: This email (and attachments) is for the intended
> recipient only and may contain privileged, confidential or copyright
> information. If received in error, please notify sender immediately
> and delete. Any other use is prohibited. Shire accepts no liability
> for damage caused by this email (and attachments) due to viruses,
> corruption, delay, interruption, unauthorised access or use. Views
> expressed are those of the individual and not necessarily Shire. Shire
> will only collect personal information from you with your prior
> consent, use it for the purpose collected or as reasonably expected
> and not disclose without consent, except if required by
> law/regulation. For further information see our privacy policy:
>  mornpen.vic.gov.au/privacystatement [3]
> 
>  DISCLAIMER: This email (and attachments) is for the intended
> recipient only and may contain privileged, confidential or copyright
> information. If received in error, please notify sender immediately
> and delete. Any other use is prohibited. Shire accepts no liability
> for damage caused by this email (and attachments) due to viruses,
> corruption, delay, interruption, unauthorised access or use. Views
> expressed are those of the individual and not necessarily Shire. Shire
> will only collect personal information from you with your prior
> consent, use it for the purpose collected or as reasonably expected
> and not disclose without consent, except if required by
> law/regulation. For further information see our privacy policy:
>  mornpen.vic.gov.au/privacystatement [3]
> 
> 
> 
> Links:
> ------
> [1] http://www.mornpen.vic.gov.au
> [2] cid:image001.png at 01D7E05F.93540130
> [3] https://www.mornpen.vic.gov.au/privacystatement
> [4] https://www.mornpen.vic.gov.au
> [5] https://www.facebook.com/mornpenshire
> [6] https://www.instagram.com/ourpeninsula/
> [7] http://twitter.com/MornPenShire
> [8] https://www.mornpen.vic.gov.au/emailcampaign
> [9] https://www.mornpen.vic.gov.au/
> [10] 
> https://lists.osgeo.org/pipermail/grass-user/2021-December/082742.html



More information about the grass-user mailing list