I want to plot a geojson with multiple geojsons as a geo map with Plotly. I tried to convert an existing Python example to Julia but without success. The code below is just one example and I’ve also tested the same structure with different geojsons or not setting featureidkey. One thing I noticed was that the Julia documentation on choropleth does not mention a color option which is usually set in Python.
For context: As I’ve explained in a previous post, I want to change the projection of the resulting map. Therefore, creating a mapbox map is unfortunately not an option. I’ve also noticed that there are other packages for plotting shapes in Julia but none of them seem well maintained and offer the same range of formatting options.
Realized the best way is to write a function myself. The code below uses the Proj package to translate lat/lon in x/y coordinates for different projections. Then I create shapes for plotting with Plots.
using Plots, JSON, Proj
u = “country”
getShp_json = JSON.parsefile(u * “.geojson”)
trans = Proj.Transformation(“EPSG:4326”, “+proj=eck4 +axis=neu”)
allShp_arr = Plots.Shape
for shp in collect(values(getShp_json[“features”])), subShp in shp[“geometry”][“coordinates”], subSubShp in subShp
shp_arr = map(z → trans(z[1], z[2]), subSubShp)
push!(allShp_arr, Plots.Shape(shp_arr))
end