Python 使用Streamlight显示地图在位置34处接收JSON中意外的令牌N时出错

Python 使用Streamlight显示地图在位置34处接收JSON中意外的令牌N时出错,python,Python,将日期时间导入为dt 作为pd进口熊猫 将U数据读取器作为pdr导入 导入matplotlib 将matplotlib.pyplot作为plt导入 将matplotlib.dates导入为日期 将numpy作为np导入 #将NATLPARK作为pnp导入 作为gpd导入geopandas 作为gp导入geopy 以gm身份导入谷歌地图 将pydeck导入为pdk 漂亮地进口 进口西皮 导入地理距离 从geopy.geocoders导入提名 从shapely.geometry导入点 从shapel

将日期时间导入为dt
作为pd进口熊猫
将U数据读取器作为pdr导入
导入matplotlib
将matplotlib.pyplot作为plt导入
将matplotlib.dates导入为日期
将numpy作为np导入
#将NATLPARK作为pnp导入
作为gpd导入geopandas
作为gp导入geopy
以gm身份导入谷歌地图
将pydeck导入为pdk
漂亮地进口
进口西皮
导入地理距离
从geopy.geocoders导入提名
从shapely.geometry导入点
从shapely.ops导入最近的_点
从scipy.spatial导入cKDTree
将scipy.spatial导入为spatial
导入streamlit作为st
def关闭方式(pt、位置、lst):
数据=pd.read\u csv('National\u Register\u of \u Historical\u Places(3.csv'))
关闭位置=[]
位置纬度=浮动(位置纬度)
位置经度=浮动(位置经度)
#对于索引,data.itterrows()中的行:
close_locations=[shapely.geometry.Point(lon,lat)表示lon,lat在zip中(数据['Longitude'],数据['Latitude'])]
gdf=gpd.GeoDataFrame(数据,几何体=close_位置,crs={“init”:“EPSG:4326”})
pts=gdf.geometry.uniary\u并集
ptsArray=np.数组(pts)
打印(ptsArray)
point_tree=spatial.KDTree(ptsArray)
query=point\u tree.query\u ball\u point([location.longitude,location.latitude],1)
otherLst=[]
对于范围内的i(len(query)):
值=查询[i]
lst.append(gdf.iloc[value])
otherLst.append(gdf.iloc[value][0])
st.write(“附近国家公园列表”)
st.write(其他LST)
返回lst
def显示图(数据,lst):
本地=[]
对于范围内的i(len(数据)):
如果lst中的数据索引[i]:
local.append(数据[i][0]、数据[i][5]、数据[i][6])
map_df=pd.DataFrame(本地,列=['资源名称','经度','纬度')
view_state=pdk.ViewState(经度=map_df['longide'].mean(),纬度=map_df['latitude'].mean(),缩放=10,俯仰=0)
layer=pdk.layer('ScatterplotLayer',data=map\u df,get\u position='[经度,纬度]',get\u半径=50,get\u color=[0255255],pickable=True)
工具提示={'html':'资源名称:
import datetime as dt
import pandas as pd
import pandas_datareader as pdr
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.dates as dates
import numpy as np
#import natlparks as pnp
import geopandas as gpd
import geopy as gp
import googlemaps as gm
import pydeck as pdk
import shapely
import scipy
import geopy.distance
from geopy.geocoders import Nominatim
from shapely.geometry import Point
from shapely.ops import nearest_points
from scipy.spatial import cKDTree
import scipy.spatial as spatial
import streamlit as st

def close_by(pt, location, lst):
    data = pd.read_csv('National_Register_of_Historic_Places (3).csv')
    close_locations = []
    location_latitude = float(location.latitude)
    location_longitude = float(location.longitude)
    #for index, row in data.itterrows():
    close_locations = [shapely.geometry.Point(lon, lat) for lon,lat in zip(data['Longitude'], data['Latitude'])]
    gdf = gpd.GeoDataFrame(data, geometry=close_locations, crs={"init":"EPSG:4326"})
    pts = gdf.geometry.unary_union
    ptsArray = np.array(pts)
    print(ptsArray)
    point_tree = spatial.KDTree(ptsArray)
    query = point_tree.query_ball_point([location.longitude, location.latitude], 1)
    otherLst = []
    for i in range(len(query)):
        value = query[i]
        lst.append(gdf.iloc[value])
        otherLst.append(gdf.iloc[value][0])
    st.write("List of Nearby National Parks")
    st.write(otherLst)
    return lst

def display_map(data, lst):
    local = []
    for i in range(len(data)):
        if data.index[i] in lst:
            local.append(data[i][0], data[i][5], data[i][6])
    map_df = pd.DataFrame(local, columns=['Resource Name', 'Longitude', 'Latitude'])
    view_state = pdk.ViewState(longitude=map_df['Longitude'].mean(), latitude=map_df['Latitude'].mean(),zoom=10, pitch=0)
    layer = pdk.Layer('ScatterplotLayer', data=map_df, get_position='[Longitude, Latitude]', get_radius = 50, get_color = [0,255,255], pickable=True)
    tool_tip = {'html': 'Resource Name:<br/.{Resource Name}', 'style': {'backgroundColor': 'steelblue', 'color': 'white'}}
    map = pdk.Deck(map_style='mapbox://styles/mapbox/light-b9', initial_view_state=view_state, layers=[layer], tooltip = tool_tip)

    st.pydeck_chart(map)




def main():
    data = pd.read_csv('National_Register_of_Historic_Places (3).csv')
    st.title("Finding NY National Parks Near You")
    streetNum = st.text_input("Enter your number")
    streetName = st.text_input("Enter Your Street Name")
    city = st.text_input("Enter your city")
    lst =[]
    geolocator = Nominatim(user_agent="Final_Project_Python")
    location = geolocator.geocode(f"{streetNum} {streetName} {city} ")
    pt = Point(location.longitude, location.latitude)
    close_by(pt, location, lst)
    st.write('Map of Nearby Locations')
    display_map(data, lst)

main()