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.1.1 is successfully published to production PyPI:

python -m pip install fastpgv==0.1.1

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.1.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 fastpgv 0.1.1
File Size Uploaded
fastpgv-0.1.1.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastpgv 0.1.1
File Interpreter ABI Platform
fastpgv-0.1.1-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.1.1.tar.gz

Download URL fastpgv-0.1.1.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a30dee68f1c94f82b6f8b87aa4a61fea25d2837fd63dcae686cba06abebfd878
BLAKE2b-256 checksum
How to use checksums
7db049f0a62b7196cde55325eca92b32a72ca85d28212fe2a19474d6a2f790b6
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.1.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL fastpgv-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Size 95.2 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1c18fc6671c83787f970c14d12efb3c18158d1eb01faa20a3a0de63654fe8fca
BLAKE2b-256 checksum
How to use checksums
74119eabcc993344fcdb857b187d06fa8c22b0f981d602ac96373652d30a4891
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

0.2

2 release files

This release

0.1.1 This release

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