Skip to main content

A function for calculating a buffer around a polyline, defining the contours of a line with variable thickness.

Project description

Variable polyline buffer

Description

variable_polyline_buffer is a Python library for calculating a buffer around a polyline, defining the contours of a line with variable thickness. This function supports various applications in geographical information systems, computer graphics, and spatial analysis where dynamic line thickness is required.

Installation

To install this package, use pip:

pip install variable_polyline_buffer

Usage

Here is a simple example of how to use Variable-Polyline-Buffer:

from variable_polyline_buffer import generate_polyline_buffer
import matplotlib.pyplot as plt

# Example data: coordinates of polyline points and distance for each segment
points = [(0, 0), (2, 0.5), (3, -0.5), (4, 1)]
distances = [1, 0.5, 0.2]  # Thickness of the individual segments

# Generate contours
left_contour, right_contour = generate_polyline_buffer(points, distances)

# Plot the contours
plt.plot([p[0] for p in points], [p[1] for p in points], "C0")
plt.plot([p[0] for p in left], [p[1] for p in left], "k--")
plt.plot([p[0] for p in right], [p[1] for p in right], "k--")
plt.axis("equal")

Output image

Replace points and dists with your polyline data and corresponding thicknesses.

Via supplying tuples as dists, one can also generate different thicknesses on the curve's two sides:

points = [(0, 0), (2, 0.5), (3, -0.5), (4, 1)]
distances = [(0.1, 1), (0.1, 0.5), 0.2]

Output image

By supplying False as distance, one can taper between segments with different widths:

points = [(0, 0), (1, 0), (2, 0), (3, 0)]
distances = [(0.5, 0), (False, 0), (0.2, 0)]

Output image

Requirements

Variable-Polyline-Buffer requires the following Python libraries:

  • NumPy

License

This project is licensed under the MIT License.

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

variable_polyline_buffer-0.1.5.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

variable_polyline_buffer-0.1.5-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file variable_polyline_buffer-0.1.5.tar.gz.

File metadata

File hashes

Hashes for variable_polyline_buffer-0.1.5.tar.gz
Algorithm Hash digest
SHA256 85d1f5bab75286f539c5851562e400eff2af82109c5a548ffaa2e8cfccef4a93
MD5 6e48ff27c1be42ead10b2730f5e1b37a
BLAKE2b-256 9aebfe3dda9c3a14505885227b37c634a2cff5c48349c970b6b29059649195e8

See more details on using hashes here.

File details

Details for the file variable_polyline_buffer-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for variable_polyline_buffer-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 84e55e027f3c2862211dfe664e0a904e94ecbd70d8e5514c32a9e44bd604591b
MD5 53429ac6205e5f58f8e8e1ec1810a3c9
BLAKE2b-256 981ec3cf5eb168061bdd30e55733a292ac8831c2a4f9f4fab802e6c50c5dd9d8

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