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)