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

Plotting line segments / multiline object #182

Closed
noahrhodes opened this issue Nov 13, 2023 · 3 comments
Closed

Plotting line segments / multiline object #182

noahrhodes opened this issue Nov 13, 2023 · 3 comments

Comments

@noahrhodes
Copy link

Is is possible to make a geo plot of line segments equivalent to this example from python's plotly?

https://plotly.com/python/lines-on-maps/#lines-on-maps-from-geopandas

I am not able to find a code example in the documentation. When I try to use geojson data and plot linesegments!(), the multilinestring does not seem to convert properly.

linesegments!(ga, powerlines, color=:white)

ERROR: MethodError: no method matching convert_arguments(::PointBased, ::Vector{AbstractVector})
Closest candidates are:
  convert_arguments(::PointBased, ::AbstractArray, !Matched::AbstractMatrix, !Matched::AbstractArray) at C:\Users\noahx\.julia\packages\Makie\RgxaV\src\conversions.jl:120
  convert_arguments(::PointBased, ::AbstractArray, !Matched::AbstractVector, !Matched::AbstractMatrix) at C:\Users\noahx\.julia\packages\Makie\RgxaV\src\conversions.jl:112
  convert_arguments(!Matched::SurfaceLike, ::AbstractVector{T1}, !Matched::AbstractVector{T2}, !Matched::Function) where {T1, T2} at C:\Users\noahx\.julia\packages\Makie\RgxaV\src\conversions.jl:420
  ...
Stacktrace:

convert_arguments(T::Type{LineSegments{Tuple{GeoJSON.FeatureCollection{2, Float32}}}}, args::Vector{AbstractVector}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at [conversions.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

convert_arguments(T::Type{LineSegments{Tuple{GeoJSON.FeatureCollection{2, Float32}}}}, args::Vector{AbstractVector}) at [conversions.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

convert_arguments(P::Type{LineSegments{Tuple{GeoJSON.FeatureCollection{2, Float32}}}}, geom::GeoJSON.FeatureCollection{2, Float32}) at [conversions.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

plot!(scene::Scene, P::Type{LineSegments}, attributes::Attributes, args::GeoJSON.FeatureCollection{2, Float32}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at [interfaces.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

plot! at [interfaces.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

plot!(la::Axis, P::Type{LineSegments}, attributes::Attributes, args::GeoJSON.FeatureCollection{2, Float32}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at [axis.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

plot! at [axis.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

#plot!#1552 at [axis.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

linesegments!(::Axis, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Symbol, Tuple{Symbol}, NamedTuple{(:color,), Tuple{Symbol}}}) at [recipes.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

top-level scope at [plot_grid.jl](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
@asinghvi17
Copy link
Member

What's the type of powerlines here? Looks like the contents are too abstract for Makie to be able to dispatch on them - if you could tighten up the type there it would probably help a lot.

Are you going straight from GeoJSON to Makie or do you do some intermediate processing?

@asinghvi17
Copy link
Member

As an update, I tried something similar in #207 and it looks like Makie doesn't support vectors of vectors of points....this needs more looking into.

@asinghvi17
Copy link
Member

I have added multilinestring support for Makie in the master branch, so this should work now, especially if you pass GeoMakie.to_multilinestring(powerlines) as input to linesegments.

Also, I don't think linesegments will perform correctly - are you sure you don't want lines instead?

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

2 participants