Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Cloropleth não funciona

''' Tentei rodar mais não funciona segue as informações abaixo:

crs = {'init': 'epsg:4326'}

pyproj: '1.9.6' geopandas: '0.4.1'

base = folium.Map([y, x], zoom_start=11)

base.choropleth(rj)

base '''

C:\Users\eoliv\anaconda3\lib\site-packages\folium\folium.py:415: FutureWarning: The choropleth method has been deprecated. Instead use the new Choropleth class, which has the same arguments. See the example notebook 'GeoJSON_and_choropleth' for how to do this.

FutureWarning

RuntimeError Traceback (most recent call last) in 1 base = folium.Map([y, x], zoom_start=11) ----> 2 base.choropleth(rj) 3 base

~\anaconda3\lib\site-packages\folium\folium.py in choropleth(self, args, **kwargs) 416 ) 417 from folium.features import Choropleth --> 418 self.add_child(Choropleth(args, **kwargs)) 419 420 def keep_in_front(self, *args):

~\anaconda3\lib\site-packages\folium\features.py in init(self, geo_data, data, columns, key_on, bins, fill_color, nan_fill_color, fill_opacity, nan_fill_opacity, line_color, line_weight, line_opacity, name, legend_name, overlay, control, show, topojson, smooth_factor, highlight, **kwargs) 1249 style_function=style_function, 1250 smooth_factor=smooth_factor, -> 1251 highlight_function=highlight_function if highlight else None) 1252 1253 self.add_child(self.geojson)

~\anaconda3\lib\site-packages\folium\features.py in init(self, data, style_function, highlight_function, name, overlay, control, show, smooth_factor, tooltip, embed, popup) 451 self.highlight = highlight_function is not None 452 --> 453 self.data = self.process_data(data) 454 455 if self.style or self.highlight:

~\anaconda3\lib\site-packages\folium\features.py in process_data(self, data) 493 self.embed = True 494 if hasattr(data, 'to_crs'): --> 495 data = data.to_crs('EPSG:4326') 496 return json.loads(json.dumps(data.geo_interface)) 497 else:

~\anaconda3\lib\site-packages\geopandas\geodataframe.py in to_crs(self, crs, epsg, inplace) 441 else: 442 df = self.copy() --> 443 geom = df.geometry.to_crs(crs=crs, epsg=epsg) 444 df.geometry = geom 445 df.crs = geom.crs

~\anaconda3\lib\site-packages\geopandas\geoseries.py in to_crs(self, crs, epsg) 303 raise TypeError('Must set either crs or epsg for output.') 304 proj_in = pyproj.Proj(self.crs, preserve_units=True) --> 305 proj_out = pyproj.Proj(crs, preserve_units=True) 306 project = partial(pyproj.transform, proj_in, proj_out) 307 result = self.apply(lambda geom: transform(project, geom))

~\anaconda3\lib\site-packages\pyproj_init__.py in new(self, projparams, preserveunits, *kwargs) 360 # on case-insensitive filesystems). 361 projstring = projstring.replace('EPSG','epsg') --> 362 return proj.Proj._new__(self, projstring) 363 364 def call(self, *args, *kw):

proj.pyx in proj.Proj.cinit__()

RuntimeError: b'no arguments in initialization list'

2 respostas

Olá Eduardo,

O choropleth não funciona mais desta forma. Para fazer funcionar utilize

base = folium.Map([y,x], zoom_start=11, tiles='OpenStreetMap')
folium.Choropleth(rj).add_to(base)
base

O popup que o instrutor faz na sequência também não está funcionando muito bem. Para esse último não tenho uma solução.

solução!

Boa tarde Allan

Como queria resolver logo e como já tinha um post de fevereiro com o mesmo problema sem responder, acabei pesquisando um pouco na documentação, mais o que o pessoal falava em outros fóruns. Da forma que vc colocou tentei fazer e tb não funcionou, isso ontem de noite mas como eu tinha modificação várias vezes as versões, não sei se foi isso, como eu estava cabreiro com o problema hj de manhã quebrei a cabeça e descobri. Na verdade temos vários problemas nesse treinamento confesso que tive diversos problemas começando pela dificuldade de instalação do geopandas, mas continuando temos 2 problemas nesse treinamento que são incompatíveis entre si. O fillna não funciona mais na versão do geopandas 0.8 e uma das aulas precisava utilizar e não funcionava, então olhando a documentação vi que as versões mais novas do geopandas realmente tiraram a utilização do fillna, fiz o downgrade para a 0.4 e funcionou porém, quando vc faz um downgrade, automaticamente o pyproj vai para a versão 1.9.6 e assim o choropleth passa a não funcionar. Solução minha foi colocar tudo na última versão, no lugar do fillna utilizei o replace com o np.nan e o crs estou utilizando o 4674 para todo o curso e tem uma diferença na programação quando vc modifica o crs para a versão do pyproj 2.6 que é diferente da aula. Obrigado pelo retorno

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software