Summary
I am getting an intermittent Syntax error (Edge):
The error is slightly different with Chrome:
The behaviour is strange, sometimes the page works flawlessly, then it will âfailâ, it doesnât always produce this error on the same component, sometimes a simple line of text will produce the error.
If i do the following code:
st.map(data)
st.map(data)
I will get the error on the first line, but the second will work fine.
I wonder if this is related to st.experimental_data_editor as it is usually the next component after that which fails?
Steps to reproduce
Code snippet:
import streamlit as st
import pandas as pd
import pydeck as pdk
import pyproj
def E_N_to_lat_lon(easting, northing, utm_band):
# Define the projection
out_proj = pyproj.Proj(proj='latlong', datum='WGS84')
in_proj = pyproj.Proj(proj='utm', zone=utm_band, datum='WGS84')
# Convert the coordinates
lon, lat = pyproj.transform(in_proj, out_proj, easting, northing)
return(lat, lon)
st.set_page_config(layout="wide")
st.title('SPLAT - CTV Routing Optimisation')
coord_type = st.radio('Coordinate Reference System',
options=['Easting & Northing','Lat/Long'],
horizontal=True)
if coord_type == 'Lat/Long':
input_data = pd.DataFrame({
"Location Name":str,
"Latitude":[] ,
"Longitude":[]})
else:
input_data = pd.DataFrame({
"Location Name":str,
"Easting":[] ,
"Northing":[]})
utm = st.number_input('UTM Zone', min_value=1, max_value=60, step=None,
format=None, key=None, help=None, on_change=None,
args=None, kwargs=None, disabled=False, value=31,
label_visibility="visible")
st.write("Click here for UTM zone map https://www.dmap.co.uk/utmworld.htm")
data = st.experimental_data_editor(input_data, use_container_width=True,
num_rows="dynamic")
if coord_type != 'Lat/Long':
data2 = list(zip(data.Easting, data.Northing))
data2 = [E_N_to_lat_lon(x,y,utm) for x,y in data2]
else:
data2 = list(zip(data.Latitude, data.Longitude))
data_df = pd.DataFrame (data2, columns = ['latitude', 'longitude'])
data_df['Location Name'] = data['Location Name']
st.dataframe(data_df)
# st.map(data_df)
st.pydeck_chart(pdk.Deck(
map_style=None,
initial_view_state=pdk.ViewState(
longitude=data_df.longitude.mean(),
latitude=data_df.latitude.mean(),
zoom=7,
min_zoom=2,
max_zoom=10,
pitch=0,
bearing=0
),
layers=[
pdk.Layer(
'ScatterplotLayer',
data=data_df,
radius_scale=6,
pickable= True,
radiusScale= 1,
radiusMinPixels= 3,
radiusMaxPixels= 10,
get_position='[longitude, latitude]',
get_color='[200, 30, 0]',
),
],
))
Debug info
- Streamlit version: 1.19
- Python version: 3.9.16
- Using Pip
- OS version: Windows 10
- Browser version: Edge 103, Chrome 110
Thank you in advance for any help!