Search code examples
dictionarygissimulationopenstreetmapanylogic

Anylogic - How to extract region & province data from a map using code


I'm a student using AnyLogic 7 University 7.3.6 for a simulation project.

In my project, I want to be able to distribute agents (people) over a geographical area (a city, specifically Stockholm, the capital of Sweden), and place them at imaginary "homes". I know that you can use openstreetmaps for loading maps into anylogic, and I want to able to realistically distribute people with different locations of that map.

What I wonder is:

is it possible to load a geographical map of a city from openStreetMaps or any other similar source, write code that can extract the different regions or municipalities in that geographical area, and save them as a collection?

My guess is that is is possible but difficult.

For example, Stockholm (capital of Sweden) consists of 26 municipalities. I want to be able to load a map of Stockholm, write code that can discover the name of the different municipalities within Stockholm (or whatever city map is being used), identify how many regions or municipalities there are in that map (26 in this case) and what their names are, save these to a collection, and then for each municipality, find all of the street names in that municipalitiy.

When I have all of the municipalities of a city along with all (or most) of the street names, I can then place my agents at different streets by using the street names.

I want to be able to place a different amount of agents (people) in each municipality, and they must not be placed at unrealistic locations (such as water or terrain), thus I reckon I need the street names, so that I can realistically place them at imaginary "homes".

I have not found any valuable information of this yet, but I'm trying to. If anyone has got any advice it would be greatly appreciated!


Solution

  • I have done something similar.

    To do this you need to create a shapefile that contains all the information you need (municipalities will be one layer of the shapefile (polygons) and streets will be the other layer (polylines) ) and you will read that shapefile with AnyLogic and you can generate random homes based on that.

    You need to find and expert in ArcGis to help you create the shapefile according to your needs. I'm not an expert in ArcGis, but I have had someone create shapefiles for me, so that would be the first step.

    Later (Second step) you will have to learn how to read shapefiles once you load them into the map in AnyLogic and transform the shapefile layers into areas and lines visible on the map... You start using the getLayers() function... You have to transform the shapefile into markup that is easily usable in AnyLogic.

    At the end of the day, your question requires a lot of things, so maybe this answer will point you into the right direction, make you quit the project or be useless... Or you can find a different and easier way to simplify your project without needing so much parafernalia.