I'd like to use OpenMapTiles to generate training data for a text recognition task. So, I need to have the corresponding text labels in a raster tile, preferably with their location on the image, stored in a separate file in text format. How can I do this with OpenMapTiles?

3 Answers 3


You can use mapbox tiles and extract features from it using

  1. Get all the layers having "type":"symbol"
  2. Define a bounding box var bbox= [[x,y] ,[x,y]];

  3. Query features from tiles with layer having all the layer extracted from step 1 var features = map.queryRenderedFeatures(e.point, { layers: ['place-town'] });

    refer https://docs.mapbox.com/mapbox-gl-js/example/queryrenderedfeatures/example 4.Extract geometry and property->name and store in file.

Note:You may need to perform this task various times for the large area. You may have to stick to one zlevel of map to get data as the data can be varied according to zoom level due to styling and less data fetched at higher zoom level as 6,7 to reduce tile size.

Then use mapbox rater tiles text recognition task as they use osm data, Or use openstreet raster tiles but data can differ according to styling as well.

Other approach can be to download osm files from https://wiki.openstreetmap.org/wiki/Planet.osm,dump it in database the query it according to bounding bbox. Steps for this can be easily be found

  • Thank you! The queryRenderedFeatures function can do what I want to achieve. But it seems that I need to query the map pixel by pixel, unless you have a better suggestion ...
    – sasantv
    Aug 2, 2019 at 20:51

Use tileserver-GL to serve the mbtiles and you can get raster tile endpoint otherwise use tilehosting.com which is openmaptiles open street map it has raster endpoint URL too. Other options are using tilestrata with plugins but it requires mapnik

  • Thanks for the response, but I guess my question was not clear enough. Getting raster images from OpenMapTiles, is quite straightforward. You can run it through docker, and it gives you a raster endpoint (using tileserver-GL). What I need to have is the text-labels on the raster tile stored in a separate file in text format.
    – sasantv
    Jun 27, 2019 at 13:23

You need just labels then convert the mbtiles to GEOJSON with OGR2OGR. or tippecanoe by mapbox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.