How do you make patches in netlogo take on the colors of an imported shapefile? - gis

'
fúè G¾‹ðÑRÀ#ÑOïC#-ºü*½RÀÆOÙ§D# H 1!Š´âÉRÀwš(yD#”Š¾6ìÈRÀIÊ;ŠãD# F 2©Ì®~ÉRÀ6ÓœÄD#›rǘsÉRÀ;=ºx·D#´µÉFbÉRÀü(I¿£D#}!YLKÉRÀ¬%”‰D#T-Bi#ÉRÀIë-}D#6j6ÉRÀ HQËqD#+f°’ÉRÀ²®‚9D#”Š¾6ìÈRÀí–[PD#ÁÀ–tîÈRÀ·cùB
D#X­#3ñÈRÀPYÈóíD#©³Î¶óÈRÀ| ¡_×D#}"ùÈRÀ¾…¥D#ܤG´þÈRÀ5µsD#oAÔÉRÀ ‚ŠWD#f¥Œ
ÉRÀaí&BD#®\¨ ÉRÀZ5šD#&Ùwo
ÉRÀMdÓ—ðD#à$_ÉRÀ:Ši©ÜD#ûÑPeÉRÀ9oæWÐD#ˆV2yÉRÀ€—ªÄªD##‚üÉRÀwš(yD#Ñ‹;°0ÉRÀÛ`õê~D#!°¾4ÉRÀab÷D#¦dµÒAÉRÀWÃ>ƒD#扺¾NÉRÀg+Ñš†D#ùl¼VÉRÀù½ˆD#á€%¸[ÉRÀøÁñ‰D#ù+‘hÉRÀl&7D#«x’U‚ÉRÀ꺔D#·÷›ÉRÀ$i„hšD#¸»ùp¬ÉRÀz8—KœD#^鮶ÉRÀê<`‡D#ùŸ/¸ÉRÀ›°D#ךÊÉRÀk–iËŸD#¨’ÒÖÈÉRÀ0¡8æÃD#·zÈÈÉRÀŒ2ÎÉD#&°Á(ÇÉRÀW4O9îD#Ë ‡EÆÉRÀî*æÑD#–"&ÄÉRÀÉÉŸ\7D#ÜæÏÔÂÉRÀ&1Ó•]D#€eX!ÃÉRÀÔ¨ÈíaD#¢â¤ÙÃÉRÀ»tøÀoD#ê)L±ÄÉRÀÑáü+zD#ÄÅÀÅÉRÀQB~D#¦½ÆÉRÀEöl.€D#ñ?J×ÉRÀÀÜ™±D#1!Š´âÉRÀá#h/ÔD#Þ$EÜÉRÀVŸSÙD#áÉ2ÕÉRÀ”ŸÀÛÞD#|98ÏÉRÀ$+Æ{ãD#´J¨ÇÉRÀX7zéD#ð˜¨ÖÀÉRÀ¼1šÎîD#£®ÃN¶ÉRÀ'á!÷D#Hnªk¸ÉRÀXð;ýD#¿RÏþ¶ÉRÀõLjíýD#µçдÉRÀ2eMÔýD#)€G¶³ÉRÀeÒãüD#p>Í°ÉRÀHúsD#…ÔÁ׬ÉRÀøÁÅ;D#/ 0éªÉRÀͶ`MD#½"U©ÉRÀ/Ïá^]D#Ê0W§ÉRÀñNnD#=Ö=o¥ÉRÀFÆp D#Á¬£ÉRÀAÿ!D#Ìñ6ç¡ÉRÀ§Þ D#WùŸÉRÀ–Fuì°D#¦çá?žÉRÀÊ\"ìÀD#x2ÐbÉRÀP·NQÉD#{ÈKšÉRÀIÊ;ŠãD#2©Ì®~ÉRÀ6ÓœÄD# È ï Ÿ±ìÀRÀ¢ö«D#CU‚Fc¿RÀb|ßlD# V Gp‰[ÀRÀü¬C*WD#1êwð¿RÀ’¬ô.AD#Æ$¼ë¿RÀ…¡³J<D#I]"(¦¿RÀLÈ!íD#T)C¢¿RÀ)XAÄèD#q¼ñœ¿RÀï̹ãD#ˆ´m¤–¿RÀôM#LßD#<¬dè¿RÀnÞ}"ÜD#Ã
KŠ¿RÀþÛ„ ÚD#š~lvƒ¿RÀƒ
ñ×D#î¬%|¿RÀxÓ«ÔD#¼pâ1x¿RÀØRðHÒD#„v¨t¿RÀbc<OÏD#U&‹q¿RÀ‹ŠM¯ÌD#›ÝU:n¿RÀ‘BÎcÉD#!õ4j¿RÀµsÿÃD#‹­3¶f¿RÀÅ&̾D#}Ȉd¿RÀr™£¶¼D#CU‚Fc¿RÀÎBc\»D#¬èȤg¿RÀÖàðµD#¿š+k¿RÀÃ2TÓ±D#÷2D½p¿RÀI™Ï·¬D#OÁØv¿RÀÀYãƨD#M2ñ…}¿RÀ†š¸ò£D#ÎxýE¿RÀówœD#û»£ãž¿RÀïêwÛ’D#«1Ö¼¸¿RÀI+¯˜…D#UZ}οRÀXþê€zD#­1iƒã¿RÀ Ê·yoD#›Â¿ö¿RÀ1ÿ]îdD#"
°;þ¿RÀë0È`D#KÀÞÀRÀ%é UD#NÍpcÀRÀÁŒ°SD#¢EØù0ÀRÀM¾´6+D#æÉЙNÀRÀŽY7ED#álÖñdÀRÀ?èO_àD#‚­ˆ#ÀRÀ~õ¹´D#ƒLL‰‚ÀRÀ)ö“²D#'}ÒƆÀRÀ¢ö«D#bä¤"‰ÀRÀ˜q^¹D#ʸ)§ˆÀRÀbmž¼D#RGa·ÀRÀ–®¿D#ÇYœ_‹ÀRÀ[þ]ÖD#(’À‹ÀRÀÛ^£ÚD#úSáÀRÀIÁäMÞD#K#¥ú–ÀRÀÆŠJ¾éD#ŒC¾6¦ÀRÀþµ{­ýD#BÉÔªÐÀRÀX’ý4D#út÷6ÒÀRÀFÆþ’8D#¬O×ÀRÀ×…‡æ?D#
QÛÀRÀ"¸4ÐBD#o$z+èÀRÀ·iÒÖSD#ï Ÿ±ìÀRÀH·:ÿYD##ÌJ#èÀRÀÆ°9BbD#KŒâÀRÀ ‚hælD#÷‡ÙwßÀRÀ`WviD#ßËîÚÀRÀ×Ƭ¯dD#* ÜñÖÀRÀñQåjaD#×ÎJÒÀRÀ=ñŽ{_D#&‘IÍÀRÀ;2‹^D#Sƃ—ÈÀRÀ?|C‚^D#T:ÑÄÀRÀeõ}_D#C,ÁÀRÀëú/Ü`D# ’Tn¾ÀRÀ­ùybD#ŠD~”¼ÀRÀ]yê0dD#dn¨³ÀRÀi¢PblD#—Ru§ÀRÀ•Ò»
xD#'I £ÀRÀû­-ÚzD#È—ÐÞÀRÀ½ôþ]}D#àÒä™ÀRÀ·ÅokD#‘Wn‘ÀRÀšLn‚D#
ö•ÀRÀ-Ly¨D#öŽ“æÀRÀ®Ñ,‹ªD#Ÿ‰ü¬ÀRÀ‰Âå|¬D#NBÒŠÀRÀ|ê®D#Õý,ˆÀRÀÂd+²D#¿ñ¶Ö„ÀRÀ¯>!®·D#ŽÙ ŸiÀRÀ>Ô" âD#zFÜ—\ÀRÀX/˜öD#dBÖÀOÀRÀ
0‹
Boundary of Philadlephia shp file I am successfully able to import a shapefile into Netlogo. Someone told me that my foreach loop that applies my shp GIS layer is only creating lines in the drawing layer of NetLogo, not actually changing the patches themselves. How do I assign some component of the shapefile to the patches themselves for turtles to be able to assess them?
My code is
to setup
clear-all
create-turtles 10
set-default-shape turtles "butterfly"
ask turtles [set size 25]
;if pxcor = min-pxcor [die]]
reset-ticks
let view gis:load-dataset "City_Plan_Boundary.shp"
gis:set-world-envelope gis:envelope-of view
foreach gis:feature-list-of view
[
gis:set-drawing-color green
gis:draw ? 1.0
]
end
thank you, ny help is appreciated. I am very new to netlogo.

Related

I can't moving the turtle

I'm just starting in netlogo to create an agent-based model. I've got 2 shapefiles, and I want to make my turtle move on my network map. For now I have only can managed to load the shapefiles in my model. Could someone give me an idea how to move the turtle on my network map?
Here is my code so far:
extensions [gis]
breed [cars car]
turtles-own [destination]
globals [
states-dataset
car-blue]
to custom-clear
reset-ticks
clear-turtles
clear-patches
clear-drawing
clear-all-plots
end
to setup
clear-all
custom-clear
ask patches [set pcolor green - 3]
set states-dataset gis:load-dataset "C:/Users/ADMIN/Documents/QGIS/Export Netlogo/Format .shp/state.shp"
gis:set-world-envelope gis:envelope-of states-dataset
gis:set-drawing-color yellow
gis:draw states-dataset 1
set route-car-blue gis:load-dataset "C:/Users/ADMIN/Desktop/routefiles/Shapefile/car/route-car-blue.shp"
gis:set-drawing-color blue
gis:draw angkot-permatabiru 1.5
foreach gis:feature-list-of route-car-blue
[car-pb -> let location gis:location-of gis:centroid-of car-pb
create-turtles 5 [
set xcor item 0 location
set ycor item 1 location
set shape "car"
set size 1
]]
end
to go
ask turtles [
let new-location one-of [link-neighbors] of destination
move-to new-location
set destination new-location]
tick
end
Does anybody know to fix my code? I want to make my turtle move based on my network map.
The problem is probably in the circularity of your destination and new-location. You define new-location as being a link-neighbor of your destination, but since you don't have a destination yet, this new-location is set to nobody. You then set your destination to be your new-location, which also sets destination to nobody, ending up in a circle where no movement is happening.
The fix for this would be to define a destination for each turtle during setup

Netlogo GIS: How can I create agents random location inside the specific region?

I have loaded shapfile and then I want to create turtles inside the map for simulating.
However, I use "gis:create-turtles-inside-polygon" then the agents just appear in same point. How can I put them in random places but inside the map?
with the following code
to setup-maps
gis:load-coordinate-system "dem.prj"
set Bangladesh gis:load-dataset "dem.shp"
set elevation gis:load-dataset "dem.asc"
gis:set-world-envelope gis:envelope-of elevation
gis:set-drawing-color red + 2
gis:draw Bangladesh 1
end
to setup-turtles
foreach gis:feature-list-of Bangladesh [ this-vector-feature ->
gis:create-turtles-inside-polygon this-vector-feature turtles 10 [
set shape "person"
set size 2.5
set color white
]
]
end
Are your shapefiles color coordinated? In which case you could make use of their color to determine where the turtles are placed.
A quick example of how I do this below. I save my map as an image first (PNG), and then use the import-pcolors function in NetLogo. That skips the need for the GIS extension.
to define-airplane-regions
ask patches with [pcolor = 14.9] [set namibia true] ask patches with [pcolor = 45.3] [set botswana true] end
to appear-aircrafts
if any? patches with [namibia = true][ ask one-of patches with [namibia = true] [sprout-aircrafts 3]] end
I have a tutorial on YouTube showing how to do this in more detail. All code in the video description.
https://youtu.be/VzvgBzO7ls0

How do you make the turtles follow only the green patches that I created from a shapefile Ioaded into netlogo?

This is my code so far. I only want the turtles to follow the green lines, however they just continue forever in the random direction they are facing when I setup the model.
Code:
extensions [gis]
breed [observer]
turtles-own [ vision-distance vision-width steps green-steps gray-steps attr-prob]
patches-own [land nearest-patch]
to setup
clear-all
create-turtles 10
set-default-shape turtles "butterfly"
ask turtles [set size 25
if pxcor = min-pxcor [die]]
reset-ticks
let view gis:load-dataset "City_Plan_Boundary.shp"
gis:set-world-envelope gis:envelope-of view
foreach gis:feature-list-of view
[
gis:set-drawing-color green
gis:draw ? 1.0
]
end
to go
ask turtles [
count-steps
pen-down
let green_target turtles
let perceived_patches patches in-cone vision-distance vision-width
let patch-under-me patch-here set green_target perceived_patches with [ (pcolor = green and self != patch-under-me) or (pcolor = black and self != patch-under-me)]
ifelse count green_target != 0 [
let target min-one-of green_target[ distance myself ]
let target_heading towards target
move-to patch-at-heading-and-distance target_heading 1 ]
[ fd 1]
]
end
to count-steps
set steps steps + 1
ifelse land = green [set green-steps green-steps + 1][set gray-steps gray-steps + 1] ;;Does not currently account for CYAN Park squares
end
First, your foreach loop that applies your GIS layer is only creating lines in the drawing layer of NetLogo, not actually changing the patches themselves. You'll have to assign some component of the shapefile to the patches themselves for turtles to be able to assess them- look at the "GIS General Examples" model in the Models Library.
Second, pathfinding can be accomplished in a variety of ways, and it really depends on what behaviour you're trying to model. For a few examples, check out the "Look Ahead" example in the Models library, or look at the below toy model for a very simplistic approach:
to setup
ca
ask patch min-pxcor 0 [
set pcolor green
sprout 1 [
set color red
pd
]
spread-right
]
reset-ticks
end
to spread-right
if pxcor < max-pxcor [
ask one-of neighbors with [ pxcor = [pxcor] of myself + 1] [
set pcolor green
spread-right
]
]
end
to go
ask turtles [
let target one-of neighbors in-cone 1.5 90 with [ pcolor = green ]
ifelse target != nobody [
face target
move-to target
] [
rt one-of [ 45 -45 ]
]
]
tick
end

How to Make a turtle Move within Polygons?

I am creating model in netlogo using GIS extension to read shapefiles. I have polygons representing a National Park and points representing lions. The points and park's polygon display without any problem. However, I want to create turtles from the points, that is where I get a problem. When I do that turtles change position. They are arranged in the same pattern but they spread and occupy the whole netlogo's world, as opposed to being a small cluster within the park.
extensions [gis]
globals [lion-dataset park-dataset]
to setup
ca
reset-ticks
;; import national park shapefile
set park-dataset gis:load-dataset "H:/college/reserve_lion.shp
gis:set-drawing-color green gis:fill park-dataset 2.0
;; read in turtle dataset and draw
set lion-dataset gis:load-dataset "H:/college/lion.shp
gis:set-drawing-color red gis:fill park-dataset 2.0
breed [lions lion]
;; creating the turtle from lion-dataset
foreach gis:feature-list-of lion-dataset
[ let location gis:location-of gis:centroid-of ?
if not empty? location
[ create-lions 1
[ set shape "person"
set size 1
set color red
set xcor gis:property-value ? " x_park"
set xcor gis:property-value ? " y_park"
show "world loaded"
end
to go
ask lions
[move]
tick
end
to move
fd 3
rt 3
end

NetLogo, how to hatch a turtle at a certain distance on Gis layers

My patches contain attributes such as elevation :
set mnt gis:load-dataset "F:/StageM2/Modelisation/Modele/mnt.asc"
gis:apply-raster mnt alt
gis:set-transformation (list 567887.504252 573503.504252 6183200.86463 6187628.86463) (list min-pxcor max-pxcor min-pycor max-pycor)
gis:set-world-envelope gis:envelope-of mnt
and turtles are created from raster of forest :
to import-foret93
set foret-93 gis:load-dataset "F:/StageM2/Modelisation/Modele/foret76_93.asc"
gis:apply-raster foret-93 f93
ask patches with [f93 = 1]
[
set pcolor black
set foret93? true
;ask n-of 2813 patches with [foret93? = true] [ hatch 2813 ]
sprout-arbres 1 [set color pink
set size 4]
]
end
The layers have the same spatial reference : RGF1993, so it is in meters.
Now, I want to create new turtles from existing turtles and randomly in a radius of 150m from the turtle (the new turtle can be hatch at 1m or at 130m). For instance, I ask just one turtle to hatch a turtle at a distance giving by an input box in the interface named dispersal-dist.
to disp-graines
ask turtle 2918
[
hatch-arbres 1
[
let seedX xcor
let seedY ycor
let ran-bear random 360
lt ran-bear
move-to one-of patches in-radius dispersal-dist
set color magenta
set size 15
]
]
end
But the created turtle go further then the dispersal distance giving in meters.
Did I forget something to transforme the netlogo scale in meters ? Or it is another problem?
Thank you in advance for your help !
While your raster dataset is expressed in meters in your case, your patches don't have a real world scale. Assuming your raster has square pixels, you can calculate a patch scale with something like:
let patch-scale (item 1 gis:world-envelope - item 0 gis:world-envelope ) / world-width
You could then use it in your existing code:
move-to one-of patches in-radius dispersal-dist / patch-scale
If your pixels in your raster have different real world height and width, you will have to do the patch-scale for the horizontal and vertical dimension separately.