Convert GADM.jl country file to GeoJSON.jl

Hi, I would like to convert the loaded GADM.jl country polygon file to GeoJSON.jl so that I can plot this using GeoMakie.jl. I am aware that MeshViz.jl supports well the GADM.jl, but I would like to customize the plot and hence I want to use GeoMakie.jl. From the examples in GeoMakie.jl and the GeoPlots of BeautifulMakie, most of them load GeoJSON file from some links hosting the file, and this is what I follow at the moment. Example

using CairoMakie
using Colors
using GeoMakie
using GeoJSON
using Downloads
ph_geojson = "https://raw.githubusercontent.com/faeldon/philippines-json-maps/master/geojson/country/lowres/country.0.001.json";
phmap = Downloads.download(ph_geojson);
geo = GeoJSON.read(read(phmap, String));
geo
function plotPH()
	fig = Figure(resolution = (1050, 800), fontsize = 22);
	ax = GeoAxis(fig[1, 1], dest="+proj=gall +lon_0=150 +lat_0=10",
		lonlims=(100, 200), latlims=(-5, 60), coastlines=true, 
		coastline_attributes=(color=:black, linewidth=0.35, fill=:black))
	poly!(ax, geo, color=colorant"#85754e",
		strokecolor = :black, strokewidth = 0.35)
	colsize!(fig.layout, 1, Aspect(1, 2.0))
	fig
end

I would like to change the code above and use the shapefile from GADM.jl for plotting the country above. Is it possible? I know I can get the coordinates of the country as follows:

using GADM
ph = GADM.coordinates("PHL")

But I don’t know how to proceed to convert this to GeoJSON file and plot it like the one above.

I should emphasize though that I am not a Geographer, and I apologize for my basic understanding.

Not GeoMakie but …

https://www.generic-mapping-tools.org/GMT.jl/dev/gallery/GADM/gadm/

1 Like

GADM.jl returns a table with geometries that follow the GeoInterface.jl so you shouldn’t need to convert to GeoJSON.jl if I am not mistaken. If you want to use MeshViz.jl then you probably want GeoTables.jl instead to load the GeoInterface.jl geometries as Meshes.jl geometries, which are Julia geometries with a more rich set of functions.

Notice that MeshViz.jl is just a set of Makie recipes, that means that you can customize the axis and plots the same way you would with GeoMakie.jl or any Makie set of recipes.

1 Like

Thanks @joa-quim, I have indeed used GMT.jl in one of my paper (currently under review), and it was easy to setup, but this time I prefer to try out GeoMakie.jl.

Thanks @juliohm, I did try to look into the codes of MeshViz.jl, I’m still trying to understand it and hoping to reuse part of it for my codes.