带有cvs数据的大叶

时间:2019-03-21 19:17:23

标签: python folium

我有以下代码。不幸的是,它无法按预期工作。

#import modeules
import folium
import geopandas as gpd
import pandas as pd

#create a folium map
m = folium.Map(location=[-23.533773, -46.625290], zoom_start = 6)

#read and add JSON file for limits
geo = folium.GeoJson(
    r'C:\Users\lsminervino\Google Drive\SEDS\Convênio SPG-SEDS- Fundação SEADE\Bases de Dados\Base para mapas\mapa_base\mapa_base.geojson').add_to(m)


#Upload do arquivo csv
csv_path=(r'C:\Users\lsminervino\Google Drive\SEDS\Convênio SPG-SEDS- Fundação SEADE\Bases de Dados\Base para mapas\pessoas_cadastradas_municipio_raça_perc.csv')
df=pd.read_csv(csv_path, engine='python', sep=';')

df.head()

dataframe

folium.Choropleth(geo_data=geo,
name='geometry',
data=df2,
columns=['% preto','% Parda','% Branca','% Amarela','% Indigena'],
key_on='Feature.properties.name',
fill_color='YlGn',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='% de cadastrados por cor'
).add_to(m)

运行脚本时出现此错误,我不知道为什么:

  

TypeError:输入类型不支持ufunc'isnan',并且根据强制转换规则“ safe”,不能将输入安全地强制转换为任何受支持的类型

有人知道为什么吗?

以下是JSON文件的示例:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "name": "Adamantina",
                "styleUrl": "#borda"
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [-51.1503, -21.65947],
                    [-51.15964, -21.6614],
                    [-51.1655, -21.674],
                    [-51.17289, -21.68237],
                    [-51.17731, -21.69243],
                    [-51.16881, -21.69734],
                    [-51.16034, -21.70349],
                    [-51.15096, -21.70601],
                    [-51.14944, -21.72152],
                    [-51.14057, -21.72641],
                    [-51.13304, -21.73526],
                    [-51.13284, -21.75022],
                    [-51.12441, -21.75606],
                    [-51.11567, -21.75999],
                    [-51.10608, -21.76172],
                    [-51.0964, -21.76329],
                    [-51.09228, -21.76581],
                    [-51.09211, -21.74911],
                    [-51.08634, -21.73734],
                    [-51.08587, -21.72282],
                    [-51.07685, -21.72239],
                    [-51.06739, -21.71887],
                    [-51.05878, -21.714],
                    [-51.04964, -21.70932],
                    [-51.04007, -21.7051],
                    [-51.03834, -21.68968],
                    [-51.03718, -21.675],
                    [-51.03622, -21.66048],
                    [-51.03176, -21.64786],
                    [-51.02336, -21.64231],
                    [-51.01475, -21.6371],
                    [-51.00796, -21.62687],
                    [-51.00513, -21.61314],
                    [-50.99731, -21.60477],
                    [-50.98859, -21.60022],
                    [-50.98084, -21.59267],
                    [-50.97854, -21.57883],
                    [-50.97169, -21.56906],
                    [-50.97473, -21.55533],
                    [-50.96891, -21.54383],
                    [-50.96667, -21.52986],
                    [-50.96894, -21.51555],
                    [-50.96601, -21.50158],
                    [-50.96629, -21.48727],
                    [-50.96947, -21.47346],
                    [-50.96986, -21.47141],
                    [-50.97546, -21.45917],
                    [-50.98243, -21.45008],
                    [-50.99112, -21.44261],
                    [-50.99307, -21.43727],
                    [-51.00382, -21.43901],
                    [-51.01303, -21.43388],
                    [-51.02159, -21.42893],
                    [-51.02899, -21.41862],
                    [-51.03643, -21.40848],
                    [-51.04592, -21.40683],
                    [-51.05536, -21.40423],
                    [-51.05835, -21.39935],
                    [-51.06644, -21.40911],
                    [-51.07339, -21.41932],
                    [-51.08149, -21.42622],
                    [-51.08821, -21.43752],
                    [-51.08313, -21.44984],
                    [-51.08655, -21.4638],
                    [-51.09291, -21.47398],
                    [-51.09959, -21.4841],
                    [-51.10091, -21.49886],
                    [-51.10383, -21.51279],
                    [-51.10545, -21.5276],
                    [-51.10243, -21.54178],
                    [-51.10514, -21.5556],
                    [-51.10159, -21.56889],
                    [-51.09295, -21.57363],
                    [-51.08607, -21.58435],
                    [-51.08074, -21.59689],
                    [-51.08015, -21.61152],
                    [-51.0861, -21.62268],
                    [-51.09229, -21.63372],
                    [-51.10219, -21.63764],
                    [-51.10981, -21.64598],
                    [-51.11927, -21.64983],
                    [-51.12926, -21.65169],
                    [-51.13771, -21.65709],
                    [-51.1471, -21.65895],
                    [-51.1503, -21.65947]
                ]
            }
        }
    ]
}

0 个答案:

没有答案