Shape-Merge
A Python based GIS library for finding and merging all Geometries that intersects with their neighbour.
The library will iterate over all the geometries provided in the form of following Inputs,
and will look for the neighbours which forms an intersection relationship with its Parent
the geometry that looks for intersection is reffered as Parent
either through a direct intersection or an intersection link generated via multiple Child geometries which have a relationship associated with its Parent either as a direct neighbour or via mutiple neighbour is reffered to as a Child intersection.
Installation
pip install shape-merge
Requirements
The library uses Rtree which has a dependency on libspatialindex, It is recommend to resolving the dependency through libspatialindex conda
LibSpatialIndex For Linux:
$ sudo apt-get update -y
$ sudo apt-get install -y libspatialindex-dev
LibSpatialIndex For Windows:
Experience is pretty grim for Windows Installation, i used conda for trouble free installation.
Rtree
conda install -c conda-forge rtree
Fiona
conda install -c conda-forge fiona
Inputs
ShapeFile
from shape_merge.merge import ShapeMerge
shape_merge = ShapeMerge()
shape_merge.populate_index_by_fiona(r"path_to_shape_file.shp")
GeoJSON
from shape_merge.merge import ShapeMerge
shape_merge = ShapeMerge()
shape_merge.populate_index_by_geojson(r"path_to_geo_json.geojson")
Iteratively populate the index
from shape_merge.merge import ShapeMerge
shape_merge = ShapeMerge()
for feature in feature_collection:
shape_merge.populate_index_by_feature(feature)
Feature must be of the following structure:
{'type': 'Feature', 'id': str, 'properties': dict, 'geometry': {'type': 'GeometryType', 'coordinates': list}}
How to run
After Populating the Index, merging is matter of a function call away, execute the following to begin merging:
shape_merge.merge_geometries()
Output
The Output will be a collection, which will contain the merged geometries and the all the ids that were merged together
merged_geoemrty = OrderedDict([(0, {'ids': [ ], 'geometry': {'type': 'GeometryType', 'coordinates': []}})])
Parameters
bounds_buffer :
During rtree index creation the bounds of individual geometry are added with buffer of 0, This param controls on how big the original bounds should grow.
geometry.bounds.buffer(self.__bounds_buffer)
The bounds of the geometry are responsible for finding potential intersecting neighbour i.e everything that lies in the bound is considered as a potential neighbour. A large value of bound value will increase the computational overhead.
geometry_buffer:
Add buffer to geometries while checking if they intersect with each other
geometry_1.buffer(self.__geometry_buffer).intersects(geometry_2.buffer(self.__geometry_buffer))
Metadata
Release files for shape-merge 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shape_merge-1.0.3.tar.gz | 9.1 kB | Without provenance | Details for shape_merge-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shape_merge-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for shape_merge-1.0.3-py3-none-any.whl |
Total release size: 17.0 kB
Release files / shape_merge-1.0.3.tar.gz
| Download URL | shape_merge-1.0.3.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
985ca0c1e76ab61d53ad4ffc8b53165e32efbcc9a6d0ad46782edd821f438e20
|
|
BLAKE2b-256 checksum How to use checksums |
fd86b38d0c8815598c9bee2973a6956f048d436c1cb3692c2f2547a5fc5e6e0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / shape_merge-1.0.3-py3-none-any.whl
| Download URL | shape_merge-1.0.3-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8371440d04280e6cd15427905e9b1eb5af8122698f574f2a8f4900fff8b5a028
|
|
BLAKE2b-256 checksum How to use checksums |
21c3ddd490d41122180ce780e6a68085c110e47008073e1cbadc0fd674b7a7b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for shape-merge 1.0.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.