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.
using PlotlyJS, DataFrames
link = “https://raw.githubusercontent.com/meherGill/geojson_suburbs/main/suburbsModified.geojson”
geomap = choropleth(DataFrame(Postal = [“2603”,“2604”,“2605”]);geojson = link, locations=“Postal”, featureidkey = “properties.id”)
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.
What is the problem with GMT.jl? Anything that I can help or, perhaps, improve?
I want the function to be part of a package and therefore dependence on an external tool is a problem unfortunately.
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, z), subSubShp)
Plots.plot(allShp_arr,ticks = false, axis = false, legend = false, color = “#d9d9d9”)
Just for comparison. This is one way of doing it with GMT
coast(DCW=(name=:UN150, pen=0.5, fill=:gray70), region=(-12,45,35,75),
proj="eck4", frame=:none, show=true)
You can do something very similar entirely within
Colors is just used for convenience):
geo = attr(scope="europe",
resolution="50", # alt. "110" or "50", in km/mm
layout = Layout(;title="Europe Levels", showlegend=false, geo=geo)