Help with GIS extension

179 views
Skip to first unread message

vidus...@gmail.com

unread,
Feb 22, 2021, 2:59:09 AM2/22/21
to netlogo-users
Hi All 

I am trying to move my agents along the roads on a multi destination trip and want to calculate total distance travelled along the road drinng whole run. I am using Path finding model using the A-star algorithm in Netlogo - GMU_roads model https://github.com/YangZhouCSS/roads/ to get coding help to get roads shapefile in NetLogo and to make my agents move to multiple locations along the roads. 

I have a global variable called total-distance-travelled to store total travel distance in one year (= one run). However, my world is quite large (i.e. whole state) as compared to the world in the GMU model (roads withing a university campus). Therefore, I am getting runtime error "your model is too large ....". 

Can anyone suggest any other approch or example model that can help me. 

I thougt of having a patch variable roads? and assign the values using gis:intersecting but it gives me error (see below my code) 

extensions [gis]

globals [ roads-dataset total-distance-travelled ]

turtles-own
my-home               ; patch where turtle is generated randomly
previous-target     ; initialize as nobody updated as turtle moves i.e. next-target becomes                                       previous target after one movement 
next-target              ; turtle finds closest patch with sp-ric value > 0 as next-target 
distance-travelled  ; distance between previous-target and next-target

patches-own
roads?  ; True is patch intersects roads shapefile
sp-rich ; species richness at the patch randomly assigned between 0 to 9 
               (set sp-rich random 10) 

to setup-turtles
  create- turtles   number-of-turtles ; create turtles based on slider
  ask  turtles   [
  setxy random-xcor random-ycor
  set color white
  set shape "person"
  set previous-target nobody
  set my-home patch-here
  set pcolor brown
  ]
end

to  setup-roads
  set roads-dataset gis:load-dataset  "data/roads_WA.shp"
  gis:set-world-envelope ( gis:envelope-of  roads-dataset   )
  ifelse ( patch-set  gis:intersecting  roads-dataset  ) [set roads? true ] [ set roads? false ]  
end

to go

 if ticks > 365 [ stop]
 ask beekeepers [
 move
 calculate-distance
  ]
  tick
end

to move
  ask turtles [ 
    if [sp-rich ] of patch-here = 0
  [ 
 ifelse roads? = true
   [ fd 1] [ right 360  fd 1 ]
      move-to next-target
      set distance-travelled distance previous-target next-target 
  ] ]
end

to-report next-target
 if previous-target = nobody  [
    ask turtles [ set next-target min-one-of patches with [ sp-rich > 0] [distance myself] ] 
   ]
end


Highlighted part is not working. I am not sure why.

Not sure how to update total-distance-travelled. 
Also, if I want travel-distance calculated for each turtle seperately, total-distance-travelled should be a turtle variable rather than global right? 

I would truely appreciate any help with this part of coding. 

Thank you 

Kind Regards

Vidushi



Stephen Guerin

unread,
Feb 22, 2021, 3:46:22 AM2/22/21
to vidus...@gmail.com, netlogo-users
Re: the error in your line:


 ifelse ( patch-set  gis:intersecting  roads-dataset  ) [set roads? true ] [ set roads? false ]  

Note in the documentation for gis:intersecting, patch-set is in italics, which means you need to provide a patch-set in its place. eg, your statement could look like:

          ask patches gis:intersecting roads-dataset [set roads? true]

Instead of dealing with roads as patch variables, it might be better to deal with the road network as a collection of turtles and links like in Yang Zhou's model that you referenced. You will need some type of network representation to use their A* approach anyway. Also, for memory issues, note how the road network was simplified in their model to optimize performance.

-Stephen
_______________________________________________________________________
Stephen...@Simtable.com
CEO, Simtable  http://www.simtable.com
1600 Lena St #D1, Santa Fe, NM 87505
office: (505)995-0206 mobile: (505)577-5828
twitter: @simtable


--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/0a60aa87-b7aa-4659-ae7f-0a04ec4b206en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages