JuliaGeo / GeometryOps.jl

GeoInterface-based geometry operations
https://juliageo.org/GeometryOps.jl/
MIT License
29 stars 4 forks source link

Coordinate Reference System dropped when GO.buffer() is used #214

Closed BG-AIMS closed 1 month ago

BG-AIMS commented 1 month ago

The CRS attached to polygon1 appears to be removed in the resulting polygon from GO.buffer(polygon1, x). Is there a way to attach a CRS back to the resulting polygon?

import GeoInterface as GI
import GeometryOps as GO
import GeoFormatTypes as GFT
using GLMakie
using LibGEOS

x = [-10, -10, 10, 10, -10]
y = [-10, 10, 10, -10, -10]
lines = GI.LineString(GI.Point.(zip(x,y)));

ring1 = GI.LinearRing(GI.getpoint(lines));
polygon1 = GI.Polygon([ring1]; crs=EPSG(3857));
GI.crs(polygon1)
GI.crs(GO.buffer(polygon1, 1))
asinghvi17 commented 1 month ago

Thanks for the issue! This looks like it was an oversight when I wrote buffer, since it calls out to LibGEOS which doesn't have the concept of a CRS.

For now, you can simply call tuples on the result and attach a CRS that way:

polygon2 = GO.tuples(GO.buffer(polygon1, 1); crs = GI.crs(polygon1))

but we should amend buffer to perform this itself.

asinghvi17 commented 1 month ago

related: https://github.com/JuliaGeo/GeoInterface.jl/issues/158