Skip to content

BoundsError when plotting linestrings with colour #374

Description

@shriv

Hi there,
I'm a beginner wanting to use GeoMakie for transport data science. Common use cases include colouring road segment linestrings with some value. However, I get a bounds error when trying the following reprex. The only approaches that work involve looping over the geoms for plotting or for creating a separate vector for x, y and colour. Is there something I'm doing wrong?

Triggered by update of:
  alpha, colormap, space, colorscale, clip_planes, projection, highclip, nan_color, viewport, arg1, f32c, model, colorrange, color, view, transform_func, linewidth or lowclip
Due to ERROR: BoundsError: attempt to access 3-element Vector{RGBA{Float32}} at index [4]
using CairoMakie, GeoMakie, ArchGDAL

wkt_strings = [
    "LINESTRING (174.70 -36.80, 174.73 -36.83, 174.76 -36.86, 174.80 -36.90)",
    "LINESTRING (174.80 -36.70, 174.83 -36.73, 174.86 -36.76, 174.90 -36.80)",
    "LINESTRING (174.60 -36.90, 174.63 -36.93, 174.66 -36.96, 174.70 -37.00)",
]
values = [1.0, 2.0, 3.0]

geoms = ArchGDAL.fromWKT.(wkt_strings)

fig = Figure()
ga = GeoAxis(fig[1, 1]; source = "+proj=longlat +datum=WGS84")
lines!(ga, geoms; color = values, colormap = :viridis)
fig

System

Julia 1.12.5
GeoMakie 0.7.16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions