# Plotting Polygons in geomakie

**URL:** <https://discourse.julialang.org/t/plotting-polygons-in-geomakie/97948>\
**Category:** Visualization\
**Tags:** makie, geometry\
**Created:** [April 26, 2023, 2:06pm UTC](https://discourse.julialang.org/t/plotting-polygons-in-geomakie/97948 "2023-04-26T14:06:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [April 26, 2023, 2:06pm UTC](https://discourse.julialang.org/t/plotting-polygons-in-geomakie/97948/1 "2023-04-26T14:06:17Z")

</div>

Hello, I’m trying to make map of administrative regions in GeoMakie but the `poly!` function does not work with Polygons, unlike specified in the documentation ([poly · Makie](https://docs.makie.org/stable/examples/plotting_functions/poly/)). Here’s a MWE:

```julia
GeoJSON.write("data/DE_regions.geojson", GeoJSON.read(read(download("https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/2_bundeslaender/1_sehr_hoch.geo.json"))))
    landers = copy(GeoJSON.read(read("data/DE_regions.geojson")))
    polys = [c.geometry for c in landers]

    f = Figure();
    ax = GeoAxis(f[1,1]; lonlims = (5,20), latlims = (46,56));
    for poly in polys
           poly!(ax, poly[i] ;strokewidth = 1, strokecolor = :black)
    end

```

The Stacktrace is long, here’s a snippet:

```julia
ERROR: `Makie.convert_arguments` for the plot type Scatter and its conversion trait PointBased() was unsuccessful.

The signature that could not be converted was:
::GeoJSON.Polygon{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}

Makie needs to convert all plot input arguments to types that can be consumed by the backends (typically Arrays with Float32 elements).
You can define a method for `Makie.convert_arguments` (a type recipe) for these types or their supertypes to make this set of arguments convertible (See http://docs.makie.org/stable/documentation/recipes/index.html).

Alternatively, you can define `Makie.convert_single_argument` for single arguments which have types that are unknown to Makie but which can be converted to known types and fed back to the conversion pipeline.

[...]

caused by: MethodError: no method matching convert_arguments(::Type{Scatter}, ::GeoJSON.Polygon{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}})
Closest candidates are:
  convert_arguments(::Union{Type{Any}, Type{<:AbstractPlot}}, ::Union{AbstractVector, IntervalSets.Interval}, ::Distributions.Distribution) at C:\Users\dehaybe\.julia\packages\Makie\Iqcri\src\stats\distributions.jl:21
  convert_arguments(::Union{Type{Any}, Type{<:AbstractPlot}}, ::AbstractVector, ::StatsBase.ECDF) at C:\Users\dehaybe\.julia\packages\Makie\Iqcri\src\stats\ecdf.jl:22
  convert_arguments(::Union{Type{Any}, Type{<:AbstractPlot}}, ::AbstractVector, ::Function) at C:\Users\dehaybe\.julia\packages\Makie\Iqcri\src\conversions.jl:607

[...]

caused by: MethodError: no method matching convert_arguments(::PointBased, ::GeoJSON.Polygon{JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}})
Closest candidates are:
  convert_arguments(::PointBased, ::AbstractVector, ::AbstractVector, ::AbstractMatrix) at C:\Users\dehaybe\.julia\packages\Makie\Iqcri\src\conversions.jl:112
  convert_arguments(::SurfaceLike, ::AbstractVector{T1}, ::AbstractVector{T2}, ::Function) where {T1, T2} at C:\Users\dehaybe\.julia\packages\Makie\Iqcri\src\conversions.jl:403
  convert_arguments(::Type{<:Combined{Makie.rainclouds}}, ::Any, ::Any) at C:\Users\dehaybe\.julia\packages\Makie\Iqcri\src\basic_recipes\raincloud.jl:189

```

I don’t understand why this does not work out of the box. `polys` is a Vector of `GeoJSON.Geometry` (Polygons and MultiPolygons).

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [April 26, 2023, 11:53pm UTC](https://discourse.julialang.org/t/plotting-polygons-in-geomakie/97948/2 "2023-04-26T23:53:15Z")

</div>

> [@HenriDeh](#):
>
> ```julia
> poly!(ax, GeoMakie.geo2basic(poly) ;strokewidth = 1, strokecolor = :black)
> 
> ```

is what you need for now. I will release a patch soon which should fix this.

---

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [April 27, 2023, 7:33am UTC](https://discourse.julialang.org/t/plotting-polygons-in-geomakie/97948/3 "2023-04-27T07:33:46Z")

</div>

Amazing, thank you.
