Skip to main content

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

Release files for quadgrid 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 quadgrid 0.2.1
File Size Uploaded
quadgrid-0.2.1.tar.gz 624.6 kB Details

Built distribution (wheel)

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

Total release size: 635.1 kB

Release files / quadgrid-0.2.1.tar.gz

Download URL quadgrid-0.2.1.tar.gz
Size 624.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f62f3c563808e9bec915172af277703d5ea1e5b6a08341d98726d157a53eff42
BLAKE2b-256 checksum
How to use checksums
928169586282854adbe727a70b8c1cd7285c16a380367627684b74860434e44b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

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

Download URL quadgrid-0.2.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7cb42dcf45fcdc6623f2846ee54247c8d1cc8d5a6fe80813dc6b1b8a7b2ea19
BLAKE2b-256 checksum
How to use checksums
0cb5b523b18b3f19fbefc64c6c288a72a72145b61c0ac08d787b0eecb8f77c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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