Hi,
I’d like to read a .geojson file and perform some geometrical operations on the geometries (union, contains, etc.).
Using LibGEOS or ArchGDAL works fine, but i’ve got some troubles with GeoJSON (maybe I’m missing something).
Say I have a featureCollection named col:
julia> typeof(col)
GeoJSON.FeatureCollection{GeoJSON.Feature{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}, JSON3.Object{Vector{UInt8}, Vector{UInt64}}, JSON3.Array{JSON3.Object, Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}
When I try to perform a GI.contains check, I get:
julia> import GeoInterface as GI
julia> GI.contains(col.geometry[2], col.geometry[1])
ERROR: MethodError: no method matching contains(::GeoInterface.PointTrait, ::GeoInterface.PointTrait, ::GeoJSON.Point{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}, ::GeoJSON.Point{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}})
Closest candidates are:
contains(::Union{GeoInterface.CircularStringTrait, GeoInterface.CompoundCurveTrait, GeoInterface.CurvePolygonTrait, GeoInterface.GeometryCollectionTrait, GeoInterface.LineStringTrait, GeoInterface.LinearRingTrait, GeoInterface.MultiLineStringTrait, GeoInterface.MultiPointTrait, GeoInterface.MultiPolygonTrait, GeoInterface.MultiSurfaceTrait, GeoInterface.PointTrait, GeoInterface.PolygonTrait, GeoInterface.PolyhedralSurfaceTrait, GeoInterface.TINTrait, GeoInterface.TriangleTrait}, ::Union{GeoInterface.CircularStringTrait, GeoInterface.CompoundCurveTrait, GeoInterface.CurvePolygonTrait, GeoInterface.GeometryCollectionTrait, GeoInterface.LineStringTrait, GeoInterface.LinearRingTrait, GeoInterface.MultiLineStringTrait, GeoInterface.MultiPointTrait, GeoInterface.MultiPolygonTrait, GeoInterface.MultiSurfaceTrait, GeoInterface.PointTrait, GeoInterface.PolygonTrait, GeoInterface.PolyhedralSurfaceTrait, GeoInterface.TINTrait, GeoInterface.TriangleTrait}, ::ArchGDAL.AbstractGeometry, ::ArchGDAL.AbstractGeometry) at ~/.julia/packages/ArchGDAL/pPZyn/src/geointerface.jl:184
contains(::GeoInterface.AbstractGeometryTrait, ::GeoInterface.AbstractGeometryTrait, ::LibGEOS.AbstractGeometry, ::LibGEOS.AbstractGeometry) at ~/.julia/packages/LibGEOS/Wbmhr/src/geo_interface.jl:145
contains(::Any, ::Any) at ~/.julia/packages/GeoInterface/246K4/src/interface.jl:485
Stacktrace:
[1] contains(a::GeoJSON.Point{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}, b::GeoJSON.Point{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}})
@ GeoInterface ~/.julia/packages/GeoInterface/246K4/src/interface.jl:485
[2] top-level scope
@ REPL[270]:1
Otherwise, it works fine with e.g. ArchGDAL:
julia> typeof(p)
ArchGDAL.IGeometry{ArchGDAL.wkbPolygon}
julia> GI.contains(p, p)
true
Before I fill an issue on Github, any ideas?
Or maybe I’m trying to do something out of the package’s scope?
As a workaround, I currently load the geojson using GeoDataFrames. That’s a bit of a heavy machinery for that simple task.