Skip to main content

Reverse geocoding from a shapefile of polygons.

How ?

The ReverseGeolocShapefile class improves the shapefile.Reader class by adding a intersection method to find polygons that intersects with a single point.

I use a simple spatial index that store the bounding box of each polygons. I save these informations into a .sidx.npy file next to the .dbf/.shp files.

Works with Python 3.6+ (I’m using f-string).

Documentation

The intersection method of the ReverseGeolocShapefile class return a list of row index.

Usage

import intersectshape

shp = intersectshape.ReverseGeolocShapefile('/path/of/shapefile.shp')

# You can use all methods of shapefile.Reader object like...
row = shp.record(5)
geo = shp.shape(2)

# Find polygons that intersects a point
x, y = 200, 500  # must be at the same projection system
ids = shp.intersection(x, y)
print(ids)
# return [] or [0, 5, 9, 7] for example.

License

This code are under the GNU GPL v3 licence.

Data of French communal polygons (Geofla shapefile located in the data folder) are under Etalab Open License.

Metadata

Release files for intersectshape 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 intersectshape 0.1.1
File Size Uploaded
intersectshape-0.1.1.tar.gz 15.3 kB Details

Release files / intersectshape-0.1.1.tar.gz

Download URL intersectshape-0.1.1.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d69677686e4f1e31f26668f36c3762d6a71662830322dbb2e4887133a4900e92
BLAKE2b-256 checksum
How to use checksums
0e6df7341c0da69547e85d80ef3e6a36edc10402d27ede8900b52bd0aad2330e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

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