Hot answers tagged

12 votes
Accepted

How can I include HTML in a Folium Marker popup?

You should check the Folium version you are using. 0.2.0 has changed how popups are added, as explained in this issue thread: https://github.com/python-visualization/folium/issues/360 Popups now no ...
Nevermore's user avatar
  • 236
11 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,015
8 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
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
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,209
7 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
  • 22.9k
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
  • 54.2k
7 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
  • 30.1k
7 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
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
  • 54.2k
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
  • 61.6k
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
5 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
  • 51
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

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
  • 61
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,136
4 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,336
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

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,688
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.3k
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
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
  • 591
3 votes

Folium and MarkerCluster?

In your first case, you're adding Marker objects iteratively to your MarkerCluster. In the second case, you are just giving a list of coordinates, but not Marker objects. Convert your locations list ...
alphabetasoup's user avatar
3 votes

Turn Layer off by default in Leaflet LayerControl

I've never used Python, but if you look at the Folium docs at https://python-visualization.github.io/folium/modules.html?highlight=featuregroup#folium.map.FeatureGroup, you'll se that folium.map....
TomazicM's user avatar
  • 22.9k
3 votes

Get coordinates from Folium's feature LatLngPopup in Python

Look at this site. I think this may interest you: https://github.com/python-visualization/folium/blob/master/examples/plugin-MousePosition.ipynb import folium from folium.plugins import MousePosition ...
gregoss24's user avatar

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