Join dataframe and geotable

TimG
Tue, 26 Mar 2024 12:03:22 +0000
New to Julia

A very basic question, I’m afraid.
I have a shape file of local authority boundaries downloaded from the Office for National Statistics and GeoIO read this as expected and Makie plots it.

One of the data fields in the shape file is the name of the local authority.
I also have a DataFrame which has a column listing the name of the local authority together with a bunch of data associated with that authority. The dataframe only consists of a subset of the local authorities in the shp file.

I want to join these two datasets on the LA name.

The geojoin function will join based on geometry but not (aparently) on the table data columns. Dataframe style leftjoin didn’t work either.

using GeoStats, GeoIO, CSV, DataFrames
import CairoMakie as mke
fname = "CTYUA_DEC_2023_UK_BFE.shp"
LAs=GeoIO.load(fname)|> Rename("CTYUA23NM" => "newLocalAuthority")
viz(LAs.geometry)
combo=CSV.read("combo.csv", DataFrame)
result = leftjoin(LAs, combo, on=:newLocalAuthority)

As a last resort, I tried Copilot but, as expected, it didn’t work.

result = join(LAs, combo, on=:newLocalAuthority)

How can I join on the table data?

35 posts - 7 participants

Read full topic