Skip to content

Instantly share code, notes, and snippets.

@stellasia
Created January 8, 2021 13:07
Show Gist options
  • Select an option

  • Save stellasia/8ea93a0e172af3a16d773fe1352534be to your computer and use it in GitHub Desktop.

Select an option

Save stellasia/8ea93a0e172af3a16d773fe1352534be to your computer and use it in GitHub Desktop.
Create a map with Python and folium
import folium
center_point = [48.857456, 2.340145]
m = folium.Map(
location=center_point,
zoom_start=13
)
# Add simple point markers
for point in points:
folium.Marker([point["latitude"], point["longitude"]]).add_to(m)
# Add point markers with tooltip and specific icon (font-awesome)
for point in am.other_points:
folium.Marker([point["latitude"], point["longitude"]], tooltip=f'{point["id"]}',
icon=folium.Icon(color='red', icon="arrow-up")
).add_to(m)
# Add geojson to map
# read commune boundaries
with open("../data/shapes.geojson") as f:
administrative_boundaries = json.load(f)
def style_function(feature):
return {
'weight': 3,
'color': "black",
'fillColor': None,
'fillOpacity': 0.0,
}
folium.GeoJson(
administrative_boundaries,
name='Administrative Boundaries',
style_function=style_function,
).add_to(m)
# Display or save map
# m.save("map.html")
m # display in a Jupyter notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment