Home > front end >  Issue plotting GeoJSON with python's plotly cloropleth
Issue plotting GeoJSON with python's plotly cloropleth

Time:09-17

I'm trying to plot from a geojson with the following structure:

import geopandas as gpd
states = gpd.read_file('diamante.geojson')
display(states.head())

enter image description here

This was obtained by converting from .shp, shx, prj, etc using mygeoconverter. The link column is my reference for merging with another dataframe later on with proper labels. The shape information seems fine as I get a basic plot from geopandas.

states.plot(aspect=1)

enter image description here

I do not know why i need the aspect=1 parameter in order for it to work. When trying to plot my map using plotly I get the following:

import pyproj
#states.to_crs(pyproj.CRS.from_epsg(4326), inplace=True)
fig = px.choropleth(states, geojson=states['geometry'], locations=states.index, color=states.varon)
fig.show()

enter image description here

The commented line was an attempt to solve the issue based on another post, which didn't seem to do anything. I am new to mapping so I don't know what to look for. enter image description here

  • Related