Skip to main content

Quality Gate Status Analytics Downloads

Welcome to UrbanPy :city_sunrise:

A library to download, process and visualize high resolution urban data in an easy and fast way.

UrbanPy is an open source project to automate data extraction, measurement, and visualization of urban accessibility metrics.

Functional goals

  • Download open source spatial data (Limits & Points of Interests)
  • Allow for the use of a grid system or administrative boundaries as spatial units.
  • Origin-destination matrix calculation by any mode using a routing API
  • Obtain travel time from spatial units to the closest facilities
  • Consolidate the results as tables and/or shapefiles (georeferenced datasets)
  • Visualise the results as maps

UX goals

  • Atomic functions (one purpose per function)
  • Use the power of Python Geospatial Ecosystem under the hood
  • Allow to flexible processing pipelines (custom layer/metrics aggregations)
  • Clear documentation with usage and examples
  • Clear and replicable example notebooks

Main modules

  • download: Main functions for data download from Nominatin API, OverPass API and HDX population data
  • geom: Spatial operations, grid partitioning, spatial filtering and street network statistics
  • plotting: Visualization wrappers for plotly interactive choropleth maps
  • routing: Distance matrix computations (may require your own API keys)
  • utils: Data handling helpers

Installation

For users

To install the urbanpy library you can use:

$ pip install urbanpy

Then use import urbanpy in your python scripts to use the library.

If you plan to use the OSRM Server route or distance matrix calculation functionalities* you must have Docker installed in your system, refer to Docker Installation.

Additional Dependecies Notes

  • It is important to note that for travel time computation, if needed, a method is implements the Open Source Routing Machine (OSRM). This method pulls, extracts and adds graph weights to the downloaded network and runs the routing server. Make sure to have docker installed for the library to work correctly.

  • Urbanpy provides a simple approximation with nearest neighbor search using a BallTree and haversine distance, but the difference between real travel time and the approximation may vary from city to city.

  • Additionally, the use of spatial libraries like osmnx, geopandas and h3 require certain extra packages. Specifically, for rtree (spatial indexing to allow spatial joins) libspatialindex is required. OSMnx and Geopandas requiere GDAL as well. If not handled by installing geopandas's dependencies, installing fiona, pyproj and shapely should satisfy the requirements. Another way to ensure all dependencies are met, installing osmnx via conda should suffice. H3 requires cc, make, and cmake in your $PATH when installing, otherwise installation will not be successful. Please refer to h3's documentation for a more detailed guide on installation options and requirements.

Examples

UrbanPy lets you download and visualize city boundaries extremely easy:

import urbanpy as up

boundaries = up.download.nominatim_osm('Lima, Peru', expected_position=2)
boundaries.plot()

Since boundaries is a GeoDataFrame it can be easily plotted with the method .plot(). You can also generate hexagons to fill the city boundaries in a oneliner.

hexs, hexs_centroids = up.geom.gen_hexagons(resolution=9, city=boundaries)

Also check our example notebooks, and if you have examples or visualizations of your own, we encourage you to share contribute.

For developers

If you plan to contribute or customize urbanpy first clone this repo and cd into it. Then, we strongly recommend you to create a virtual environment. You can use conda, this installation manage some complicated C spatial library dependencies:

$ conda env create -n urbanpy -f environment.yml python=3.6
$ conda activate urbanpy

Or if you are more confident about your setup, you can use pip:

$ python3 -m venv .env
$ source .env/bin/activate
(.env) $ pip install -r requirements.txt

License

Copyright © 2020. Banco Interamericano de Desarrollo ("BID"). Uso autorizado. AM-331-A3

Authors

UrbanPy's original authors are Claudio Ortega (socials), Andrés Regal (socials), and Antonio Vazquez Brust (socials).

Contribution guidelines

If you want to contribute to UrbanPy, be sure to review the contribution guidelines. This project adheres to UrbanPy's code of conduct. By participating, you are expected to uphold this code.

*Current support is tested on Linux Ubuntu 18.04 & Mac OS Catalina, coming soon we will test and support Windows 10.

Metadata

Release files for urbanpy 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for urbanpy 0.2.1
File Size Uploaded
urbanpy-0.2.1.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for urbanpy 0.2.1
File Interpreter ABI Platform
urbanpy-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 60.9 kB

Release files / urbanpy-0.2.1.tar.gz

Download URL urbanpy-0.2.1.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
691e0cb47a983853d5c7f80e95e5cf9f9ac4e90c43acebb74e2ad16b7a7e2038
BLAKE2b-256 checksum
How to use checksums
2bf8431149ccb47bd60d2b162f26c5944750f06ab51789ea454e0ce8cc7fd624
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

Release files / urbanpy-0.2.1-py3-none-any.whl

Download URL urbanpy-0.2.1-py3-none-any.whl
Size 32.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c05002f13a01a17311fd51e63fcf284342b8b9f47b58385ae5df9dd0261470d3
BLAKE2b-256 checksum
How to use checksums
d0c475be8630e2b033e8e843c9507dbd9605579d97c0befe0abb2caf2cb178fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page