# Outlining paths with polygons

**URL:** <https://discourse.julialang.org/t/outlining-paths-with-polygons/96243>\
**Category:** General Usage\
**Tags:** geo\
**Created:** [March 17, 2023, 1:08pm UTC](https://discourse.julialang.org/t/outlining-paths-with-polygons/96243 "2023-03-17T13:08:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 17, 2023, 1:08pm UTC](https://discourse.julialang.org/t/outlining-paths-with-polygons/96243/1 "2023-03-17T13:08:58Z")

</div>

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:

```julia
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")
plt.show()

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

```

![image](https://global.discourse-cdn.com/julialang/original/3X/d/8/d896a1bd5eb7c963db9b29760ba8479ee22976c7.png)

Can this be done in Julia?

---

<div class="post-metadata">

**Author:** ![visr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/visr/32/17204_2.png) [@visr](https://discourse.julialang.org/u/visr)\
**Post date:** [March 17, 2023, 1:30pm UTC](https://discourse.julialang.org/t/outlining-paths-with-polygons/96243/2 "2023-03-17T13:30:41Z")

</div>

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](https://github.com/JuliaGeo/LibGEOS.jl), so you should be able to port this example to Julia.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [March 17, 2023, 2:01pm UTC](https://discourse.julialang.org/t/outlining-paths-with-polygons/96243/3 "2023-03-17T14:01:21Z")

</div>

Perfect. Than you!
