0

I have placed agents of a population (from a database) on a point on the GIS map (following this tutorial: https://www.anylogic.com/resources/educational-videos/how-to-video-placing-agents-on-the-gis-map/). After that, I converted different regions from the GIS map. Now I want that every agent contains a parameter "region" corresponding to the region that it is located in. Does anyone know how to do this?

Edit: The Region is only needed to identify which GIS points are in the same region. So the parameter "region" can be an integer.

  • What do you refer with "region"? Is it the `GISRegion`? Else the easiest option is to add a parameter, or variable and just set it when the agent gets created. – Jaco-Ben Vosloo Aug 31 '21 at 20:03
  • Yes, I mean a GISRegion. I set the order location on a GIS point using the "this" function. But what is the function to select its corresponding region? – Bart wolker Sep 01 '21 at 07:49
  • I have edited the question. I hope it is more clear now. – Bart wolker Sep 01 '21 at 14:07

1 Answers1

0

Simplest option is to have a variable of type GISRegion in your agent and then on the on startup code of the agent you simply access the map and do a region search on the map saving the value to the variable

gisRegion = main.map.searchFirstRegion(address);

enter image description here

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
  • Hi Jaco, Thank you for the answer. I got it working the way you suggested. However, the automatically selected regions are often very small (cities). I would like to enlarge this region into provinces. Is it possible to select a larger region automatically or select a region out of a set of predefined (imported from the GIS maps) regions . – Bart wolker Sep 03 '21 at 08:52
  • If you want to use predefined regions you can always include them in the database data and then setup the agent using these values. Perhaps see if this question will assist you https://stackoverflow.com/questions/68707795/anylogic-use-arrival-table-and-a-parameter-database-together-in-one-source-bloc/68708035#68708035 – Jaco-Ben Vosloo Sep 03 '21 at 09:08