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.
To install the urbanpy library you can use:
$ pip install urbanpy
import urbanpy in your python scripts to use the library.
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.
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()
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.
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
Copyright © 2020. Banco Interamericano de Desarrollo ("BID"). Uso autorizado. AM-331-A3
*Current support is tested on Linux Ubuntu 18.04 & Mac OS Catalina, coming soon we will test and support Windows 10.