Skip to main content

fastpgv

fastpgv is a lightweight Python wrapper for fast density computation for Polygon-to-Grid Visualization (PGV).

This package provides an efficient way to compute density results through a simple Python interface. Compute a density value for every pixel from weighted polygons using the C++17 SLED (Sweep-Line Edge-Difference Aggregation) algorithm.

Features

  • One Python interface: fastpgv.run(weighted_polygons, resolution).
  • Weighted polygons with explicit vertex coordinates.
  • The polygons should be non-overlapping.
  • C++ computation backend with the Python interface.

Installation

From the fastpgv/ source directory:

python -m pip install .

After version 0.2 is successfully published to production PyPI:

python -m pip install fastpgv==0.2

Requirements

  • Python 3.10 or newer.
  • NumPy, installed automatically by pip.
  • A C++17 compiler for source builds. pip installs the Python build dependencies.

Quick Example

import fastpgv

# Polygons contain ordered vertex coordinates, not just identifiers.
polygon_a = {
    "type": "Polygon",
    "coordinates": [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]],
}
polygon_b = {
    "type": "Polygon",
    "coordinates": [[[1, 0], [2, 0], [2, 1], [1, 1], [1, 0]]],
}

density = fastpgv.run(
    [(polygon_a, 2.0), (polygon_b, 3.0)],
    resolution=(2, 1),
)
print(density)
# [[2. 3.]]

Inputs and Output

Both arguments are required:

Argument Meaning
weighted_polygons Nonempty iterable of (geometry, weight) pairs
resolution Positive integer (X, Y): columns and rows

Notes

  • Each pixel value is the sum of weight * polygon_pixel_intersection_area: weighted area, not area-normalized density.
  • Coordinates are planar, with no CRS transformation or geodesic calculation. Project geographic coordinates first when metric areas are required.
  • Supply valid polygon topology. Ring orientation is corrected, but invalid holes and self-intersections are not repaired. Empty input is rejected.
  • The complete output array requires 8 * X * Y bytes, plus polygon-edge and working storage. Choose a resolution that fits available memory.

License and Further Information

MIT licensed, by SLED contributors.

The source archive includes PUBLISHING.md (build and upload instructions), PORTING.md (implementation provenance), and THIRD_PARTY_NOTICES.md (dependency notices).

Release files for fastpgv 0.2

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

Source distribution (sdist)

Source distribution for fastpgv 0.2
File Size Uploaded
fastpgv-0.2.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastpgv 0.2
File Interpreter ABI Platform
fastpgv-0.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 110.9 kB

Release files / fastpgv-0.2.tar.gz

Download URL fastpgv-0.2.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
87514a1cf60cd857ef8426c043e2772f801ba6d3644aa729d5508b1699912cb0
BLAKE2b-256 checksum
How to use checksums
b35c1a733c35f268dfeeca1557f8d80f4508b0dedc22a9241fb71a54e75aefc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / fastpgv-0.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL fastpgv-0.2-cp312-cp312-macosx_11_0_arm64.whl
Size 95.1 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
175dad0d84d29ca2baa5d23c13cffc4171e22a00e2a88d3e7cbe64b4e40b6052
BLAKE2b-256 checksum
How to use checksums
ed48e041fc171471613b989b3f1968d3a0a2ed73f9a2e7f00fd5b1c991aa2f0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.2 This release

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