Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ target/
.mypy_cache/
.dmypy.json
dmypy.json

# Virtual environment
venv/
17 changes: 17 additions & 0 deletions gis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# GIS Examples

## Vector Data

- [GeoSchelling Model (Polygons)](https://github.com/projectmesa/mesa-examples/tree/main/gis/geo_schelling)
- [GeoSchelling Model (Points & Polygons)](https://github.com/projectmesa/mesa-examples/tree/main/gis/geo_schelling_points)
- [GeoSIR Epidemics Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/geo_sir)
- [Agents and Networks Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/agents_and_networks)

## Raster Data

- [Rainfall Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/rainfall)
- [Urban Growth Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/urban_growth)

## Raster and Vector Data Overlay

- [Population Model](https://github.com/projectmesa/mesa-examples/tree/main/gis/population)
92 changes: 92 additions & 0 deletions gis/agents_and_networks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
venv/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# DotEnv configuration
.env

# Database
*.db
*.rdb

# Pycharm
.idea

# VS Code
.vscode/

# Spyder
.spyproject/

# Jupyter NB Checkpoints
.ipynb_checkpoints/

# exclude data from source control by default
# /data/

# Mac OS-specific storage files
.DS_Store

# vim
*.swp
*.swo

# Mypy cache
.mypy_cache/

**/*.pkl
40 changes: 40 additions & 0 deletions gis/agents_and_networks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Agents and Networks Model
=========================

[![](https://img.youtube.com/vi/zIRMNPTBESc/0.jpg)](https://www.youtube.com/watch?v=zIRMNPTBESc)

## Summary

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).

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.

### GeoSpace

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.

### GeoAgent

The commuters are the GeoAgents.

## How to run

First install the dependencies:

```bash
python3 -m pip install -r requirements.txt
```

Then run the model:

```bash
python3 scripts/run.py --campus ub
```

Change `ub` to `gmu` for a different campus map.

Open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press `Start`.

## License

The data is from the [GMU-Social Model](https://github.com/abmgis/abmgis/blob/master/Chapter08-Networks/Models/GMU-Social/README.md) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).
Binary file added gis/agents_and_networks/data/gmu/Mason_Rds.zip
Binary file not shown.
Binary file added gis/agents_and_networks/data/gmu/Mason_bld.zip
Binary file not shown.
Binary file not shown.
Binary file added gis/agents_and_networks/data/gmu/hydrol.zip
Binary file not shown.
Binary file added gis/agents_and_networks/data/gmu/hydrop.zip
Binary file not shown.
Binary file added gis/agents_and_networks/data/ub/UB_Rds.zip
Binary file not shown.
Binary file added gis/agents_and_networks/data/ub/UB_bld.zip
Binary file not shown.
Binary file not shown.
Binary file added gis/agents_and_networks/data/ub/hydrol.zip
Binary file not shown.
Binary file added gis/agents_and_networks/data/ub/hydrop.zip
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading