Hi
I want to plot a choropleth map using a topojson (I converted the .shp file to a topojson) and a dataframe.
-
The topojson has the “polygons”, coordinates", and the names of the districts.
-
The dataframe has many columns. But the useful ones for this case are: “count” (this is the # of IPs) and “featureId” (this has the names of the districts).
What these files have in common is the name of districts.
Here some images for you to understand:
TOPOJSON FILE
DATAFRAME
This is my code:
@vlplot(width=1000, height=800) +
@vlplot(
mark={
:geoshape
},
data={
values=JSON.parsefile("/home/juliana/roc/Data/Topojson/disa_ONT_region.topojson"),
format={
type=:topojson,
feature=:disa_ONT_region
}
},
transform=[{
lookup=:featureId,
from={
data=df_splunk,
key=:featureId,
fields=["count"]
}
}],
color={
"rate:q",
scale={domain=[0, 0.15], scheme=:reds},
legend={title="IPs Rate in Ontario - BST"}
},
projection={
type=:albersUsa
}
)
In the “transform” block, I am calling my dataframe (df_splunk).
I want “VegaLite” to use the column “featureId” (names of districts) and the “count” (number of IPs) to visualize a choropleth map. But I have not succeded yet.
I know that in “lookup” I have to put the field to look for in the dataframe. And that “field” is what both files have in common (in this case the names of the districts).
But in what part am I telling VegaLite to use the names of districts of the topojson file? I guess it is : “properties” or “DA_ID” of the topojson file.
So, what am I doing wrong?
Thank you
Here some of the documentation and tutorials that I have checked:
https://www.queryverse.org/VegaLite.jl/dev/examples/examples_maps/
[https://www.flirtwithjulia.com/2019/02/18/Choropleth-Map-With-VegaLite.jl.html]