Last active
June 11, 2020 22:14
-
-
Save morkapronczay/a78f4fa19065ef949c598ba00ed8e754 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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