Skip to main content

FastNSA Python

FastNSA is a native-accelerated Python toolkit for network-constrained spatial point analysis. It provides point-to-network mapping, network kernel density estimation (NKDE), network K-functions, and spatiotemporal network K-functions.

The package has two integration levels:

  • A lightweight array API based on NumPy and the native FastNSA library.
  • A geospatial API for GeoPandas, Shapely, NetworkX, and OSMnx workflows.

Installation

Python 3.11 or newer is required. Install the base NumPy/native runtime with:

python -m pip install fastnsa

Published binary wheels determine the supported operating systems, CPU architectures, and Python versions for each release. If no compatible wheel is available, pip may attempt a source build, which requires CMake and a C++17 compiler.

Install only the optional integrations you need:

python -m pip install "fastnsa[dataframe]"  # pandas exports
python -m pip install "fastnsa[xarray]"     # ST result DataArray exports
python -m pip install "fastnsa[geo]"        # GeoPandas and Shapely workflows
python -m pip install "fastnsa[osm]"        # NetworkX and OSMnx workflows
python -m pip install "fastnsa[viz]"        # Matplotlib visualizations
python -m pip install "fastnsa[all]"        # all optional integrations

Minimal Example

The bundled line dataset is useful for installation checks and examples. It does not require GeoPandas, NetworkX, or OSMnx.

import fastnsa as nsa

network = nsa.make_line_network(length=1000.0)
events = nsa.make_line_events(network, offsets=[100.0, 350.0, 700.0, 900.0])

result = nsa.network_k_function(
    network=network,
    points=events,
    r_values=[50.0, 100.0, 250.0],
    method=nsa.KFunctionMethod.STARS,
    simulations=5,
    random_state=2026,
)

print(result.to_records())
result.save_npz("network_k_result.npz")
restored = nsa.load_result("network_k_result.npz")

events.close()
network.close()

Native resources are context managers, so larger applications can use a deterministic lifecycle:

with nsa.make_line_network() as network:
    with nsa.make_line_events(network) as events:
        result = nsa.network_k_function(
            network=network,
            points=events,
            r_max=500.0,
            r_step=50.0,
        )

Geospatial Workflow

With the osm extra installed, a network can be downloaded through OSMnx and event files can be loaded through GeoPandas:

import fastnsa as nsa

network = nsa.Network.from_osm(place="Central Park, New York", network_type="drive")
points = nsa.load_points("events.gpkg", layer="events", time_col="event_time")
events = nsa.PointEvents(points, target_network=network, time_col="event_time")

k_result = nsa.network_k_function(
    network=network,
    points=events,
    r_min=0.0,
    r_max=2000.0,
    r_step=50.0,
    method=nsa.KFunctionMethod.STARS,
    simulations=99,
    envelope="global",
)

Use a projected coordinate reference system whose map units are metres for distance-based analyses. FastNSA does not interpret degree coordinates as geodesic distances.

Main Features

  • Point mapping with R-tree, exact comparison, and approximate comparison.
  • NKDE methods including ADA and LION with optional event weights.
  • Network K-function methods SPS, NS, and STARS.
  • Spatiotemporal methods RQS, SPS, EAR, MTS, and EARTH.
  • Pointwise or global Monte Carlo envelopes, reproducible seeds, and p-values.
  • CSV, pandas, NPZ, and optional xarray result exports.
  • Progress callbacks and cooperative cancellation for host applications.
  • Direct NumPy/native inputs for low-dependency QGIS and server integrations.

Documentation

License

FastNSA is licensed under GNU LGPL v2.1 only. Applications may dynamically link to the library under the LGPL terms. Modifications to the FastNSA library itself must remain available under the applicable LGPL requirements. See the packaged LICENSE file for the complete license text.

Metadata

Release files for fastnsa 0.3.0

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

Source distribution (sdist)

Source distribution for fastnsa 0.3.0
File Size Uploaded Provenance Actions
fastnsa-0.3.0.tar.gz 147.6 kB With provenance Details for fastnsa-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fastnsa 0.3.0
File Actions
fastnsa-0.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for fastnsa-0.3.0-py3-none-win_amd64.whl
fastnsa-0.3.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for fastnsa-0.3.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
fastnsa-0.3.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for fastnsa-0.3.0-py3-none-macosx_11_0_arm64.whl
fastnsa-0.3.0-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details for fastnsa-0.3.0-py3-none-macosx_10_9_x86_64.whl

Total release size: 823.2 kB

Release files / fastnsa-0.3.0.tar.gz

Download URL fastnsa-0.3.0.tar.gz
Size 147.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dc05039c1e36b40d7c7ec265d16364e93fb9e916ba17d461a3cc5d42fb3a09f2
BLAKE2b-256 checksum
How to use checksums
5e98712831cd104f8045abb3d5b8e953d9754070c130e7a92684385d8172132b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fastnsa-0.3.0-py3-none-win_amd64.whl

Download URL fastnsa-0.3.0-py3-none-win_amd64.whl
Size 174.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
1242a9c5d6ac7d6092ea5da6d908357ea4481b6593a9cd83e34e73c44ebd9802
BLAKE2b-256 checksum
How to use checksums
053f3ee0e04395fe593d46319172de9f5cd16504bea6c0183308ba308907e393
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fastnsa-0.3.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL fastnsa-0.3.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 170.4 kB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
1f4f9ccefe59d8903ad2b9f7485da3d297c35f297b5ad4a63246585b695c542c
BLAKE2b-256 checksum
How to use checksums
e5b0b560cbb1a3334d31cc10fe680edd98e70b662cc3ea8aba9a1b165ea7a5ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fastnsa-0.3.0-py3-none-macosx_11_0_arm64.whl

Download URL fastnsa-0.3.0-py3-none-macosx_11_0_arm64.whl
Size 155.4 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
625eff53e20078a657c0a371f1157ca2fdce238158542de5b8032575a6042622
BLAKE2b-256 checksum
How to use checksums
ba54d1fab87b113baa99f2fc53d5e8a49241db86b04f28b48e326ca74760a9af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fastnsa-0.3.0-py3-none-macosx_10_9_x86_64.whl

Download URL fastnsa-0.3.0-py3-none-macosx_10_9_x86_64.whl
Size 175.9 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
04e905d0d342a38bc58339bc2d8c6561e762bbcb4010ba592eab58537577bfcc
BLAKE2b-256 checksum
How to use checksums
23f05936f90a0ae919eacbcadd0a82da087547c29862e94d3e9375f7f550181c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for fastnsa 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for fastnsa-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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