Slow loading of Turf.JS Hexbin and Count with Mapbox Studio Baselayer - mapbox

I've been having difficulty with slow loading of a project I've been looking to fork that was on the Mapbox blog (link here).
I've substituted in my own mapbox key, redefined the bbox to focus on the Ukraine, and re-centered the map on my own mapbox studio baselayer. However, the page loads painfully slowly when I render it in MAMP locally on my computer or when it's uploaded to an S3 bucket.
Not sure what I've done wrong or what I could change to make it render quicker like in the bl.ocks.org example.
Link here for my version of the above project: https://s3.amazonaws.com/conflict.donbass/ukraine2.html

I think has something to do with the bbox size, try setting it to [33, 44.2, 40.6, 50.3]

Related

Mapbox doesn't cluster at top level zoom

I have copied the mapbox example from here;
https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/
When I run it from my server though the map loads, but clustering doesn't seem to work.
If I zoom in, I see the individual records, but no zoomed out clustering. If you zoom in enough around Spain you will see the records.
http://75.9.250.45:8011/mrcjava/servlet/SQL_CT_01.I00090s
I have simply copied and pasted the code from the example into my own html, so I'm unsure why it would behave differently than the example does
This was due to freemarker causing errors with some of the code. Wrapping these as per the below solved it
${r'${w}'} instead of ${w}.

How should we display GeoPackage on Mapbox GL JS?

We used wgrib2 to convert weather radar data into NetCDF format. We converted it to GeoPackage format using gdal_translate. We created a Color Map on QGIS 3.10 and the GeoPackage appeared as expected.
We would like to display this on the Internet using these files or processed versions of these files. We have Mapbox GL JS as a candidate for that but it is not required. We have not found a way to display the gpkg files we have generated. How can we get it to display?
https://docs.mapbox.com/mapbox-gl-js/guides/
We generated png images using gdaldem color-relief and we also tried the following method
However, when we zoomed in on the map with this method, the quality of the image was rough and it could not be displayed beautifully.
https://docs.mapbox.com/mapbox-gl-js/example/image-on-a-map/
Since the gpkg we generated displays correctly in QGIS, it would be most desirable to be able to display the gpkg on MapBox. However, if that is not possible, we would like to display that data beautifully, even in another format.
We also tried to generate tiles using gdal2tiles.py. It worked as we expected when we created data up to zoom level 10. However, when we created the data for zoom level 11, it took more than 12 minutes. Since our data is generated every 5 minutes, we cannot spend any more time on tile generation.
Mapbox GL JS specialises in displaying vector tiles, but can also display raster tiles. If you can't generate static raster tiles from your GeoPackage data source (because they're too big and change too fast), you'll need some kind of server that can read GeoPackage and serve up raster tiles on demand.
Running GeoServer would be one way to do that. It supports GeoPackage natively and could serve up the requested tiles without having to generate them all in advance.
There is also a NetCDF extension that might let you skip the GeoPackage conversion step.
(What you tried was generating a single raster image, which was probably insufficiently detailed for your needs).

Lines in Mapbox tilesets not rendering correctly

I recently updated my tilesets for a project in Mapbox, but with the new ones, at certain zooms, parts of the lines simply disappear completely, both on the tileset preview and on the style itself. It even happens when I re-uploaded my old tilesets which worked perfectly before...
They are all geojson data, here is a example if you can access it : clemapbox.7m7v5xg0 .
This is really annoying and I don't know what to do about, even changing to old data I used didn't work, I still have missing parts of lines...
(And also I can simply not upload some geojson files that are directly from overpass, I don't know why).
Hope someone can help
Thanks !
EDIT : screenshots

Mapbox Android SDK - querySourceFeatures at a given coordinate

I use Mapbox Tileset API and generated a custom tileset (it's a huge 400MB of GeoJSON data) uploaded to Mapbox servers, and added to our style in the studio as a custom fill layer.
This way I can show our custom areas (as polygons) of the world with green (visited) and red (remaining) locations with using expressions only.
I would like to tell if a point (GPS coordinate) is within a polygon of the tileset source/layer and which one, even if the app is in the background (GPS tracking is running in the background and I would like to notify the user when they are within a polygon).
Using queryRenderedFeatures would be great, but unfortunately, it doesn't work when the app is in the background or the user's position is outside of the current viewport.
Is there any solution to get the list of the features at a GPS coordinate even if it's outside of the viewport?
Another requirement is that, it should work when the device is offline, so the Tilequery API won't help.
Downloading the offline data of our style with a limited zoom range working perfectly, I can see my custom source-layer (polygons) even if the device is offline.
So I think there should be a way to query the tileset-source when the device is offline too.
Currently, I generate a simplified GeoJSON file and use it with turf#points-within-polygon when the device is offline, but there're gaps, sometimes polygons are covering each other (due to the simplifying) etc... if I make the tolerance level lower the file is going to be too large to download and store it offline, so this is not really a solution just a poor workaround.
Can I make a PIP (point-in-polygon) query for a custom Tileset source even outside of the viewport, when the app is in the background and the device is offline?
Assuming this is your actual question:
Can I make a PIP (point-in-polygon) query for a custom Tileset source even outside of the viewport, when the app is in the background and the device is offline?
If the device is offline, then any solution that requires fetching tiles on demand (like a tileset in Mapbox-GL or TileQuery) is out.
You said storing the whole GeoJSON is out, because it's too big.
I think the remaining solution is to generate a single-zoom-level tileset and store it locally, then query it with something like query-mbtiles.

Loading in a tileset with c#?

I've got a very large tileset with over 200 different 64x64 tiles. It would be practical to load them in a C# script, I've tried the following (for-loop):
tileset[x] = Resources.Load<Sprite>("Sprites/Tileset/Tileset_" + x);
Where in my asset folder, Sprites is the folder where Tileset.png is. Tileset.png is sliced in a grid (64x64) in I see Unity has sliced all the tiles correctly.
Is there a way I can load them, and put them in a Sprite array (Sprite[]) in code? What would be the correct path?
Looking for correctness? Then batching is caring...
If loaded individually, each tile will cost you a draw call. I would recommend that you look at creating spritesheets to batch the loading and rendering or these tiles. We have been using TexturePacker to load images for our apps and displaying 200+ images at once with one load call, one draw call and great performance. Alongside the app to create the spritesheets, there's a Unity Plugin on the asset store to load and manage them.
Note: we use the pro version.
Otherwise you can just load all the resources at a given path with Resources.LoadAll