Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    but only 0/0/0 is requested
    Andrew Annex
    nvm, totally fixed by setting the crs to 4326
    Hi, I'm new to Folium. I have created a map which shows routes at sea. In order to geopraphic selection I added folium draw plugin. Is there a way to get the polygon coordinates iot use them in Shapely.
    Sorry to be that guy. But if you want to get polygon back to Python in order to use them with Shapely. I suggest using ipyleaflet, which gives you a way to register a callback function that will be called when a new shape is drawn with the Control.
    in your case this callback function would create the Shapely shape
    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
    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:, 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 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: 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:
    '0.11.0'  # 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\ 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.