Skip to main content
12 votes
Accepted

Adding graticules to Folium map

You can add graticules as polylines. First, set intervals of latitude and longitude. import folium m = folium.Map() lat_interval = 10 lon_interval = 10 grid = [] for lat in range(-90, 91, ...
Kadir Şahbaz's user avatar
10 votes
Accepted

Fill color not showing appropriately in folium?

According the documentation, when you're creating a CircleMarker object the fill parameter defaults to False. Try explicitly setting it to True in your code: #... for lt, ln, el in zip(lat, lon, ...
Ali's user avatar
  • 4,065
10 votes

Python folium package for 'satellite' map

You can also use ESRI Satellite for satellite images. I used this: tile = folium.TileLayer( tiles = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/...
Greg Kendall's user avatar
8 votes

Click event on maps with Folium and information retrieval

Actually I have found a great way to do it.. Folium has a feature named LatLngPopUp which creates a popup where you click on the map with its location. I've edited that popup and added a href link ...
Tal's user avatar
  • 81
8 votes
Accepted

What are Folium style_function parameters

The Geojson layer's style_function mimics the style function from Leaflet.js. Here are all the parameters.
beenjaminnn's user avatar
8 votes

Coordinate System Mismatch In Folium

There are several things you have to take into account when dealing with coordinates and coordinate systems in Leaflet. First, regardless of the coordinate system of the actual map displayed, all ...
TomazicM's user avatar
  • 26.3k
8 votes
Accepted

How to fully customise LayerControl() in Folium?

It's possible via combination of three informations All layers inherit from class Layer https://github.com/python-visualization/folium/blob/master/folium/map.py#L30 and one of the option states the ...
ThomasG77's user avatar
  • 31k
8 votes
Accepted

Exporting GeoJSON with defined properties using Folium Draw plugin

The JS script to be used in Python code: $(document).ready(function(){ var x = 0; // {map} will be replaced to map object using Python {map}.on("draw:created", ...
Kadir Şahbaz's user avatar
7 votes
Accepted

Using Mapbox tiles with folium

As per http://python-visualization.github.io/folium/quickstart.html "Folium supports passing any Leaflet.js compatible custom tileset" let lets try that and bypass it's built in support: folium.Map(...
AndrewHarvey's user avatar
  • 2,219
7 votes
Accepted

Mapping multiple polygons on Folium

If you use the data of Converting a column with coordinates in Pandas to GeoPandas, there is a problem with your location value or with your data The data in the GeoDataFrame x1,y1,x2,y2 = gdf['...
gene's user avatar
  • 55.1k
6 votes
Accepted

`folium.GeoJson` displays all polygons in GeoDataframe but not individual ones

Because gdf["geometry"]) is a GeoSerie and gdf["geometry"][0] is a shapely geometry (the geometry column is a list of shapely geometries). The type of data data=gdf["geometry&...
gene's user avatar
  • 55.1k
6 votes
Accepted

Identifying coordinate system from dataset (without using GIS software)

If you download the shapefile instead of the CSV you'll find a .prj file in the zip which is the projection metadata: PROJCS["NZGD_2000_New_Zealand_Transverse_Mercator",GEOGCS["...
Spacedman's user avatar
  • 65k
6 votes
Accepted

Python folium add marker in random place

Folium injects the JS code to a place before the line where map object is created. In the image, Line 1 is where folium adds the code. Line 2 is where the map object is created. Line 1 always run ...
Kadir Şahbaz's user avatar
6 votes
Accepted

Folium to display points in Leaflet map (from data stored in array)

Move m.save("index.html") to the end. # previous lines while i < len(marker)-1: folium.Marker([float(marker[i]), float(marker[i+1])], popup="new location", icon=folium.Icon(...
Kadir Şahbaz's user avatar
6 votes
Accepted

Control Layer Order/Z-Index of Custom DivIcon() Marker in Folium Map

Solution for your problem are Leaflet map panes (see https://leafletjs.com/reference.html#map-pane), which are DOM elements used to control the ordering of layers on the map. Each map pane has it's ...
TomazicM's user avatar
  • 26.3k
5 votes

Using Mapbox tiles with folium

The answer above is correct, but I wanted to add some detail of where Mapbox users can get the necessary url for the code. When in Mapbox Styles page, simply choose to share your style, and under '...
Mike W's user avatar
  • 71
5 votes

Click event on maps with Folium and information retrieval

You can use GeoJsonTooltip to show selected fields from a GeoDataFrame. usmap = folium.Map( location=[40,-95], tiles='cartodbpositron', zoom_start=5, control_scale=True ) folium....
Dataform's user avatar
  • 1,356
5 votes
Accepted

Reset map zoom based on added layers in Folium

Just tried this and it worked. map.fit_bounds(map.get_bounds(), padding=(30, 30))
ar-siddiqui's user avatar
  • 1,768
5 votes
Accepted

Draw a line between pairs of points with calculating the distance using Folium

You can use this script: import pandas as pd from pyproj import Transformer import folium df = pd.DataFrame({'name_origin (f)' : ['A', 'A', 'A', 'A', 'A', 'A', 'A'], 'x_origin' : [...
Kadir Şahbaz's user avatar
5 votes
Accepted

Python folium - Leaflet plugin not visible on the map

In png_js , change .addTo{map} to .addTo({map}) and wrap JS code in $(document).ready(function(){ ... }); Code: import folium m = folium.Map() m.get_root().header.add_child(folium.CssLink('https://...
Kadir Şahbaz's user avatar
4 votes
Accepted

Python folium package for 'satellite' map

Your code is almost correct. Fixed one: token = "pk...." # your mapbox token tileurl = 'https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.png?access_token=' + str(token) m = folium.Map( ...
JaakL's user avatar
  • 2,156
4 votes
Accepted

How to change circle opacity in Folium?

The parameter to control that is called fill_opacity. folium.Circle( location=[lat, long], color=colormap(city_ratio), radius=50*math.sqrt(city_pop), fill=True, opacity=0.8, ...
Anatolii Suhanov's user avatar
4 votes
Accepted

Folium draw and highlight polylines with distinct colours from unique GeoJSON

Solution (works perfectly)! It appears it is possible to achieve what I set to (see main question) within the extent of the style_function. We can pass values to the style_function properties in a ...
Indigo Wizard's user avatar
4 votes
Accepted

Highlight geometry in Folium map on hover

The answer is highlight_function... For example: folium.GeoJson( data=ecmap_gdf["geometry"], highlight_function= lambda feat: {'fillColor': 'blue'} ).add_to(m) May be must review ...
Cristhian Montoya Álava's user avatar
3 votes

Click event on maps with Folium and information retrieval

In my case I use folium plugin "Draw" for set markers and framework PyQt5. Everything work fine. from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets from folium.plugins import Draw ...
Vlad Chuenko's user avatar
3 votes
Accepted

Appropriate False return statement?

That comment by neighdough worked for me. I had to filter out the dataset using the statement data = data[data['MAG'] < 6.0] and everytime I wanted another filtering e.g. if Magnitude > 7.0: ...
Mehmud's user avatar
  • 601
3 votes

Folium Heat Maps

Apologies for the thread necromancy, but after having had to Google this for the Nth time, I wanted to go ahead and record here that the only thing wrong with the OP's code here is that HeatMap wants ...
A C's user avatar
  • 131
3 votes

error message 'module' object has no attribute 'MarkerCluster'

Just to expand a bit on @dslamb's answer, look at the imports in your code. You use: from folium.plugins import MarkerCluster And then in your code you do: marker_cluster = folium.MarkerCluster()....
Alex Leith's user avatar
  • 13.5k
3 votes

error message 'module' object has no attribute 'MarkerCluster'

According to this notebook (https://github.com/python-visualization/folium/blob/master/examples/MarkerCluster.ipynb) you should try calling MarkerCluster directly. This is because you have imported ...
dslamb's user avatar
  • 2,166
3 votes

How can I include HTML in a Folium Marker popup?

You can embed arbitrary HTML using folium.Html, with script=True. Here is a minimal example which demonstrates this: import folium m = folium.Map([51.5, -0.25], zoom_start=10) test = folium.Html('&...
alexkp's user avatar
  • 31

Only top scored, non community-wiki answers of a minimum length are eligible