Hello,
Increasingly I find myself needing to join dataframes on Geographic Information System (GIS) objects and it seems no capability exists to do so in the Julia eco-system. Nor does it seem there is much interest (c.f. Perform spatial join with GeoDataFrames) . Using python I could do this
import geopandas as gpd
import pandas as pd
gdfa = gpd.read_file('./a.csv') # polygons
gdfb = gpd.read_file('./b.csv') # points
gdfc = gdfb.sjoin(gdfa, how="left", predicate="within")
Without any specific Julia tooling for this I have tried the following without success
using DataFrames
using ArchGDAL
using CSV
dsa = ArchGDAL.read("./a.csv")
layera = ArchGDAL.getlayer(dsa, 0)
dfa = layera |> DataFrame
rename!(dfa, ""=> :geometry)
dsb = ArchGDAL.read("./b.csv")
layerb = ArchGDAL.getlayer(dsb, 0)
dfb = layerb |> DataFrame
rename!(dfb, ""=> :geometry)
import Base.(==)
import Base.isequal
import Base.isless
function ==(a::ArchGDAL.IGeometry{ArchGDAL.wkbPoint},b::ArchGDAL.IGeometry{ArchGDAL.wkbPolygon})
ArchGDAL.within(a,b)
end
function ==(a::ArchGDAL.IGeometry{ArchGDAL.wkbPolygon},b::ArchGDAL.IGeometry{ArchGDAL.wkbPoint})
ArchGDAL.within(b,a)
end
innerjoin(dfa,dfb, on=:geometry, makeunique=true)
Thoughts and advice welcome!
The data used in the examples above are here: