Merging overlapping GeoJSON LineStrings (Tippecanoe) and add visualization - visualization

I would like to merge overlapping GeoJSON LineStrings and visually style merged LineString. I have a database of GeoJSON LineStrings which represent routes people drove. I would like to visualize routes which people drive most frequent with different colour than the ones that are not that frequently driven.
Example of Tippecanoe rendered Mbtiles of GeoJSON LineStrings (numbers stand for overlapping routes):
And I would like to achieve something similar to what I depicted on image bellow:
I came across few articles how to visualize GeoJSON Points, but I can not find any helpful tip how to achieve the visualization for LineStrings. Any help, idea or tip would be much appreciated.
Technologies that I'm using:
MongoDB,
Tippecanoe (https://github.com/mapbox/tippecanoe),
tileserver-gl (https://github.com/maptiler/tileserver-gl)
Ideally I would like to achieve similar results that Strava has:

Related

Leaflet clustering choropleth regions

I'm fairly new to Leaflet library and I would like to ask if following functionality is somehow already implemented in Leaflet(or maybe in some other library).
I've found the following example which does clustering based on markers on the map and map also contains choropleth areas displayed.
My question is - Is it possible to do clustering based on choropleth data? Like if I have geojson data for some regions and would also have geojson data of subregions for every region. So if I do zooming then those subregions would collapse to big regions or big regions would be divided to small ones?
Big thanks for any advices or links!
No, because clustering algorithms work only on point data.
You might want to just hide the regions and display the "subregions" when zooming in.
If data becomes too dense when zooming out, consider making the union of the polygon geometries to display that instead. A naïve algorithm would be search for the smallest polygon, then search for the smallest neighboring polygon, replace them by their union, repeat. Stop the algorithm when the smallest polygon is larger than a given threshold.

Mapbox geometries get degraded when exported to tilesets

I'm trying out Mapbox for the first time, and playing around with drawing some polygons in the dataset editor for export to a tileset. However, the polygons in the resulting tileset are not the same as what I create in the editor. The polygons are only very rough, simplified approximations of the originals.
In dataset editor:
In map layer as tileset export:
I understand that Mapbox does vector simplification at certain zoom levels, but these changes are not zoom-dependent. I zoom in all the way and the shapes are still like this.
Moreover, such extreme degredation of the geometries makes tilesets essentially useless for features that require any sort of accuracy, like property lot lines.
Am I missing something, or is this really the expected behavior? Is there really no way to get accurate geometries into a tileset?
UPDATE: It appears this is only happening with shapes I create by drawing in the Mapbox data editor. So far the geometries that I've uploaded as geojson files have gotten converted to tilesets accurately...
I suspect this is because the maxzoom is too low.
When you create a Mapbox Tileset, either by uploading GeoJSON directly as a new Tileset, or by exporting your your Dataset to a Tileset, Mapbox will try to guess an appropriate minzoom and maxzoom of the Tileset.
Sometimes the min/max zoom's used aren't suitable for the map you're trying to create. Since there is no way to specify a maxzoom in either of the two approaches the only alternative is to create your Tileset locally with https://github.com/mapbox/tippecanoe specifying an appropriate maxzoom for your data and then uploading the resulting .mbtiles as a Mapbox Tileset.

Visualising road segments as heatmap in Leaflet efficiently

I have data consisting of parts of road segments of a city, with different number of visits. I want to plot the data on a Map and visualise it in the form of a heatmap.
I have two related questions:
I have the data from Open Street Maps (OSM) in the form of pairs of node ID's, where node ID correspond to the unique ID being assigned to a point by OSM. I also have a mapping for each node Id to its corresponding coordinates. Is there any Leaflet or Mapbox utility or plugin, which can plot a trip / highlight the road segment using 2 node ID's. I can always do it manually (by using the coordinate mapping and converting it into GeoJSON), but the problem occurs with the line width -- I have to make it exactly overlap with the width of the road, so that it seems that I am highlighting a road segment.
Is there any plugin / utility for Leaflet or Mapbox, which can be used for plotting polylines or geojson as heatmap efficiently? My current approach is calculating the color for each polyline and encoding that as a geojson property. But the problem is that with the increase in the number of lines (> 1K) the rendering becomes a pain and the method is not feasible. There are some plugins for Leaflet out there for plotting heatmap, but all of them are for points only and not lines. Any approach using WebGL would be really great.
An approach which I thought of could be converting my data into a shape file, upload to Mapbox Studio and use as a layer directly. But I have no idea how to go about doing that i.e. creating a shapes file, encoding the information in such a way that the complete road segment gets highlighted in the correct color.

Newbe help on getting from polygon shape file to Leaflet polygon

Learning Leaflet. Had success with point data. Now want to create polygons.
The process starts with an Access record with a Parcel Identification Number. Using ArcMap desktop, the records are joined to a parcel shape file for the county.
What the best approach to get to Leaflet polygons from here? Like with point data, do I need to add fields to contain the lat/lon data?
I don't need a lot of detail; just a pointer in the right direction. I don't mind doing homework.
My approach would be to convert the shapefile to geojson and then load the geojson into your Leaflet map.
I'm aware of some ArcGIS plugins to export geojson, but an alternative approach is to use the command line tool GDAL (ogr2ogr).
See the links on this answer for more details, but the command will end up being something like the following...
ogr2ogr -f GeoJSON -t_srs "EPSG:4326" [name][.geojson|.json] [name].shp
From there you can preview the results in geojson.io or github before creating your Leaflet map.

Leaflet + geojson datas

I'm working on a project using Leaflet. For this project I've created an interface to draw all the roofs of a large city as polygons. A lot of scripts calculate the surfaces, the addresses, the orientation and so on... I'll store each roof's datas in a geojson file (or files). We expect to get about 10 000 roofs or more. I don't know if Leaflet displays only visibles polygons depending window's boundaries or if all the polygons are drawn, and my problem is to find the better way to do this storage.
In one geojson file. It may be a problem because the 10 000 roofs are computed in the same time and waiting for polygons loading may be very boring for users.
In separated geojson files: for each roof I can approximatively calculate the coordinates of its center and put this roof in the right geojson file depending the lat/lng. By this way I can create (say 20 or 50) differents geojson files and call the right one depending boundaries. Then the question is: to create all the polygons, is it better to call the 6 (or 8 or 10) geojson usefull files for the area on screen, or is it better to create a new dynamic geojson file?
All the roof's datas are stored in a database or in a XML file and I have to detect boundaries and automatically create a dynamic geojson file. But each time user scroll or darg or zoom the map I'm supposed to recreate this unique geojson file...
Do you ever have a similar problem to solve and how do you solve it ? Thx.
I think the second scenario is the most robust, you need tiled GeoJSON tiles. Have a look at Leaflet Plugins. There is one called TileLayer.GeoJSON. Some links on how to create these tiles are on OpenStreetMap wiki.