Paulo Sergio
Paulo Sergio

Reputation: 39

Export world with turtles' coordinates

I am developing a model that loads an .asc topographic file to the view and then, I create some turtles and the model runs etc., etc..

I would like to know if it's possible to export the result of the simulation with turtle location into .asc or .csv. I have never done something like this so I really need help.

Thanks

Upvotes: 1

Views: 474

Answers (2)

Paulo Sergio
Paulo Sergio

Reputation: 39

To put @JenB 's answer in context this is the way I found to solve the problem:

`file-open "filename.csv" ask bees

[

file-type item 1 gis:envelope-of bee who
file-type ","
file-type item 3 gis:envelope-of bee who
file-type ","
file-type who
file-type ","
file-type tipo
file-type "\n"

] file-close`

This will create a csv type with the following format:

[latitude, longitude, number of the turtle, tipo (a turtle attribute)]

Upvotes: 0

JenB
JenB

Reputation: 17678

Look at the output programming guide in the NetLogo documentation (see ccl.northwestern.edu/netlogo/docs/programming.html#output). You want something like (not tested):

file-open "filename.csv"
ask turtles
[ file-type xcor filetype ", "
  file-type ycor filetype ", "
  file-print myvariablename
]
file-close

This will put each turtle's information on a separate line in the file, with the x-coordinate, y-coordinate and the value of the variable called myvariablename. A comma is between each.

The primitive you have found export-world saves everything, not just the information you want and not in csv format.

Upvotes: 3

Related Questions