Outlining paths with polygons

Hi all,

I was wondering whether if Julia has packages with similar functionality to Shapely. Suppose I have a list of coordinates and want to define a path with a buffer, plot it and test whether specific points fall within the path. Here is a simple example in Python:

from shapely.geometry import Point, LineString, Polygon
from shapely.ops import unary_union
from matplotlib import pyplot as plt

buffer = .05
poly1 = LineString([(0,0), (2,0), (2,2), (0,2)]).buffer(buffer)
poly2 = LineString([(2,2), (4,2), (4,4), (2,4)]).buffer(buffer)
poly3 = LineString([(1,1), (3,1), (3,3), (1,3)]).buffer(buffer)
poly4 = LineString([(3,3), (5,3), (5,5), (3,5)]).buffer(buffer)
polys = [poly1, poly2, poly3, poly4]
polygon_union = unary_union(polys)

xs, ys = polygon_union.exterior.xy

fig, axs = plt.subplots()
axs.set_aspect('equal', 'datalim')
axs.plot(xs, ys, alpha=0.5)
plt.plot(xs, ys, color="blue")
for inner in polygon_union.interiors:
    xi, yi = zip(*inner.coords[:])
    axs.plot(xi, yi, color="blue")

# correctly returns false
point = Point(2.5, 1.5)
# correctly returns true
point = Point(2, 1)


Can this be done in Julia?

Shapely uses the GEOS computational geometry library. A direct equivalent of that in Julia is GitHub - JuliaGeo/LibGEOS.jl: Julia package for manipulation and analysis of planar geometric objects, so you should be able to port this example to Julia.


Perfect. Than you!