Skip to content

Instantly share code, notes, and snippets.

@morkapronczay
Last active June 11, 2020 22:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morkapronczay/a78f4fa19065ef949c598ba00ed8e754 to your computer and use it in GitHub Desktop.
Save morkapronczay/a78f4fa19065ef949c598ba00ed8e754 to your computer and use it in GitHub Desktop.
import geopandas as gpd
import folium
import matplotlib.pyplot as plt
# read date
url = 'https://geoservicos.pbh.gov.br/geoserver/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=ide_bhgeo:BAIRRO&srsName=EPSG:31983&outputFormat=application%2Fjson'
gdf = gpd.read_file(url)
# check if data is right
fig, ax = plt.subplots(figsize=(10,10))
gdf.plot(ax=ax)
# convert to lat-long
gdf = gdf.to_crs(epsg=4326)
# create map
bh = gdf[['id','geometry', 'NOME']]
x_map=bh.geometry.centroid.x.mean()
y_map=bh.geometry.centroid.y.mean()
mymap = folium.Map(location=[y_map, x_map], zoom_start=11,tiles='OpenStreetMap')
# add polygons to map
folium.GeoJson(
gdf
).add_to(mymap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment