Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Folium don't have two ways communication (From JavaScript to Python and the other way around). But ipyleaflet does, allowing you to do this kind of magic
    Thank you very much Martin for quick response.
    Ari Hartikainen
    Another, not so easy solution could be hack this functionality with eel, if you can edit the html/javascript https://github.com/samuelhwilliams/Eel
    Hi everyone! quick question, sorry if I'm too blunt. I have a bunch of markers clustered with MarkerCluster and a bunch of PolyLines to connect them. When I zoom out the markers cluster together but the PolyLines keep pointing to the original positions instead of the position of the cluster. Is there anyway to have the lines drawn between clusters?
    I speak little English! Question translated by the google translator. Folium too heavy, problem opening browser too much data. 30 thousand locations.
    I want to draw a wind animation like this: https://github.com/danwild/leaflet-velocity, but I don't know how to do with python/Folium, or other method?
    I see on the website below that he wants to do this in python, but he/she didn't give the method.
    Maybe someone here can help me?
    Hi! Is there any feature in place that can show location traces for a given observation (e.g. for longitudinal observations) - I'm wondering if there's any way to visualise movements between locations (like start, point1, point2, ...., end) for each observation with dotted lines between each point. If it isn't already a functionality in place, I think it would be something worthwhile!
    For visualizing movement you can use the antpath
    although it is not exactly what you are looking for it seems
    Ah. It might be - but I think something without the moving lines with intermediate points along the path would be useful
    Hi all. What is the best way to override Folium's default templating code? I have a custom basemap in .mbtiles format, and I can override the Folium defaults just fine to have my own L.TileLayer code. However, if I want to add additional basemaps, I need to use the default templates again. When saving to HTML, whatever is in the current template gets written... so you can't have it both ways. I'm guessing this is a jinja thing that I'm not aware of.
    ^ This was solved by overriding templates on TileLayer instances instead of the entire raster_layers.py at runtime.
    Hi everyone! I'm new of folium (1 week of practice, but seems a wonderful tool!). I didn't understand why when I'm installing folium with pip (as described in installation procedures), it seems to install an older version (with GeoJsonPopup not found and Choropleth available). When doing some research it seems that I have to install the master version from github.. is it the best way to proceed?
    Thanks a lot @and-viceversa !
    Martin Hvidberg
    Hi Group – I would like to migrate this site: http://snapseatlas.dk/ into something Python driven. The background map is OSM and the markers are showing data fro a SQL database. Is it possible to do this in Folum? Can I preserve the functionality of a selector, like the on in the top-right corner?
    Martin Hvidberg

    can folium read geopackage data? if not how can I convert the data from geopackage to geojson?

    @sarangjaiswal QGIS will do that for you.

    Garrison R.
    @MartinHvidberg_gitlab folium’s feature groups are the toggles. This could be created off any csv or data table.
    Garrison R.
    Or even using pandas to take the sql to a dataframe.
    Martin Hvidberg
    Thanks tor your answers. Just to make completely sure. Can it make dynamic map, where one user types in a new point to the database, and a moment later it is visible to everybody on the map? I have the 'typing in' covered, but I want to be sure that the map, generated by folium, can read live from the database, maybe via pandas. Whit 'live' i specifically mean: data is reloaded from the database, every time you open the map.
    I would like to see an example of a map generated with features from an SQL database, maybe using pandas. Can anybody point me to such an example, please.
    Hello All ! , I was wondering is there any calendar search button to use filter on date ranges in folium map ..I want to enter from_Date: ,To_Date:

    Hey guys,

    I wonder whether it's possible for DivIcon to have an automatic size.

    The context:
    On my map, hovering over a country will trigger a tooltip with the country's name.
    I also have several DivIcons, with the following code:

        location=[lat, lon],
                <div style="background-color: red; display: inline-block;">
                        <br />{region_info}
            icon_size=(100, 100),
            icon_anchor=(0, 0),  

    Because of the variation in region_names and region_infos, the width of the content varies between 50 and 90 pixels. I want my text to be displayed on two lines and the div to fit its content: the display: inline-block in the html allows me to do this, even if my icon_size is constant.

    But the problem is that the size of the DivIcon affects the tooltips: I can have a 70px-wide block with content, but an area of 30px next to it which doesn't display as a block but still counts as that block. So if I hover out of the visible block, instead of the tooltip appearing with some country's name, nothing happens. This is especially problematic when this area covers a bunch of small countries.

    What I'd like to happen is for the DivIcon to fit to the html within, or to have some kind of dynamic behaviour. I have tried doing icon_size=(10, 10) or removing icon_size, but the block just shrinks to fit to the longest word in the content. I have tried to go through the code for folium.DivIcon, branca.MacroElement, branca.Figure, etc., but wasn't able to get control of this behaviour.

    Any suggestions welcome.

    Hi, I am designing a choropleth dashboard with multiple layers to toggle on/off. Two open questions: 1) first, is there any way to hide the legends? They are cluttering the map, so I wanted to hide them and display legend stats as a popup icon for each district I am mapping. 2) second, is there any functionality within the layer control selection that can reset/clear all selections on a map?
    Many thanks!
    Relatedly (forgot to mention as third q above) - is there a parameter to adjust legend positions for choropleth maps? I see they run horizontally across the top of the map, but what if I want it vertically down one side of the window? Or even a minimizable option, similar to layer controls feature?
    M Powers
    I know that a CRS representation changed between geopandas 0.6.1 and 0.7, and that folium 0.11.0 made changes (#1251) to support this. Question: is folium 0.11.0 backwards-compatible for geopandas 0.6.1, or must I upgrade to 0.7? (it seems that I can only do so with conda via the conda-forge channel, which will also change many of the dependent packages to conda-forge. I'm reluctant to do that if not necessary.)
    Here are some specific messages from the issue I am trying to work through:
    gdf.crs  # gdf created via gpd.read_file()
    {'init': 'epsg:4326'}
    folium.GeoJson(gdf, name='gdf test').add_to(test_map)
    RuntimeError                              Traceback (most recent call last)
    <ipython-input-24-268ce60b1d50> in <module>
    ---> 36 folium.GeoJson(gdf, name='gdf test').add_to(test_map)
    . . . 
    S:\MDP\Programs\Anaconda3\lib\site-packages\pyproj\__init__.py in __new__(self, projparams, preserve_units, **kwargs)
        360         # on case-insensitive filesystems).
        361         projstring = projstring.replace('EPSG','epsg')
    --> 362         return _proj.Proj.__new__(self, projstring)
        364     def __call__(self, *args, **kw):
    _proj.pyx in _proj.Proj.__cinit__()
    RuntimeError: b'no arguments in initialization list'
    M Powers
    (... or maybe my problem is something else altogether...)
    M Powers
    Update: upgrading pyproj to 2.6.1 did the trick (although FutureWarnings are still produced. Presumably these would go away with geopandas 0.7.)
    Yves Moisan
    Hello all. I'm trrying to get a popup on a GeoJson layer. I can get a tooltip allright that fetches the fields in the GeoJSON attribute elements, but I can't get a popup with that information. Using 0.11. I thought popups behaved kind of like tooltips, e.g. folium.GeoJson(img_centroids, name="Centroïdes d'images", tooltip = tooltip, popup = popup) but whatever way I create my popup object does nothing. Pointers appreciated. TIA
    @ymoisan you asked for some guideline. NOT sure if it works as it is between triple quotes lol But If I kept it is for some good reason ya ll tell
        fg = folium.FeatureGroup(name="tiles")
        with open(geojson_file) as geojson:
            tileDic = json.load(geojson)
        for feature in tileDic['features']:
            coords = [[y,x] for i in feature['geometry']['coordinates'] for x,y in i ]
            tileId = feature['properties']['tile_id']
    Yves Moisan
    @rupestre-campos : thank you for your answer. I ended up monkey patching the code with a code bit I found in a PR. I have two remaining issues, if anyone has pointers :
    1) when I click on a Search result (plugins.Search) I defined a search_zoom and all works fine; however I can't get rid of the red circle that appears on the map; luckily, only the last search item red circle remains but still that is bothersome, especially since the circle doesn't scale so it's always apparent on the map, whatever zoom level
    2) I built a MarkerCluster Layer to manually loop through my folium.GeoJson object to build specific icons as a function of one attribute; I didn't find the way to do it in the GeoJson layer; so I tried pointing the Search box to that MarkerCluster Layer; the search box shows up, but searching never ends; so I pointed the Search control to the original GeoJson object and that works. Problem is, I have to add the GeoJson layer to my map. Even having the layer defined won't let me use the search on it. I have to add_to map. That destroys the nice clusters (in fact it goes on top of clusters) so I thought how can I set visibility to "off". control=False in the layer gets rid of it in the LayerControl object, but I can't tell the layer not to draw itself.
    Pointers appreciated. TIA
    Yves Moisan
    Erratum : show=False works on GeoJson layers
    I'd be happy if there was a "previous zoom" and/or "home" button. Thanx for this awesome library !|
    Hi everyone,
    I'm Trying to use features.GeoJson Tooltip to add a tooltip which will show about 30 different information from geoJson file.
    Is there anyway to make the tooltip into 2 or more columns?
    Currently it only shows all of them in single column
    Hi guys, I am trying to add some latex symbols to the choropleth legend. I tried the way of matplotlib (r'$ $') but it does not work. I am wondering is there any way to do this?
    Thank you.
    Tom Mueller

    I would like to publish information from an ArcGIS MapServer to Folium. I had some It looks like that can be done if a given api is configured to create tiles, but many are not. My first question is, does anyone know if this is possible?
    Some ArcGIS MapServer services are published in the WMS format but these are relative few. I tried to configure the api listed below as a Folium “wms_layer” but I am getting a driver error (also listed below). Anyone know if this is even possible?

    m.add_wms_layer(wms_name="Census Current (2020) WMS",wms_url="https://tigerweb.geo.census.gov/arcgis/services/TIGERweb/tigerWMS_Current/MapServer/WMSServer",
    wms_layers='2010 Census Public Use Microdata Areas Labels')

    DriverError: D:\Dev\APS\aps\data\satskred\AvalDet_20190101_051134_ref_20181226_trno_095_VV\AvalDet_20190101_051134_ref_20181226_trno_095_VV.shp\AvalDet_20190101_051134_ref_20181226_trno_095_VV.shp: No such file or directory

    2 replies
    Michele Gentili
    Hi everyone! Does someone know how to change Icon color in the geoJson dictionary when defining the points? Also how tom add a popup for those points. I saw how to do it with Marker, but then I cannot add a Search Bar! Thanks in advance. Here some code to play with:
    import folium
    from folium import features
    m = folium.Map([ 45.75345246,12.34117475], zoom_start=7)
    points_ = {'type': 'FeatureCollection',
     'features': [{'type': 'Feature',
       'properties': {'Codice': 500732, 'Categoria': 'D1', 'Cluster': 3},
       'geometry': {'type': 'Point', 'coordinates': [12.34117475, 45.75345246]},
       'id': '0'},
      {'type': 'Feature',
       'properties': {'Codice': 500732, 'Categoria': 'A2', 'Cluster': 3,'iconColor':'red'},
       'geometry': {'type': 'Point', 'coordinates': [14.34117475, 46.75345246]},
       'id': '1'}]}
    pp = folium.Popup("hello",fields=['Codice'])
    ic = features.Icon(iconColor="red")
    gj = folium.GeoJson(points_)#, tooltip=tooltip)
    Maarten van der Hoef
    Hi Everyone, my map control has a huge line as i'm using mapbox with a manual http url.. Is there something possible here, I personally would love to hide the whole radio, happy with all suggestions! TIA.
    Hi everyone, Just wondering is there any way to plot markers on a specific date on a TimeSliderChoropleth map at all? Trying to plot a marker on a specific date and then removing it after that date has been passed on the slider. Any advice welcome!
    Hi all. I'm new both to Github and to Gitter and I hope that my help request will not be a problem.
    Just in case someone reads...
    Afternoon y'all. Wondering if any folks on here know how to add hyperlinks to a local directory file on the folium.html option. I'm trying to figure out how to add a hyperlink to a plotly chart and iterate by index position