Skip to content

Commit e45afe7

Browse files
committed
add gis examples
1 parent 0f8dccd commit e45afe7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4948
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ target/
7676
.mypy_cache/
7777
.dmypy.json
7878
dmypy.json
79+
80+
# Virtual environment
81+
venv/

gis/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# GIS Examples
2+
3+
## Vector Data
4+
5+
- [GeoSchelling Model (Polygons)](https://github.com/projectmesa/mesa-examples/tree/main/gis/geo_schelling)
6+
- [GeoSchelling Model (Points & Polygons)](https://github.com/projectmesa/mesa-examples/tree/main/gis/geo_schelling_points)
7+
- [GeoSIR Epidemics Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/geo_sir)
8+
- [Agents and Networks Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/agents_and_networks)
9+
10+
## Raster Data
11+
12+
- [Rainfall Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/rainfall)
13+
- [Urban Growth Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/urban_growth)
14+
15+
## Raster and Vector Data Overlay
16+
17+
- [Population Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/population)

gis/agents_and_networks/.gitignore

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
8+
# Distribution / packaging
9+
.Python
10+
env/
11+
venv/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*.cover
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Django stuff:
52+
*.log
53+
54+
# Sphinx documentation
55+
docs/_build/
56+
57+
# PyBuilder
58+
target/
59+
60+
# DotEnv configuration
61+
.env
62+
63+
# Database
64+
*.db
65+
*.rdb
66+
67+
# Pycharm
68+
.idea
69+
70+
# VS Code
71+
.vscode/
72+
73+
# Spyder
74+
.spyproject/
75+
76+
# Jupyter NB Checkpoints
77+
.ipynb_checkpoints/
78+
79+
# exclude data from source control by default
80+
# /data/
81+
82+
# Mac OS-specific storage files
83+
.DS_Store
84+
85+
# vim
86+
*.swp
87+
*.swo
88+
89+
# Mypy cache
90+
.mypy_cache/
91+
92+
**/*.pkl

gis/agents_and_networks/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Agents and Networks Model
2+
=========================
3+
4+
[![](https://img.youtube.com/vi/zIRMNPTBESc/0.jpg)](https://www.youtube.com/watch?v=zIRMNPTBESc)
5+
6+
## Summary
7+
8+
This is an implementation of the [GMU-Social Model](https://github.com/abmgis/abmgis/blob/master/Chapter08-Networks/Models/GMU-Social/README.md) in Python, using [Mesa](https://github.com/projectmesa/mesa) and [Mesa-Geo](https://github.com/projectmesa/mesa-geo).
9+
10+
In this model, buildings are randomly assigned to agents as their home and work places, and the buildings' nearest road vertices are used as their entrances. Agents' commute routes can be found as the shortest path between entrances of their home and work places. These commute routes are segmented according to agents' walking speed. In this way, the movements of agents are constrained on the road network.
11+
12+
### GeoSpace
13+
14+
The GeoSpace contains multiple vector layers, including buildings, lakes, and a road network. More specifically, the road network is constructed from the polyline data and implemented by two underlying data structures: a topological network and a k-d tree. First, by treating road vertices as nodes and line segments as links, a topological network is created using the NetworkX and momepy libraries. NetworkX also provides several methods for shortest path computations (e.g., Dijkstra, A-star). Second, a k-d tree is built for all road vertices through the Scikit-learn library for the purpose of nearest vertex searches.
15+
16+
### GeoAgent
17+
18+
The commuters are the GeoAgents.
19+
20+
## How to run
21+
22+
First install the dependencies:
23+
24+
```bash
25+
python3 -m pip install -r requirements.txt
26+
```
27+
28+
Then run the model:
29+
30+
```bash
31+
python3 scripts/run.py --campus ub
32+
```
33+
34+
Change `ub` to `gmu` for a different campus map.
35+
36+
Open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press `Start`.
12.5 KB
Binary file not shown.
19.7 KB
Binary file not shown.
67.2 KB
Binary file not shown.
18 KB
Binary file not shown.
3.4 KB
Binary file not shown.
15 KB
Binary file not shown.

0 commit comments

Comments
 (0)