Skip to main content

Creates shapely shapes around given points.

Project description

Bounding Shapes

This library creates Shapely shapes designed to fit closely around a set of given points, and provides functionality to create a grid of points inside those shapes. This simplifies the problem of trying to find a shape that fits around all points, whilst allowing for gaps/multiple shapes to accomodate for situations where points may be clustered around a few areas, or handling points far outside a cluster.

import geopandas as gpd
from shapely import MultiPoint

# Example dataset of rainfall stations covering England
fn = "AllRainfallStations"
imported_gdf = gpd.read_file(f"zip://{fn}.zip!{fn}/{fn}.shp")
imported_gdf.head()
sample_N geometry
0 1 POINT (-1.17133 52.18628)
1 1 POINT (-1.1637 52.98624)
2 1 POINT (-1.67298 51.69289)
3 1 POINT (-0.64929 52.49389)
4 1 POINT (-0.99517 52.73152)
# Convert improted data into Multipoint object
reprojected_gdf = imported_gdf.to_crs(crs="EPSG:32631")
points = MultiPoint(list(zip(reprojected_gdf.geometry.x, reprojected_gdf.geometry.y)))
points

from bounding_shape.bounding_shape import create_bounding_area

bounding_area = create_bounding_area(points)
bounding_area

Using the libary to create a set of points inside an area:

from bounding_shape.bounding_shape import create_spaced_points
spaced_points = create_spaced_points(points=points) 
spaced_points

Targeting a number of grid points

If creating a grid and there is a target number of points for the shape to be split into, the get_grid_spacing_for_points method allows this to be specified with the magnitude parameter.

from bounding_shape.bounding_shape import create_spaced_points, get_grid_spacing_for_points
from shapely import MultiPoint

points = MultiPoint([[0.0, 0.0], [0.0, 100.0], [100.0, 100.0], [100.0, 0.0]])

distance = get_grid_spacing_for_points(points=points, magnitude=20)
spaced_points = create_spaced_points(points=points, grid_spacing=distance, buffer=0.0)
spaced_points

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

bounding_shape-0.1.1.tar.gz (237.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bounding_shape-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file bounding_shape-0.1.1.tar.gz.

File metadata

  • Download URL: bounding_shape-0.1.1.tar.gz
  • Upload date:
  • Size: 237.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for bounding_shape-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7d30205216fa18323882d861e89adfa46a25225cd1cdaea3222e82fe02f5620b
MD5 cd87445f573bed1c3b2f805aa93c4587
BLAKE2b-256 eeb2d4137c685fb5dc34936b4a2d39c04935940eb9aee8b3d544a1e0c923227a

See more details on using hashes here.

File details

Details for the file bounding_shape-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bounding_shape-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for bounding_shape-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18aab88e0f28bae787f10ee9e512583a37ddcaa638f2eb49896672898684ff79
MD5 86153da519aa5bbd308189bc230e3675
BLAKE2b-256 a1bcf770fc2155fa2628a2433e69c70a9180c41b0211215c2dd1e0d78ab07cee

See more details on using hashes here.

Supported by

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