Placing Agents in GIS Space 

In agent based models, GIS maps are often used as environment spaces. The environment type for such models is then a GIS space. A GIS space environment type enables you to place agents in a geospatial environment defined by a GIS map. With the GIS space type, you can also set and retrieve an agent’s current location, to move the agent with a specified speed from one location to another, execute an action when the agent arrives at a location, animate an agent at its location (no matter whether it is initially static or moving), establish connections among agents based on their locations, and perform other useful services.

The following video shows how to read agents' addresses/coordinates from the database and locate agents in the given points on the GIS map:

How-To video: Placing agents on the GIS map

Placing agents using search results

Using the search menu of the GIS Map shape, you can easily place an agent at a desired location on a GIS map. To do this, you first need to find a desired location, then you assign an agent to the location.

To create and place agents using search

  1. Open a model that contains one or more custom agent types that live in a GIS space.
  2. Double-click the GIS Map to enter its edit mode and search for a location on the map where you want to place an agent.
  3. Go to the GIS Search Results view, select the element you need from the list of search results, right-click it, and select the option Create agents at selected elements
  4. Under this option you will see a list of agent types. Choose the agent type that you would like to create at the selected location on the map.

  5. AnyLogic will automatically create an agent instance and place its animation in the selected location:

  6. You can select several search result elements and apply the action to all of them at once.

The option Create agents at selected elements is only available if there are custom agent types in the model.

To define the initial location for an agent 

  1. Let us assume you have some agent living in the GIS space. Select this agent in the graphical editor and go to its Properties view.
  2. Expand the Initial location section,and choose one of the following options from the Place agent(s) list of options:

Defining locations programmatically

With the following functions, you can programmatically define an agent’s initial location on a GIS map. These functions should be used only to initialize an agent’s location. They should not be used to move an agent.

There are three ways to programmatically define an agent’s initial location:

  1. You can put a GIS Point or GIS Region object on the map, and use its node as the agent’s location.
  2. You can place the agent at the location of another agent.
  3. You can define the location’s latitude and longitude.

void setLocation(INode node) - Puts the agent in the specified location: a GIS point or region. 
Parameter: node - name of the location

void setLocation(Point point) - Puts the agent in the specified GIS point. 
Parameter: point - name of the location

void setLocation(Agent agent) - Puts the agent into the location of another agent.

void setLatLon (double latitude, double longitude) - Sets the coordinates of the agent location. 
latitude - the latitude coordinate of the location measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
longitude - the longitude coordinate of the location measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

Sample model: Product Delivery

Related topics

 GIS Tutorial

Finding locations on the map

GIS markup objects

Movement in GIS space