geocompy

Geocomputation with Python: an open source book

https://github.com/geocompx/geocompy

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    4 of 16 committers (25.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.7%) to scientific vocabulary

Keywords

book geo geocomputation geocompx geopython python spatial

Keywords from Contributors

overpass-api routing street-networks transportation
Last synced: 4 months ago · JSON representation ·

Repository

Geocomputation with Python: an open source book

Basic Info
  • Host: GitHub
  • Owner: geocompx
  • License: other
  • Language: Python
  • Default Branch: main
  • Homepage: https://py.geocompx.org/
  • Size: 359 MB
Statistics
  • Stars: 403
  • Watchers: 13
  • Forks: 87
  • Open Issues: 3
  • Releases: 3
Topics
book geo geocomputation geocompx geopython python spatial
Created almost 4 years ago · Last pushed 6 months ago
Metadata Files
Readme License Code of conduct Citation

README.md

geocompy

Render <!-- Binder --> Open in GitHub
Codespaces

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:

  1. Python dependencies, which can be installed with pip, a package manager or a Docker container (see below)
  2. 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
  3. 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.

Open in GitHub
Codespaces

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:

  1. Install Microsoft’s official Dev Container extension
  2. 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: ``` sh # 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`](https://fosstodon.org/deck/@hugovk@mastodon.social/111311327842154267) prefix specifying the Python version): ``` sh # Install dependencies from the requirements.txt file python -m pip install -r requirements.txt ``` You can also install packages individually, e.g.: ``` sh pip install jupyter-book ``` Deactivate the virtual environment when you’re done: ``` sh deactivate ```

Install dependencies with a package manager

The [`environment.yml`](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](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html) but should work for any package manager. ``` bash # 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: ``` bash micromamba env create -f environment.yml ``` Activate the environment as follows: ``` bash micromamba activate geocompy ``` Install kernel, this will allow you to select the environment in vscode or IPython as follows: ``` bash python -m ipykernel install --user ``` You can now reproduce the book (requires quarto to be installed): ``` bash 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: ``` sh cd ipynb # jupyter notebook . # open a notebook showing all chapters jupyter notebook 02-spatial-data.ipynb ``` You should see something like this: ![](https://user-images.githubusercontent.com/1825120/176920562-d2e7f9af-84b4-4352-8a50-9d9946084c66.png) See documentation on running and developing Python code in a Jupyter notebook at [docs.jupyter.org](https://docs.jupyter.org/en/latest/).

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](code) and [ipynb](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: ``` bash 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: ``` bash ./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: ``` bash 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](environment.yml) and [requirements.txt](requirements.txt) files to ensure reproducibility. To update the `requirements.txt` run the following: ``` bash 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: ``` bash micromamba list export > environment.yml ```

Owner

  • Name: geocompx
  • Login: geocompx
  • Kind: organization

The geocompx project is a community-driven effort to provide resources for learning and teaching about geocomputation in multiple programming languages.

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}
}

GitHub Events

Total
  • Create event: 2
  • Release event: 1
  • Issues event: 10
  • Watch event: 103
  • Delete event: 2
  • Issue comment event: 18
  • Push event: 25
  • Pull request review event: 4
  • Pull request review comment event: 1
  • Pull request event: 4
  • Fork event: 32
Last Year
  • Create event: 2
  • Release event: 1
  • Issues event: 10
  • Watch event: 103
  • Delete event: 2
  • Issue comment event: 18
  • Push event: 25
  • Pull request review event: 4
  • Pull request review comment event: 1
  • Pull request event: 4
  • Fork event: 32

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,268
  • Total Committers: 16
  • Avg Commits per committer: 79.25
  • Development Distribution Score (DDS): 0.483
Past Year
  • Commits: 89
  • Committers: 6
  • Avg Commits per committer: 14.833
  • Development Distribution Score (DDS): 0.596
Top Committers
Name Email Commits
Michael Dorman d****n@p****l 655
Robin Lovelace r****x@g****m 340
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

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 87
  • Total pull requests: 80
  • Average time to close issues: 5 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 15
  • Total pull request authors: 12
  • Average comments per issue: 4.28
  • Average comments per pull request: 1.38
  • Merged pull requests: 71
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 18
  • Pull requests: 25
  • Average time to close issues: 4 days
  • Average time to close pull requests: about 22 hours
  • Issue authors: 10
  • Pull request authors: 6
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.6
  • Merged pull requests: 21
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Robinlovelace (34)
  • michaeldorman (21)
  • Nowosad (13)
  • anitagraser (8)
  • lwasser (1)
  • anisotropi4 (1)
  • zehuiyin (1)
  • Rapsodia86 (1)
  • chrisjkuch (1)
  • ausdpy (1)
  • martinfleis (1)
  • felixcremer (1)
  • shriv (1)
  • benz0li (1)
  • jeromemaiquez (1)
Pull Request Authors
  • michaeldorman (33)
  • Robinlovelace (26)
  • anitagraser (4)
  • Nowosad (4)
  • anisotropi4 (2)
  • asinghvi17 (2)
  • smkerr (2)
  • Jakidxav (2)
  • sacridini (2)
  • JoshCole-DTA (1)
  • sgillies (1)
  • jtmiclat (1)
Top Labels
Issue Labels
enhancement (6) waiting (3) question (3) help wanted (2) future ideas (1) documentation (1)
Pull Request Labels

Dependencies

.github/workflows/convert.yml actions
  • actions/checkout v2 composite
.github/workflows/main.yaml actions
  • actions/checkout v3 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/netlify.yml actions
  • actions/checkout v3 composite
  • nwtgck/actions-netlify v1.2 composite
.github/workflows/pr.yml actions
  • actions/checkout v2 composite
requirements.txt pypi
  • 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
.github/workflows/upstream.yml actions
  • actions/checkout v2 composite
.github/workflows/prep-book-package.yml actions
  • actions/checkout v2 composite
environment.yml conda
  • 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