Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the use of ArchGDAL.ISpatialRef in reproject #403

Open
felixcremer opened this issue Nov 29, 2023 · 1 comment
Open

Enable the use of ArchGDAL.ISpatialRef in reproject #403

felixcremer opened this issue Nov 29, 2023 · 1 comment

Comments

@felixcremer
Copy link
Contributor

When I have a geometry in a specific CRS I can get the crs information via ArchGDAL.getspatialref(geom) but then I can't use this crs for the reprojection.
It would be good to be able to use the crs that I get from ArchGDAL in the relevant ArchGDAL functions.

I can get the projstring via ArchGDAL.toProj4 but then to use it in the reproject call I have to wrap it in the ProjString type.

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> crs = ArchGDAL.getspatialref(deu.geom[1])
Spatial Reference System: +proj=longlat +datum=WGS84 +no_defs
# This works: but could be made easier
julia> projdeu = ArchGDAL.reproject(only(deu.geom), ProjString(ArchGDAL.toPROJ4(crs)), ProjString(newproj))

Geometry: MULTIPOLYGON (((17.199717191748 -0.16543096960377, ... 47)))
julia> projdeu = ArchGDAL.reproject(only(deu.geom), crs, ProjString(newproj))
ERROR: MethodError: no method matching reproject(::ArchGDAL.IGeometry{ArchGDAL.wkbMultiPolygon}, ::ArchGDAL.ISpatialRef, ::ProjString)

Closest candidates are:
  reproject(::ArchGDAL.AbstractGeometry, ::GeoFormat, ::GeoFormat; kwargs...)
   @ ArchGDAL ~/Documents/NFDI4Earth/deliverables/D2.5_1-5_Overview_DC_tech/dev/ArchGDAL/src/spatialref.jl:155
  reproject(::T, ::GeoFormat, ::Nothing; kwargs...) where T
   @ ArchGDAL ~/Documents/NFDI4Earth/deliverables/D2.5_1-5_Overview_DC_tech/dev/ArchGDAL/src/spatialref.jl:100
  reproject(::Union{Tuple{var"#s244", var"#s244"} where var"#s244"<:Number, Tuple{var"#s243", var"#s243", var"#s243"} where var"#s243"<:Number, AbstractVector{<:Number}}, ::GeoFormat, ::GeoFormat; kwargs...)
   @ ArchGDAL ~/Documents/NFDI4Earth/deliverables/D2.5_1-5_Overview_DC_tech/dev/ArchGDAL/src/spatialref.jl:114
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[160]:1
@rafaqz
Copy link
Collaborator

rafaqz commented Nov 29, 2023

I think I just never thought to add that, rather than intentionally leaving it out. But sounds like it would be good to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants