问题
I need to create nodes from the cities shapefile of GIS general examples, so I can use them as targets for turtles. I tried the follows solutions but it doesn't work: http://netlogo-users.18673.x6.nabble.com/Creating-nodes-turtles-out-of-a-shp-file-and-linking-them-td5004359.html http://netlogoabm.blogspot.com/2015/07/loading-gis-and-csv-data-to-model-to-be.html#more
This is the code:
extensions [ gis ]
globals [ cities-dataset
countries-dataset ]
breed [ city-labels city-label ]
breed [ country-labels country-label ]
breed [ country-vertices country-vertex ]
to setup
clear-all
gis:load-coordinate-system (word "data/" projection ".prj")
set cities-dataset gis:load-dataset "data/cities.shp"
set countries-dataset gis:load-dataset "data/countries.shp"
gis:set-world-envelope (gis:envelope-union-of (gis:envelope-of cities-dataset)
(gis:envelope-of countries-dataset))
end
to display-cities
ask city-labels [ die ]
foreach gis:feature-list-of cities-dataset
[ gis:set-drawing-color blue
gis:fill ? 2.0
if label-cities
[ let location gis:location-of (first (first (gis:vertex-lists-of ?)))
if not empty? location
[ create-city-labels 1
[ set xcor item 0 location
set ycor item 1 location
set size 0
set label gis:property-value ? "NAME" ] ] ] ]
end
Could someone help me please ?
来源:https://stackoverflow.com/questions/33846864/creating-nodes-turtles-out-of-a-shp-file-from-gis-general-examples