Linestring do not show in Mapbox

Running locally on MacBook Pro Apple M2 Max

Trying to create a layer with many polygons, municipalities in a country.
I have a geojson file with nearly 30.000 lines, close to 80 MB. It has a column geometry with datatype geometry.
I have gotten a Mapbox token that is inside a config.toml file. I can do scatterplots in Mapbox bye the way.
The result is a blank map with no lines on it.
Where to start debugging this issue?

The code:

import streamlit as st
import pandas as pd
import pydeck as pdk
import numpy as np
import matplotlib.pyplot as plt
import geopandas as gpd

st.title('municipalities')
st.write('This app shows the location of municipalities.')

# Read the GeoJSON data
kom_df = gpd.read_file('mun.geojson')
print(kom_df.head())
print(kom_df.info())

# Create a polygon layer
polygon_layer = pdk.Layer(
    'GeoJsonLayer',
    id='municipalities',
    data=kom_df,
    get_polygon='geometry',  # Use the 'geometry' attribute to access the polygon geometry
    opacity=0.8,
    stroked=True,
    filled=True,
    extruded=True,
    wireframe=True,
    get_elevation="elevation",
    get_fill_color="fill_color",
    get_line_color=[0, 0, 0],  # Set the line color to red
    auto_highlight=True,
    pickable=True,
    line_width = 20
)

# Create a deck with the polygon layer
deck = pdk.Deck(
    map_provider='mapbox',  # Use Mapbox as the map provider
    map_style='mapbox://styles/mapbox/light-v9',  
    initial_view_state=pdk.ViewState(
        latitude=64,
        longitude=11,
        zoom=5
    ),
    layers=[polygon_layer]
)


# Render the deck
st.pydeck_chart(deck)

Found that the geometry actually is a line string, not a polygon.

"type" : "Feature",
				"geometry" : {
					"type" : "LineString",
					"coordinates" : [
						[ 288015.22, 6684315.95 ],
						[ 288028.68, 6684317.98 ],
						[ 288044.91, 6684320.48 ],
						[ 288046.77, 6684320.66 ],
						[ 288044.36, 6684311.3 ],
						[ 288043.71, 6684307.59 ],
						[ 288042.26, 6684300.94 ],
						[ 288041.23, 6684294.41 ],
						[ 288040.6, 6684290.72 ],
						[ 288039.88, 6684287.2 ],
						[ 288038.68, 6684281.07 ],
						[ 288037.66, 6684276.2 ],
						[ 288037, 6684272.45 ],
						[ 288036.69, 6684269.47 ],
						[ 288035.44, 6684264.32 ],
						[ 288035.26, 6684258.46 ],
						[ 288034.74, 6684254.96 ],
						[ 288034.69, 6684251.11 ],
						[ 288034.27, 6684247.73 ],
						[ 288034.13, 6684240.82 ],
						[ 288034.33, 6684237.32 ],
						[ 288034.46, 6684233.06 ],
						[ 288034.9, 6684229.73 ],
						[ 288035.99, 6684224.32 ],
						[ 288037.13, 6684218.97 ],
						[ 288041.55, 6684212.3 ],
						[ 288043.88, 6684209.03 ],
						[ 288046.8, 6684206.66 ],
						[ 288049.83, 6684204.15 ],
						[ 288052.87, 6684201.25 ],
						[ 288055.87, 6684199.51 ],
						[ 288058.39, 6684197.9 ],
						[ 288061.46, 6684195.22 ],
						[ 288065.58, 6684193.47 ],
						[ 288068.73, 6684191.38 ],
						[ 288071.37, 6684189.79 ],
						[ 288082.21, 6684187.93 ]
					]
				},
				"properties" : {
					"objtype" : "Grense",
					"identifikasjon.Identifikasjon.lokalId" : "0013634f-6156-3dc6-8e8c-eb64db29075e",
					"identifikasjon.Identifikasjon.navnerom" : "https://data.geonorge.no/sosi/inndelinger/inndelingsbase/kommuner",
					"identifikasjon.Identifikasjon.versjonId" : null,
					"oppdateringsdato" : "2023-11-07T21:53:34+01:00",
					"gyldigFra" : "20231107",
					"gyldigTil" : null,
					"datafangstdato" : null,
					"kvalitet.Posisjonskvalitet.målemetode" : "55",
					"kvalitet.Posisjonskvalitet.nøyaktighet" : 200,
					"datauttaksdato" : "2024-03-04T12:27:11+01:00",
					"opphav" : "Kartverket",
					"avgrensningstype" : "Kommunegrense"
				}
			},

This is an example of what the json file contains.
Can I use GeoJSONLayer?
How do I read the LineString with its coordinates?
The coordinates list length can variate a lot.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.