0

I am working on the Folium Map Python Library, and Its connects the two different points together (PolyLine), is there any best example with folium which doesn't connect lines on map or I can color them with unique ids,

I was trying some JSON thing with my Data, but that didn't work with my code, still it connects all the different lines as mentioned in below picture? can any one suggest any best solution, which doesn't connect these lines, but I have to still use the folium.

lat = filteredData.lat
lon = filteredData.lon

data = {
    'type': 'FeatureCollection',
    'features': [
        {
            'type': 'Feature',
            'geometry': {
                'type': 'LineString',
                'coordinates': [[lon, lat] for (lat, lon) in zip(lat, lon)],
            },
            'properties': {'fillcolor': 'black'}
        },
    ],
}


m = folium.Map(location=[36.862317, -76.3151], zoom_start=6)
m.add_child(folium.features.GeoJson(data))
m

this is the reference link I am using

enter image description heres.

id101112
  • 1,012
  • 2
  • 16
  • 28
  • provide a [mcve] – eyllanesc May 09 '18 at 20:34
  • this is the complete question I guess, I just need the help with the folium map and what I need I also explained it, what else you need to answer the question, I do not understand your point – id101112 May 09 '18 at 23:55
  • You indicate: *I was trying some JSON thing with my Data, but that didn't work with my code*. When you say that, what we hope is that you show what you have tried, so we will indicate where the error is and so you can correct it and learn from it, so provide an MCVE – eyllanesc May 09 '18 at 23:59
  • I updated it and provided the code for GeoJSON, can you look at it, please.. thanks – id101112 May 10 '18 at 00:09
  • That image you show is what you want or what you get ?, Be clear and take advantage of all the resources you provide. – eyllanesc May 10 '18 at 00:10
  • that image is not from my data, its just an example showing how it connects different points with polyline, which is as mentioned in the following link http://qingkaikong.blogspot.com/2016/06/using-folium-4-draw-lines-plot-san.html – id101112 May 10 '18 at 00:12
  • i am guessing this link may help you to understand my problem https://github.com/python-visualization/folium/issues/523 – id101112 May 10 '18 at 00:13
  • So that explains it, it also shows what you get by noting what is missing to get what you want, your code is not an MCVE, if you had taken the time to read the content of the link you would know that an MCVE must be complete, it is to say that I should execute the code that you show without adding more code and thus not waste time patching, guessing, etc. that in the end those who want to help you bore us. – eyllanesc May 10 '18 at 00:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/170728/discussion-between-id101112-and-eyllanesc). – id101112 May 10 '18 at 00:18

1 Answers1

0

Most likely the problem arises because you have only one feature in the geojson definition. You should be doing something like this:

data = {
    'type': 'FeatureCollection',
    'features': [
        {
            'type': 'Feature',
            'geometry': {
                'type': 'LineString',
                'coordinates': [[lon, lat] for lat, lon in zip(lats, lons)],
            },
            'properties': {'fillcolor': 'black'}
        }
        for (lats, lons) in zip(latss, lonss)],
}

Here both lats and lons are lists of numbers. Hence, latss and lonss are lists of lists of numbers. Each pair (lats, lons) describes a single line.

hilberts_drinking_problem
  • 11,322
  • 3
  • 22
  • 51