Skip to main content

Python package for creating zoning systems

Project description

zonebuilder

The goal of zonebuilder is to break up large geographic regions such as cities into manageable zones. Zoning systems are important in many fields, including demographics, economy, health, and transport. The zones have standard configuration, which enabled comparability across cities. See its website at zonebuilders.github.io. Also checkout https://zonebuilders.github.io/zonebuilder-rust/ for visualization. This package provides the python bindings for zonebuilder-rust.

Usage

Installation

pip install zonebuilder

use with Python 3.6 and above.

Creating zones

The core function of this library is clockboard.

import zonebuilder
zones = zonebuilder.clockboard(center, kwargs) #eg. zonebuilder.clockboard([0,0])

## OPTIONS:
##      center, REQUIRED: a list with an x and y coordinate specifying the center of the region of interest
##      kwargs, OPTIONAL keyword arguments
##      distances = <distances>...
##             The distances between concentric rings. `zonebuilder.triangular_sequence` is useful to 
##             generate these distances [default: 1.0,3.0,6.0,10.0,15.0] given by triangular_sequence(5)
##      num-segments = <num-segments>
##             The number of radial segments. Defaults to 12, like the hours on a clock [default: 12]
##      num-vertices-arc = <num-vertices-arc>
##             The number of vertices per arc. Higher values approximate a circle more accurately [default: 10]
##      precision = <precision>
##             The number of decimal places in the resulting output GeoJSON files. Set to 6 by default. 
##             Larger numbers mean more precision, but larger file sizes [default: 6]
##      projected = <projected>
##             Boolean, is the data projected? [default: False]

which will return a stringified geojson object. You can load it into other python geo libraries as follows:

#geojson
import geojson
featurecollection = geojson.loads(zones)

#geopandas
import geopandas
geodataframe = geopandas.GeoDataFrame.from_features(featurecollection["features"])

Example

Executing clockboard([0,0]) will yield the 49 zones shown in the following figure centered on [0,0]: image info

Dev-notes

Installation

Steps to test the python bindings for zonebuilder-py

  1. Create a local virtual environment for python and activate it.
python -m venv env
source env/bin/activate
  1. Install necessary libraries into the environment
pip install -r dev-requirements.txt
  1. Develop the rust code into a python package and install it into the local environment
maturin develop

alternately you can also

pip install .
  1. Test it (somehow directly typing pytest throws error), use below
python -m pytest

Current functions

  1. triangular_sequence
  2. clockboard

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zonebuilder-1.0.1.tar.gz (62.6 kB view details)

Uploaded Source

Built Distribution

zonebuilder-1.0.1-cp38-cp38-macosx_10_7_x86_64.whl (281.7 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

File details

Details for the file zonebuilder-1.0.1.tar.gz.

File metadata

  • Download URL: zonebuilder-1.0.1.tar.gz
  • Upload date:
  • Size: 62.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for zonebuilder-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2091fd89741553337bdef59fbb6b656eebb7a38613ae043e50a0844de69b5b48
MD5 2e0fd085b4f813b4263bfdc570f92eff
BLAKE2b-256 f8abc4f99df8e13ad557be2d5d72be6feb2c0db7a7a4d4b868c4ef166b77753a

See more details on using hashes here.

File details

Details for the file zonebuilder-1.0.1-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: zonebuilder-1.0.1-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 281.7 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for zonebuilder-1.0.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ad3dde8877613478906c4ece323621e108ac80ee1af1305102746208182c5015
MD5 937bdaf1895f512476b042caa11b80c9
BLAKE2b-256 54b680026ba0c5989a0a45df25462dd72340b5c0b01fa16e7447bf57635aa36b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page