I want to store in an empty list the coordenates of a patch based on its type of cultivation. For now i have and empty list called myland in which the agents store whats near them.
For example, I have tomato soy and cows, and a turtle in the middle. I have this.
ask locals [set myland [plantation] of patches in-radius 5 with [plantation != "Cows"]]
This brings me the list of patches that are for agriculture, but now i want to know where in that radius are those patches.
How would you do it?
The plan is to color those patches differently
I would suggest that you do not do that. That that way lies pain and madness.
Rather than storing the plantation string value in a list, store the patches themselves in an agentset. This will make everything else easier.
But first, remember that NetLogo is not strongly typed, and most values are immutable. This means that is doesn't matter was was in a variable before, when you assign a new value, the old value is replaced. So, it doesn't matter if you initialize a variable to an "empty list" if you then use 'set' to put something else there.
Now to your question.
If your intent is to color patches based on the value of a patch variable, it seems less efficient to ask turtles to find patches, and then color them
It would be simpler to just ask the patches to color themselves based on the plantation value.
Consider:
Let cow-color brown
Let wheat-color yellow
Let grass-color green
ask patches
[
Ifelse
( Plantation = "cows" )
[ Set pcolor cow-color ]
( Plantation = "wheat" )
[ Set pcolor wheat-color ]
;; Otherwise
[ Set pcolor grass-color ]
]
It's also worth noting that your sample code did not return a list of patches. It returned a list of strings, from the plantation variable.
But you had the right idea. It's usually better to store the patches or turtles themselves in an agentset. It usually makes everything else easier.
Your original example could be:
Ask locals
[
Set myland patches in-radius 5
;; Do all kinds of things with myland
]