Skip to main content

Geospatial queries powered by Boost Geom

Project description

Movici Geo Query is a library for creating geospatial indexes (rtrees) and querying those trees. It is targeted and optimized to work together with other Movici libaries. It works natively with numpy arrays, where multi-point geometries (such as linestrings and polygons) are accepted using Movici’s csr format.

Getting Started

import numpy as np
from movici_geo_query import GeoQuery, PointGeometry

points_a = PointGeometry(np.array([[0, 1], [0.5, 1]]))
points_b = PointGeometry(np.array([[0.6, 0.9]]))

gq = GeoQuery(points_a)


result = gq.nearest_to(points_b)

# for each point in point_b, gq.nearest returns the index of the nearest point in points_a. The
# result will have the same length as points_b and contains indexes to the points_a array

print(result.indices) # np.array([1])

Installation

Movici Geo Query binary wheels are currently available for Linux (manylinux) and Windows. There are currently no concrete plans for Mac builds. If you’d like to have macos binaries, please create an issue for it. Installation can be done using pip install movici-geo-query

Building from source

Building from source requires a C compiler that supports C++17, such as Clang>=5. To build movici-geo-query from source you also need a version of Boost.geometry that contains the boost::geometry::index::rtree headers (eg. boost > 1.74.0). These can be installed using your favorite package manager, downloaded from the Boost website, or taken directly from GitHub. When downloading manually, make sure the boost header files can be found by pip by placing them in pythons include directory:

BOOST_VERSION=1.79.0
INCLUDE_DIR=$(python3 -c "import sysconfig as sc; print(sc.get_paths()['include'])")
TMP_DIR=/tmp/boost_geometry
mkdir -p ${TMP_DIR}
git clone --depth 1 --branch boost-${BOOST_VERSION} https://github.com/boostorg/geometry.git ${TMP_DIR}
cp ${TMP_DIR}/include/boost ${INCLUDE_DIR}

Now you can clone, compile and install from source:

git clone https://github.com/nginfra/movici-geo-query.git
pip3 install movici-geo-query/

To specify a compiler, use the CC environment variable:

CC=g++7 pip install movici-geo-query/

Developing Movici Geo Query

Developing Movici Geo Query assumes you’re developing on Linux using a modern C++ compiler that support C++17, such as Clang>=5. We have tests both in C++ and in Python. Supported Python versions are 3.8 and higher. It also requires Boost.geometry (see Building from source)

# install the dev requirements
pip3 install -r requirements-dev.txt

# install the package in editable mode
pip3 install -e -v .

# run the c test suite
mkdir build
cd build
cmake ..
make -j
./test
cd ..

# run the python test suite
pytest tests/python

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

movici-geo-query-1.2.0.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distributions

movici_geo_query-1.2.0-cp311-cp311-win_amd64.whl (350.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

movici_geo_query-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

movici_geo_query-1.2.0-cp310-cp310-win_amd64.whl (350.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

movici_geo_query-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

movici_geo_query-1.2.0-cp39-cp39-win_amd64.whl (350.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

movici_geo_query-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (664.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

movici_geo_query-1.2.0-cp38-cp38-win_amd64.whl (350.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

movici_geo_query-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (663.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ 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