ArchGDAL.jl icon indicating copy to clipboard operation
ArchGDAL.jl copied to clipboard

Geometry 3d-ness is not preserved at the type level by `GI.convert` nor `AG.create*`.

Open asinghvi17 opened this issue 1 year ago • 0 comments

MWE:

julia> import ArchGDAL as AG, GeoInterface as GI

julia> geom = AG.fromWKT("MULTIPOLYGON (" *
                     "((0 4 8,4 4 8,4 0 8,0 0 8,0 4 8)," *
                     "(3 1 8,3 3 8,1 3 8,1 1 8,3 1 8))," *
                     "((10 4 8,14 4 8,14 0 8,10 0 8,10 4 8)," *
                     "(13 1 8,13 3 8,11 3 8,11 1 8,13 1 8)))")
Geometry: MULTIPOLYGON (((0 4 8,4 4 8,4 0 8,0 0 8,0 4 8),(3  ...  8)))

julia> typeof(geom)
ArchGDAL.IGeometry{ArchGDAL.wkbMultiPolygon25D}

julia> GI.coordinates(geom)
2-element Vector{Vector{Vector{Vector{Float64}}}}:
 [[[0.0, 4.0, 8.0], [4.0, 4.0, 8.0], [4.0, 0.0, 8.0], [0.0, 0.0, 8.0], [0.0, 4.0, 8.0]], [[3.0, 1.0, 8.0], [3.0, 3.0, 8.0], [1.0, 3.0, 8.0], [1.0, 1.0, 8.0], [3.0, 1.0, 8.0]]]
 [[[10.0, 4.0, 8.0], [14.0, 4.0, 8.0], [14.0, 0.0, 8.0], [10.0, 0.0, 8.0], [10.0, 4.0, 8.0]], [[13.0, 1.0, 8.0], [13.0, 3.0, 8.0], [11.0, 3.0, 8.0], [11.0, 1.0, 8.0], [13.0, 1.0, 8.0]]]

julia> GI.coordinates(geom) |> AG.createmultipolygon
Geometry: MULTIPOLYGON (((0 4 8,4 4 8,4 0 8,0 0 8,0 4 8),(3  ...  8)))

julia> geom
Geometry: MULTIPOLYGON (((0 4 8,4 4 8,4 0 8,0 0 8,0 4 8),(3  ...  8)))

julia> GI.coordinates(geom) |> AG.createmultipolygon |> typeof
ArchGDAL.IGeometry{ArchGDAL.wkbMultiPolygon}

julia> GI.coordinates(geom) |> AG.createmultipolygon |> GI.is3d
false

julia> GI.coordinates(geom) |> AG.createmultipolygon |> GI.ismeasured
false

julia> GI.coordinates(geom) |> AG.createmultipolygon |> GI.coordnames
(:X, :Y, :Z)

Not sure what the best way around this is - maybe a check before materializing the geometry?

asinghvi17 avatar Nov 13 '24 21:11 asinghvi17