yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
137 stars 25 forks source link

Rename reproject to reproject! because it is changing the geometry inplace #402

Open felixcremer opened 6 months ago

felixcremer commented 6 months ago

While reprojecting a geometry I got very confused that my starting geometry got reprojected in place. I think we should add this info to the documentation and also add a ! to the function name to clarify that the reprojection happens in place.

using GADM
using ArchGDAL
julia> deu = GADM.get("DEU", depth=0)
(geom = ArchGDAL.IGeometry{ArchGDAL.wkbMultiPolygon}[Geometry: MULTIPOLYGON (((7.98642063100016 47.5555305480001, ... 02)))], GID_0 = ["DEU"], COUNTRY = ["Germany"])

julia> projdeu = ArchGDAL.reproject(only(deu.geom), EPSG(4326), ProjString(newproj))
Geometry: MULTIPOLYGON (((67.8564039238532 -13.2639375695037 ... 25)))

julia> deu
(geom = ArchGDAL.IGeometry{ArchGDAL.wkbMultiPolygon}[Geometry: MULTIPOLYGON (((67.8564039238532 -13.2639375695037 ... 25)))], GID_0 = ["DEU"], COUNTRY = ["Germany"])
rafaqz commented 6 months ago

Sorry, I can't remember why there is no bang. I guess we need both methods and the non-bang method to make a copy.