How to compact mbtiles with mbutil - mapbox

I'm creating maptiles with arc2earth and ArcGIS and it creates a lot of duplicate tiles.
I would like to reduce its size using mbtiles. I think it is possible to "compact" tiles, but I don't find the way.
Do you know if mbtiles still have compact command or it is just been deprecated?
Thanks!

At the moment mbutil doesn't expose this as an option - TileMill is the only client that supports properly compressed tiles. Of course, mbutil is an open source project, so if you're game, you can built it and add it.

Related

Downloading OpenStreetMap maps as png-images without a browser

Currently I am using Selenium and Folium to download OpenStreetMap maps... The issue I am encountering now is that, for my next assignment, I have to download 5 million images, and my current Python script is too slow. Having that one running in the background for hours on my laptop is not really an option.
Currently, my script opens the browser, saves the screen and extracts the nxn pixels image I need.
Does anybody know of a smarter way of extracting maps from OpenStreetMap?
Currently, I have a CSV list of 5'ish million x & y coordinates of points, and I need to download a map for each one of these in png-format... How should I proceed?
I hope you are not downloading from openstreetmap.org tile servers, because this is strictly discouraged as you can see on https://operations.osmfoundation.org/policies/tiles/ under "Bulk Downloading".
It might make sense for you to setup an own tileserver or subscribe to some tile-server service. There are static map services, which allow you to download the combined map image of an area, see
https://justmarkup.com/articles/2014-05-27-overview-of-static-map-solutions/#openstreetmap
for example.
This mentions Mapquest and Mapbox.

Get/list source-layers from Mapbox GL JS vector source

In Mapbox GL JS I am adding a vector tile source from a locally hosted mbtiles file. Adding this source to my map instance is easy like below.
map.addSource("polylinesSource",{
"type":"vector",
"tiles": [
"http://localhost:8000/polylinesJoined/{z}/{x}/{y}.pbf"
]
})
The source-layers from this service will be dynamic and I am hoping for a way to reference all those layers once the source is loaded. Is it possible to list all the layers in a source once loaded?
This is surprisingly fiddly to do. Mapbox-GL-JS doesn't expose any methods to list the vector tile source layers available within a tileset.
I built vector inspector to solve this exact problem. The code here shows you the process for extracting that information from a .pbf: https://github.com/stevage/vector-inspector-api/blob/master/server.js
Alternatively, since you have the local mbtiles file, another option is to extract it locally. Using another tool I built, tileinfo.
Also, if you serve the tiles using something like tessera you can access the layers info directly at the TileJSON endpoint.

Use existing offline raster mbtiles to display on mapbox map

I'd like to transition the map in my app from currently Apple-Maps-SDK to Mapbox. My users already downloaded a lot of offline maps into several .mbtiles tiles containing raster data.
My question now is if it's possible to still use those while the user will be transitioning to the new maps? I just don't simply want to delete all offline maps and tell the user that he needs to download everything again right now, but rather give them a time-window to do that...
I was looking at MGLRasterTileSource/MGLSource and thought that I can create a subclass and somehow provide my own data to the map, but this does not seem to be supported. There are no datasource methods on it for that purpose...
Would be great if somebody could point me into the direction on how to archive what I want.
EDIT:
So I thought it might work that way... I migrate my existing raster tiles into a downloaded pack inside the mapbox offline database. So I had a look at the caches.db but at least the data in there is not just a plain png/jpg (tried with the mapbox satellite images, which should be raster).
Cause there is no public interface for getting existing raster-tiles in there, is there?
I've seen an other solution where somebody is hosting a webserver inside the app... but that somehow looks like quite an overkill to me?!?
https://gist.github.com/namannik/3b7c8b69c2d0768d0c2b48d2ed5ff71c

TMS tile source in routeme/mapbox

Using the MapBox iOS SDK (routeme) is it possible to point to an offline TMS directory structure of tiles?
I know that I can point to an online TMS source like OpenStreetMap but I would like to just store a TMS directory structure on the device for offline use.
It doesn't out of the box, but you can create your own RMTileSource to easily do this. You want to go straight up to RMTileSource as opposed to modeling after something like RMOpenStreetMapSource since this is a subclass of the general web tile handling class.

Proper way to create tile maps for Leaflet.js?

I am trying to build a custom-designed map, with correct geodata. It could even be an image created in illustrator, but it has to be exported as a set of tiles in correct map format - so that it can be read by tools like Leaflet.js
What confuses me is that none of the available map tools seem to work very well together. I did find Tilemill, which looks very promising (it has a very clean interface and works with CSS), but:
Openstreetmaps does not allow downloading tile images, only XML data in OSM format.
Tilemill does not allow importing Openstreetmaps XML data (why!).
Even if you manage to design a map in Tilemill, you still cannot export tile images, only a proprietary SQL database format? What's the point of that?
If Tilemill is useless, are there other tools that allow opening OSM XML data and applying your own design styles?
There are some sources that talk about building your own tile server:
This source suggests converting OSM to PostGIS using SQL, and then using a custom python script and a tool named Mapnik. Then it says that it's not recommended to use Mapnik for OSM....
This source sounds promising, but then it casually mentions that you have to build and run your own custom Linux distribution...
Is there a simpler way to create map tiles with correct filenames and folders for Leaflet.js?
Tilemill does not allow importing Openstreetmaps XML data (why!).
OpenStreetMap XML is an interchange format: it's a way to transfer things around, not to use them. You can import it into PostGIS and use it in TileMill.
Even if you manage to design a map in Tilemill, you still cannot export tile images, only a proprietary SQL database format? What's the point of that?
If you export millions of tile images, you'll fill up your hard disk and run out of inodes. It's a bad deal. That's why we made MBTiles, which is not proprietary, but very much open source in every definition of the word, and you can export it to disk with mb-util if you so wish.
If Tilemill is useless, are there other tools that allow opening OSM XML data and applying your own design styles?
TileMill isn't useless, but if you want another option, you can use Maperitive, though it is proprietary in every sense of the word.