Geocomputation with Python
An open source book and online resource for getting started in this space with Python.
https://github.com/geocompx/geocompy
Category: Sustainable Development
Sub Category: Education
Keywords
book geo geocomputation geocompx geopython python spatial
Keywords from Contributors
routing gdal geospatial-data geography transportation spatial-data cycling reproducibility spatial-analysis overpass-api
Last synced: about 21 hours ago
JSON representation
Repository metadata
Geocomputation with Python: an open source book
- Host: GitHub
- URL: https://github.com/geocompx/geocompy
- Owner: geocompx
- License: other
- Created: 2022-01-13T10:35:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-11T14:32:16.000Z (17 days ago)
- Last Synced: 2025-04-21T07:02:01.797Z (7 days ago)
- Topics: book, geo, geocomputation, geocompx, geopython, python, spatial
- Language: Python
- Homepage: https://py.geocompx.org/
- Size: 358 MB
- Stars: 374
- Watchers: 13
- Forks: 79
- Open Issues: 3
- Releases: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.bib
README.md
geocompy
Geocomputation with Python is an open source book project that will be
published as a physical book. We are developing it in the open and
publishing an up-to-date online version at https://py.geocompx.org.
Dependencies
Running the code that is part of Geocomputation with Python (geocompy
for short) requires the following dependencies to be installed:
- Python dependencies, which can be installed with
pip
, a package manager or a
Docker container (see below) - An integrated development environment (IDE) such as VS
Code (running locally or on
Codespaces/other
host) or Jupyter
Notebook for
running and exploring the Python code interactively - Quarto, which is used to
generate the book
Reproduce the book with GitHub Codespaces
GitHub Codespaces minimise
set-up costs by providing access to a modern IDE (VS Code) plus
dependencies in your browser. This can save time on package
installation. Codespaces allow you to make and commit changes, providing
a way to test changes and contribute fixes in an instant.
To run the book in Codespaces, click on the link below.
You should see
something like this, the result of running all the code in the book by
opening the terminal (e.g. with the command Ctrl+J) and entering the
following command:
quarto preview
Reproduce the book with Docker (devcontainer)
If you can install Docker
this is likely to be the quickest way to reproduce the contents of this
book. To do this from within VS Code:
- Install Microsoft’s official Dev
Container
extension - Open the folder containing the repo in VS Code and click on the
‘Reopen in container’ button that should appear, as shown below (you
need to have Docker installed on your computer for this to work)
Edit the code in the containerised instance of VS Code that will appear
🎉
See details below for other ways to get the dependencies and reproduce
the book.
Install dependencies with pip
Use pip
to install the dependencies as follows, after cloning the repo
and opening a terminal in the root folder of the repo.
First we’ll set-up a virtual environment to install the dependencies in:
# Create a virtual environment called geocompy
python -m venv geocompy
# Activate the virtual environment
source geocompy/bin/activate
Then install the dependencies (with the optional
python -m
prefix specifying the Python version):
# Install dependencies from the requirements.txt file
python -m pip install -r requirements.txt
You can also install packages individually, e.g.:
pip install jupyter-book
Deactivate the virtual environment when you’re done:
deactivate
Install dependencies with a package manager
The environment.yml
file contains a list of
dependencies that can be installed with a package manager such as
conda
, mamba
or micromamba
. The instructions below are for
micromamba
but should work for any package manager.
# For Linux, the default shell is bash:
curl -L micro.mamba.pm/install.sh | bash
# For macOS, the default shell is zsh:
curl -L micro.mamba.pm/install.sh | zsh
After answering the questions, install dependencies with the following
command:
micromamba env create -f environment.yml
Activate the environment as follows:
micromamba activate geocompy
Install kernel, this will allow you to select the environment in vscode
or IPython as follows:
python -m ipykernel install --user
You can now reproduce the book (requires quarto to be installed):
micromamba run -n geocompy quarto preview
Reproduce chapters with jupyter
VS Code’s quarto.quarto
plugin can Python code in the chunks in the
.qmd files in this book interactively.
However, you can also run any of the chapters in a Jupyter Notebook,
e.g. as follows:
cd ipynb
# jupyter notebook . # open a notebook showing all chapters
jupyter notebook 02-spatial-data.ipynb
You should see something like this:
See documentation on running and developing Python code in a Jupyter
notebook at docs.jupyter.org.
Additional information
If you’re interested in how to auto-generate and run the .py and .ipynb
files from the .qmd files, see below.
Updating the .py and .ipynb files
The Python scripts and IPython notebook files stored in the code
and ipynb folders are generated from the .qmd files. To
regenerate them, you can use the following commands, to generate .ipynb
and .py files for local versions of Chapter 2, for example:
quarto convert 02-spatial-data.qmd # generate .ipynb file
jupytext --to py *.ipynb # generate .py files .ipynb files
Do this for all chapters with the following bash script in the repo:
./convert.sh
Updating .py and .ipynb files with GitHub Actions
We have set-up a GitHub Action to do this automatically: every commit
message that contains the text string ‘convert’ will create and push
updated .ipynb and .py files.
Executing the .py and .ipynb files
Running the code chunks in the .qmd files in an IDE such as VSCode or
directly with quarto is the main way code in this book is designed to be
run interactively, but you can also execute the .py and .ipynb files
directly. To run the code for chapter 2, for example, you can run one of
the following commands from your system shell:
python code/chapters/02-spatial-data.py # currently requires manual intervention to complete, see #71
ipython ipynb/02-spatial-data.ipynb # currently requires manual intervention to complete, see #71
bash ./run-code.sh # run all .python files
Updating packages
We pin package versions in the environment.yml and
requirements.txt files to ensure reproducibility.
To update the requirements.txt
run the following:
python -m pip install pur
pur -r requirements.txt
python -m pip install -r requirements.txt
To update the environment.yml
file in the same way based on your newly
installed packages, run the following:
micromamba list export > environment.yml
Citation (CITATION.bib)
@book{dorman_geocomputation_2025, title = {Geocomputation with {{Python}}}, isbn = {9781032460659}, abstract = {Book on geographic data with Python.}, publisher = {{CRC Press}}, author = {Dorman, Michael and Graser, Anita and Nowosad, Jakub and Lovelace, Robin}, year = {2025} }
Owner metadata
- Name: geocompx
- Login: geocompx
- Email:
- Kind: organization
- Description: The geocompx project is a community-driven effort to provide resources for learning and teaching about geocomputation in multiple programming languages.
- Website: https://geocompx.org/
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/108929306?v=4
- Repositories: 14
- Last ynced at: 2025-04-25T00:55:38.415Z
- Profile URL: https://github.com/geocompx
GitHub Events
Total
- Create event: 2
- Release event: 1
- Issues event: 8
- Watch event: 87
- Delete event: 1
- Issue comment event: 16
- Push event: 23
- Pull request review event: 3
- Pull request review comment event: 1
- Pull request event: 3
- Fork event: 27
Last Year
- Create event: 2
- Release event: 1
- Issues event: 8
- Watch event: 87
- Delete event: 1
- Issue comment event: 16
- Push event: 23
- Pull request review event: 3
- Pull request review comment event: 1
- Pull request event: 3
- Fork event: 27
Committers metadata
Last synced: 7 days ago
Total Commits: 1,267
Total Committers: 16
Avg Commits per committer: 79.188
Development Distribution Score (DDS): 0.483
Commits in past year: 156
Committers in past year: 7
Avg Commits per committer in past year: 22.286
Development Distribution Score (DDS) in past year: 0.455
Name | Commits | |
---|---|---|
Michael Dorman | d****n@p****l | 655 |
Robin Lovelace | r****x@g****m | 339 |
Jakub Nowosad | t****i@g****m | 180 |
github-actions | g****s@g****m | 51 |
anitagraser | a****r@g****t | 22 |
Will Deakin | w****n@c****k | 10 |
Anshul Singhvi | a****i@g****m | 1 |
Eduardo Lacerda | e****o@g****m | 1 |
Jakidxav | 3****v | 1 |
JoshCole-DTA | 1****A | 1 |
Jt Miclat | j****t@g****m | 1 |
Sean Gillies | s****s@g****m | 1 |
Steve Kerr | 5****r | 1 |
robinlovelace-ate | r****e@a****k | 1 |
Robin Lovelace | g****l@l****k | 1 |
Robin Lovelace | r****n@U****k | 1 |
Committer domains:
- uol-lap-300496.ds.leeds.ac.uk: 1
- leeds.ac.uk: 1
- activetravelengland.gov.uk: 1
- crinstitute.org.uk: 1
- gmx.at: 1
- github.com: 1
- post.bgu.ac.il: 1
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 141
Total pull requests: 109
Average time to close issues: 5 months
Average time to close pull requests: 7 days
Total issue authors: 14
Total pull request authors: 12
Average comments per issue: 4.87
Average comments per pull request: 1.65
Merged pull request: 103
Bot issues: 0
Bot pull requests: 0
Past year issues: 32
Past year pull requests: 18
Past year average time to close issues: about 1 month
Past year average time to close pull requests: 1 day
Past year issue authors: 9
Past year pull request authors: 7
Past year average comments per issue: 4.19
Past year average comments per pull request: 0.94
Past year merged pull request: 16
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- Robinlovelace (55)
- michaeldorman (30)
- Nowosad (27)
- anitagraser (14)
- lwasser (2)
- anisotropi4 (2)
- chrisjkuch (2)
- martinfleis (2)
- jeromemaiquez (2)
- zehuiyin (1)
- Rapsodia86 (1)
- felixcremer (1)
- shriv (1)
- benz0li (1)
Top Pull Request Authors
- michaeldorman (59)
- Robinlovelace (30)
- anitagraser (4)
- Nowosad (4)
- anisotropi4 (2)
- JoshCole-DTA (2)
- sgillies (2)
- jtmiclat (2)
- smkerr (1)
- asinghvi17 (1)
- Jakidxav (1)
- sacridini (1)
Top Issue Labels
- enhancement (11)
- waiting (7)
- question (4)
- help wanted (3)
- future ideas (2)
- documentation (2)
Top Pull Request Labels
Dependencies
- actions/checkout v2 composite
- actions/checkout v3 composite
- peaceiris/actions-gh-pages v3 composite
- actions/checkout v3 composite
- nwtgck/actions-netlify v1.2 composite
- actions/checkout v2 composite
- Cartopy ==0.22.0
- PyYAML ==6.0
- contextily ==1.3.0
- folium ==0.14.0
- geopandas ==0.12.2
- jupyter *
- mapclassify *
- matplotlib ==3.6.2
- numpy ==1.24.0
- osmnx ==1.6.0
- pandas ==1.5.2
- pyproj ==3.4.1
- rasterio ==1.3.4
- rasterstats ==0.17.0
- requests ==2.28.1
- scipy ==1.9.3
- shapely ==2.0.0
- topojson ==1.5
- xarray ==2022.12.0
- actions/checkout v2 composite
- actions/checkout v2 composite
- bokeh
- branca
- cartopy >=0.22
- contextily
- cython
- fiona >=1.9
- folium
- geopandas >=1.0.0
- geopy
- geoviews
- hvplot
- jupyter
- jupyterlab
- mapclassify
- matplotlib
- nbformat
- numpy
- osmnx
- pandas
- proj
- pyogrio
- quarto
- rasterio
- rasterstats
- richdem
- shapely
- topojson
Score: 8.704833909687792