Skip to main content

Fast, memory-efficient 2D spatial indexes for Python.

Project description

geoindex-rs

Fast, memory-efficient 2D spatial indexes for Python.

API

KDTree

KDTree.from_interleaved

Construct an KDTree from a 2D numpy array of x and y. This must have two dimensions, with the second dimension having length two.

KDTree.from_separated

Construct an KDTree from two separated 1D numpy arrays of x and y. Each array must have one dimension and both arrays must have the same length.

KDTree.range

Search the index for items within a given bounding box.

Arguments:

  • min_x: float
  • min_y: float
  • max_x: float
  • max_y: float

Returns indices of found items

KDTree.within

Search the index for items within a given radius.

  • qx (float): x value of query point
  • qy (float): y value of query point
  • r (float): radius

Returns indices of found items

RTree

RTree.from_interleaved

Construct an RTree from a 2D numpy array of minx, miny, maxx, maxy. This must have two dimensions, with the second dimension having length four.

For example, the output of shapely.bounds is in this format.

import numpy as np
from geoindex_rs import RTree

geometries = shapely.polygons(...)
bounds = shapely.bounds(geometries)
tree = RTree.from_separated(bounds)

RTree.from_separated

Construct an RTree from four separate 1D numpy arrays of minx, miny, maxx, maxy. Each array must have one dimension and all arrays must have the same length.

import numpy as np
from geoindex_rs import RTree

minx = np.array([-10, ...], dtype=np.float64)
miny = np.array([-20, ...], dtype=np.float64)
maxx = np.array([10, ...], dtype=np.float64)
maxy = np.array([20, ...], dtype=np.float64)
tree = RTree.from_separated(minx, miny, maxx, maxy)

RTree.search

Search within an RTree for the given bounding box. Returns the indices of the input array that match the output.

tree = RTree.from_separated(...)
tree.search(minx, miny, maxx, maxy)

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

geoindex_rs-0.1.0.tar.gz (39.0 kB view hashes)

Uploaded Source

Built Distributions

geoindex_rs-0.1.0-cp38-abi3-win_amd64.whl (209.6 kB view hashes)

Uploaded CPython 3.8+ Windows x86-64

geoindex_rs-0.1.0-cp38-abi3-win32.whl (202.5 kB view hashes)

Uploaded CPython 3.8+ Windows x86

geoindex_rs-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

geoindex_rs-0.1.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.3 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ s390x

geoindex_rs-0.1.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64le

geoindex_rs-0.1.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.1 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

geoindex_rs-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

geoindex_rs-0.1.0-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.12+ i686

geoindex_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (329.8 kB view hashes)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

geoindex_rs-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl (341.8 kB view hashes)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

Supported by

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