Plot map/geojson using Vega in Livebook

Hi!

I’m new to elixir world and to learn a few things I got into a project of fetching data from an API and plotting some stuff. The data I want to plot is map/geo data from a Finnish WebFeatureServer.

After fetching the data, I’m doing something like:

base_map =
  Vl.new(width: 400, height: 400)
  |> Vl.data_from_values(features ,format: :json , type: :featureCollection)
  |> Vl.projection(type: :mercator)
  |> Vl.mark(:geoshape)
  |> Vl.encode_field(:color, "properties.naiset", type: :quantitative)

where features is the list of features from the server, but the result is not what I hoped for: Pasteboard - Uploaded Image

I tried analysing the Vega Spec output, since I’m also new to Vega I’m not quite sure what I’m doing wrong (my guess is something with the scale or projection)

%{
  "$schema" => "https://vega.github.io/schema/vega-lite/v5.json",
  "data" => %{
    "format" => "json",
    "type" => "featurecollection",
    "values" => [
      %{
        "bbox" => [243238.7074, 7276001.5097, 627859.7, 7776430.911],
        "geometry" => %{
          "coordinates" => [
            [
              [412373.1985, 7276001.5097],
              [413803.717, 7277425.091],
              [427779.649, 7292121.84],
              [444538.768, 7291543.363],
              [451429.652, 7295129.029],
              [461616.22, 7300363.885],
              [461385.917, 7289578.81],
              [491950.939, 7286610.701],
              [503301.393, 7289791.985],
              [518535.957, 7313104.574],
              [523951.184, 7311273.286],
              [529768.18, 7315646.993],
              [534776.431, 7300873.374],
              [555960.827, 7298229.095],
              [569086.753, 7303600.565],
              [568767.928, 7308451.269],
              [562371.144, 7316158.058],
              [563104.105, 7320196.602],
              [570051.364, 7321770.669],
              [575008.83, 7319436.645],
              [579288.478, 7321216.143],
              [579928.398, 7325866.071],
              [573532.923, 7328766.401],
              [572435.541, 7335122.877],
              [577450.11, 7336119.469],
              [578610.673, 7349374.686],
              [571535.284, 7350680.086],
              [568892.525, 7357831.516],
              [575470.26, 7375090.259],
              [600847.92, 7367226.299],
              [600723.816, 7369982.334],
              [614767.566, 7370520.926],
              [612103.6, 7377488.2],
              [609809.277, 7382629.323],
              [606883.5, 7386978.2],
              [605693.5, 7389646.3],
              [604456, 7393092.6],
              [594548.9, 7408533.9],
              [593130.4, ...],
              [...],
              ...
            ]
          ],
          "type" => "Polygon"
        },
        "geometry_name" => "geom",
        "id" => "avi_vaki2020.6",
        "properties" => %{
          "avi" => "6",
          "ika_0_14" => 26094,
          "ika_0_14p" => 14.8,
          "ika_15_64" => 104662,
          "ika_15_64p" => 59.2,
          "ika_65_" => 45909,
          "ika_65_p" => 26,
          "miehet" => 88437,
          "miehet_p" => 50.1,
          "naiset" => 88228,
          "naiset_p" => 49.9,
          "name" => "Lapland AVI",
          "namn" => "Lapplands RFV",
          "nimi" => "Lapin AVI",
          "til_vuosi" => 2020,
          "vaesto" => 176665,
          "vaesto_p" => 3.2,
          "vuosi" => 2021
        },
        "type" => "Feature"
      }
    ]
  },
  "encoding" => %{"color" => %{"field" => "properties.naiset", "type" => "quantitative"}},
  "height" => 400,
  "mark" => "geoshape",
  "projection" => %{"type" => "mercator"},
  "width" => 400
}

Any ideas what can be going wrong?

Thanks for your time and I appreciate any help!

Thanks!