Skip to main content

Project Title

APPEL: A faster spatial join/reverse geocoding threaded algorithm

Getting Started

Spatial joins are like common relational database joins, just for geographic data. In general, we have a set of coordinates and we want to know which point is in which polygon, this operation is described as reverse geocoding. The algorithm relies on standard Point-In-Polygon operations but tends to minimize then.

APPEL proposes a new way to spatial joins that promises to be faster than than trivial brute force and R-Tree implementation of PostGIS and GeoPandas. For a million points it takes about 14 seconds to finish locating, while PostGIS takes about 7 minutes and GeoPandas takes 1 minutes and 7 seconds. All on the same machine.

To do so, the polygons to be searched are organized through a tree. The tree levels are predefined based on states, mesoregions, microregions and municipalities. In addition, it is considered that the geographic points provided by users are more likely to be located in more populated regions. Therefore, these areas are sorted to be the first to be found at each level of the tree.

Currently, the systems works only for Brazil territory and locates the cities of each point. But it's principle is extensible for any geographical region. You'll need just a shapefile (or equivalent) with each region and subregions population to build the data structure.

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Python 3.6
GeoPandas
Numpy
Shapely

Installing

A step by step series of examples that tell you how to get a development env running Just use pip.

pip install appel

By default, it comes with a tree for Brazil's regions.

To use, you must input the longitude and latitudes in the query function:

from numpy import array

from appel.searchtree import SearchTree

search = SearchTree()

longitudes = array([2.748047, -20.890625], dtype='float32')
latitudes = array([-63.03125, -49.53125], dtype='float32')
results = search.query(longitudes, latitudes)
print(results)

It will return a dataframe with latitudes longitudes and the city id.

Running the tests

Just run methods on the classes of test package.

Built With

  • GeoPandas - Essential for reading shapely files and build the search data structure.
  • Shapely - vectorized contains function is the core of the search algorithm.

Contributing

Currently I don't have a fixed system. Use issues for critics, help or any question in general.

Authors

License

This project is licensed under the GNU Affero General Public License - see the LICENSE.md file for details

Acknowledgments

Thanks PurpleBooth for this README.md template.

Metadata

Release files for appel-geocode 1.1.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 appel-geocode 1.1.0
File Size Uploaded Provenance
appel_geocode-1.1.0.tar.gz 5.1 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for appel-geocode 1.1.0
File Interpreter ABI Platform
appel_geocode-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.1 MB

Release files / appel_geocode-1.1.0.tar.gz

Download URL appel_geocode-1.1.0.tar.gz
Size 5.1 MB
Tags Source
SHA-256 checksum
How to use checksums
0caa3e6e0536b7f6eafacd85da404ce8858653647795e1b7ae544c28d87afefb
BLAKE2b-256 checksum
How to use checksums
64d7a0408de4dc25f4fb93b0a9289ddb6b148c5d61444615d56206ac9d482107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

Release files / appel_geocode-1.1.0-py3-none-any.whl

Download URL appel_geocode-1.1.0-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32655d3d7ee43e4fa6c905356b0548a4096a63546c6c86933d89598e39965980
BLAKE2b-256 checksum
How to use checksums
766059d3d11590d5fe174e9bee9decd5a666696aadf2568f0aa48c4c8dbc4efc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

Security for appel-geocode 1.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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