Interactive Map Using Plotly
The following, is a simple example of an interactive map using Plotly. The map contains information for the unemployment rate in the city of Bogotá for the year 2017.
from urllib.request import urlopen
import json
import geopandas as gpd
import plotly.express as px
bog_url = "https://serviciosgis.catastrobogota.gov.co/arcgis/rest/services/desarrolloeconomico/tasadedesempleo/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentsOnly=false&datumTransformation=¶meterValues=&rangeValues=&f=geojson"
with urlopen(bog_url) as url:
jdata = json.loads(url.read().decode())
print(jdata.keys())
unempDF = gpd.read_file(bog_url)
fig = px.choropleth_mapbox(unempDF,
geojson=jdata,
locations = 'LOCCODIGO',
color = 'ITD2017',
color_continuous_scale='Jet',
range_color=(3, 12),
mapbox_style="carto-positron",
zoom=9.4, center = {"lat": 4.624335, "lon": -74.063644},
opacity=0.5,
labels={'ITD2017':'unemployment rate'}
)
fig.update_layout(title_text='Unemployment Rate (Bogotá, 2017)',
margin={"r":0,"t":26,"l":0,"b":0})
fig.show()