VectorFeature ? in a shapefile for a road network

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

VectorFeature ? in a shapefile for a road network

Sara Vicario
I am using this code to create my road network in Netlogo from a shapefile. However, I got an error in foreach gis:vertex-lists-of ? because ? is not recognised as VectorFeature in my VectorDataSet roads.
 How can I solve this issue?
 
 to make-road-network
  clear-links
  let first-node nobody
  let previous-node nobody
  foreach gis:feature-list-of roads [ ; each polyline
    foreach gis:vertex-lists-of ? [ ; each polyline segment / coordinate pair
      foreach ? [ ; each coordinate
        let location gis:location-of ?
        if not empty? location [ ; some coordinates are empty []
          create-nodes 1 [
            set color green
            set size 1
            set xcor item 0 location
            set ycor item 1 location
            set hidden? true
            if first-node = nobody [
              set first-node self
            ]
            if previous-node != nobody [
              create-link-with previous-node
            ]
            set previous-node self
          ]
        ]
      ]
      set previous-node nobody
    ]
  ]


end

Reply | Threaded
Open this post in threaded view
|

Re: VectorFeature ? in a shapefile for a road network

Czar Joseph Castillo
Hello, I had a similar problem before. This is how I created nodes in
netlogo from the vertices in my GIS shapefile.

-------------------------------------------------------------------------
extensions[gis]
globals [acad_oval]
breed [nodes node]

to setup
  clear-all
  ask patches [
    set pcolor white]
  gis:load-coordinate-system  "gisdata/acad oval.prj"
  set acad_oval gis:load-dataset "gisdata/acad oval.shp"
  gis:set-world-envelope (gis:envelope-of acad_oval)
  gis:set-drawing-color black gis:draw acad_oval 1
*  foreach gis:feature-list-of acad_oval [[vector-feature] -> *;for some
reason, this is a magic command that i do not understand. But it works. I
think this is the key to make this work.
    let location gis:location-of (first(first(gis:vertex-lists-of
vector-feature)))
   if not empty? location [
    create-nodes 1 [
     set xcor item 0 location
     set ycor item 1 location
     set shape "circle"
     set size 0.5
    ]]]

  ask node 92[
    create-link-to (node 136)
  ]
end
--------------------------------------------------------------------------------------------------------

On Tue, Apr 3, 2018 at 9:24 PM, [hidden email] [netlogo-users] <
[hidden email]> wrote:

>
>
> I am using this code to create my road network in Netlogo from a
> shapefile. However, I got an error in foreach gis:vertex-lists-of ?
> because *?* is not recognised as VectorFeature in my VectorDataSet *roads*
> .
>
> How can I solve this issue?
>
> to make-road-network
>   clear-links
>   let first-node nobody
>   let previous-node nobody
>   foreach gis:feature-list-of roads [ ; each polyline
>     foreach gis:vertex-lists-of ? [ ; each polyline segment / coordinate pair
>       foreach ? [ ; each coordinate
>         let location gis:location-of ?
>         if not empty? location [ ; some coordinates are empty []
>           create-nodes 1 [
>             set color green
>             set size 1
>             set xcor item 0 location
>             set ycor item 1 location
>             set hidden? true
>             if first-node = nobody [
>               set first-node self
>             ]
>             if previous-node != nobody [
>               create-link-with previous-node
>             ]
>             set previous-node self
>           ]
>         ]
>       ]
>       set previous-node nobody
>     ]
>   ]
>
>
> end
>
>
>
>