Skip to main content

Quadtree grid generator

Project description

Quadgrid

The quadgrid package provides a class and some convenience functions for generating quadtree-based grids at arbitrary resolutions in pandas, geopandas and xarray formats for use in geospatial analysis and catastrophe risk modelling.

Overview

Quadtree grids are a way of recursively partitioning a plane into nested quadrants, allowing for simple but efficient geocoding of points.

Some assumptions have been made to simplify the package:

  • all coordinates are in decimal degrees
  • all longitudes range from -180 to +180 degrees
  • the centre of the grid is at 0E, 0N

The package contains a single class, QuadGrid, which is used to generate grid objects. The class has methods to convert the grid into tabular (pandas DataFrame), vector (geopandas GeoDataFrame) and raster (xarray Dataset) formats which can be saved or used in further processing.

Individual quadcells at a given resolution are labelled with unique quadtreeIDs (qids). In the simplified example below, the red point is in top-level cell '2', then cell '2', then '0' then '3' giving a nominal qid of '2203'. In practice, quadtrees lend themselves to a base-4 encoding, allowing them to be stored and processed efficiently as integers.

image.png

Versions

0.2.0 Major refactor into object-oriented framework, and to make quadtreeID calculations robust against floating point rounding errors in edge cases

0.1.4 Fixed bug in quadgrids defined at a resolution coarser than 1 degree

0.1.3 Added resolution to DataFrame conversions; apply_mask can accept GeoDataFrames

0.1.2 Changed email address in pyproject.toml

0.1.1 Bug fix to ensure user-specified bounded grid is consistent with the global grid

0.1.0 First release

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

quadgrid-0.2.0.tar.gz (625.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quadgrid-0.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file quadgrid-0.2.0.tar.gz.

File metadata

  • Download URL: quadgrid-0.2.0.tar.gz
  • Upload date:
  • Size: 625.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for quadgrid-0.2.0.tar.gz
Algorithm Hash digest
SHA256 60258f9bb1e8eb90a28dc1d11ae2a856518d816e4c4c1c4aa9a9731c4400fd8e
MD5 85788d55362afaf3886c22a334185dba
BLAKE2b-256 66b8866f6de1333ef821a7756fea8bb17cc3df56c8f5a347d684f859c8969dfe

See more details on using hashes here.

File details

Details for the file quadgrid-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: quadgrid-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for quadgrid-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c56b89fcaa5b941402a5c44984faf125377131f361011ef24b92a5abfc6d96ff
MD5 6a6f99117bdac6fd112cc44b601d0314
BLAKE2b-256 b0f8d11ab0060908f12a05cf84fc566ae21705d571728d1519bf91d049682d3a

See more details on using hashes here.

Supported by

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