Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't plot geometry wrapper types #110

Open
evetion opened this issue Sep 4, 2023 · 7 comments
Open

Can't plot geometry wrapper types #110

evetion opened this issue Sep 4, 2023 · 7 comments

Comments

@evetion
Copy link
Member

evetion commented Sep 4, 2023

julia> using GeoInterface, Plots, GeoFormatTypes

julia> points = GeoInterface.Point.(rand(10),rand(10), crs=GeoFormatTypes.EPSG(4326))
10-element Vector{GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG}}:
 GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG}((0.6569792502348218, 0.5196554284209661), EPSG(4326))
...

julia> plot(points)
ERROR: Cannot convert GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG} to series data for plotting
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] _prepare_series_data(x::GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG})
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:8
  [3] _series_data_vector(x::GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG}, plotattributes::Dict{Symbol, Any})
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:36
  [4] (::RecipesPipeline.var"#21#24"{Dict{Symbol, Any}})(vi::GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG})
    @ RecipesPipeline ./none:0
  [5] iterate
    @ ./generator.jl:47 [inlined]
  [6] _series_data_vector(v::Vector{GeoInterface.Wrappers.Point{false, false, Tuple{Float64, Float64}, EPSG}}, plotattributes::Dict{Symbol, Any})
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:51
  [7] macro expansion
    @ ~/.julia/packages/RecipesPipeline/BGM3l/src/series.jl:129 [inlined]
  [8] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl:300
  [9] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl:38
 [10] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl:72
 [11] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots ~/.julia/packages/Plots/3BCH5/src/plot.jl:223
 [12] #plot#188
    @ ~/.julia/packages/Plots/3BCH5/src/plot.jl:102 [inlined]
 [13] plot(args::Any)
    @ Plots ~/.julia/packages/Plots/3BCH5/src/plot.jl:93
 [14] top-level scope
    @ REPL[10]:1
@rafaqz
Copy link
Member

rafaqz commented Sep 4, 2023

Yeah you need to do using GeoInterfaceRecipes and it will work.

I recently did this:
https://github.com/JuliaGeo/GeoInterface.jl/blob/main/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl#L184

It would be so much better if it just worked, but the dependency structure makes that impossible. I wish we could load packages in extensions then we could just load GeoInterfaceRecipes.jl if Plots.jl was around.

I've also wondered if we can hack in an include("../GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl") from a Plots.jl extension of GeoInterface. It does mean compiling that code twice but maybe that's fine.

@evetion
Copy link
Member Author

evetion commented Sep 4, 2023

Ah, of course, I forgot I explicitly needed to load it.

@rafaqz
Copy link
Member

rafaqz commented Sep 4, 2023

Probably everyone will do that tho... what do you think about doing the the include hack?

@felixcremer
Copy link
Member

Why can't we make GeoInterfaceRecipes a proper extension depending on Plots?

@evetion
Copy link
Member Author

evetion commented Sep 5, 2023

Extensions can only extend existing methods AFAIK. Not even sure whether recipes would count as such, probably not.

@rafaqz
Copy link
Member

rafaqz commented Sep 5, 2023

The problem is other packages need to use the macro even when Plots is not avalable, or everyone has to do it in extensions.

But we can do both with the include hack

@asinghvi17
Copy link
Member

asinghvi17 commented Apr 19, 2024

If we're able to drop the GeometryBasics dependency in GeoInterfaceMakie, then it could be included as an extension on MakieCore! That solves the circular dependency issue, and we can probably pass polygons as vectors of vectors of tuples to Makie (if that doesn't work now, it can be made to work before Makie v0.21).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants