OpenStreetMap logo OpenStreetMap

Fresh Sentinel-2 in your editors. With QGIS, but easier

Posted by TrickyFoxy on 2 August 2023 in English. Last updated on 3 August 2023.

It seems that there is only one instruction for getting fresh Sentinel-2. It tells you quite well how to prepare images, but it is difficult to explain how to use them in OSM editors. So after step 7, you can do

without GeoTIFF and tile server

  1. Select in QGIS: Processing->Toolbox->Raster Tools->Generate XYZ tiles (MBTiles)
  2. Set the parameters:
    • to Extent of the map area you need.
    • Maximum Zoom is most likely 15.
    • In Output Path, specify where to save the tile file
  3. Click Run and wait for rendering to finish.
  4. Install the mbtiles plugin in JOSM
  5. Open the file you received in step 3.

By the way, recently Guru Maps learned how to tear off MBtiles https://gurumaps.app/blog/2023/06/14/mbtiles


But if you still want a tile server, you can do without tileserver-php from the instructions. And without the QTiles plugin, it will also work faster!

Classic tiles with a web server

  1. Select in QGIS: Processing->Toolbox->Raster Tools->Generate XYZ tiles (Directory)
  2. Set the parameters:
    • to Extent of the map area you need.
    • Maximum Zoom is most likely 15.
    • Set Output Directory. You can immediately select the directory of your web server.
  3. Click Run and wait for rendering to finish.
  4. Start your web server. If you didn’t use Nginx or Apache, open the folder with your tiles in the terminal and try using the web server in Python: python -m http.server 80 or PHP: php -S 127.0.0.1:80
  5. In JOSM, open Preferences->Layers->+TMS
  6. Enter a URL like this: http://localhost/<tile folder name>/{zoom}/{x}/{y}.png
  7. Get closer to the desired area in JOSM and select your new layer from the Layers menu.

p. s. I used QGIS 3.32.1-Lima.


upd: method from @maraf24

Classic tiles for JOSM without a web server

Instead of starting the web server, specify the following URL in JOSM: file://<absolute path to the folder with tiles>/{zoom}/{x}/{y}.png

Discussion

Comment from maraf24 on 3 August 2023 at 10:09

For JOSM the third option is no MBTiles and no web server, as JOSM can directly access files by “file:///…” url.

Comment from TrickyFoxy on 3 August 2023 at 12:41

Oh, cool, thanks @maraf24

Too bad iD doesn’t have access to file://

Comment from InsertUser on 11 August 2023 at 18:22

I recently found out that Ff5722’s steps 3-7 can be simplified to:

  1. In QGIS; open data source manager.
  2. Select raster. Browse to and select zip file. Leave newly created (Sentinel specific) dropdown at default setting and click add.
  3. In new “Select Items to add in {XXXXX}” window select either the option described as “Bands B2, B3, B4, B8 with 10m resolution UTM {xxx}” or “True color image UTM {xxx}”. (or both if you want more options for visualisation)

Choosing “Bands B2, B3, B4, B8…” automatically displays as colour image (virtual raster?) with slightly worse contrast than the computed TCI layer but allows you to change the bands used for display to use e.g. Red=B8, Green=B4 and Blue=B3 which can give good contrast at the edge of vegetation (now red) and highlight partially obscured roads.

When generating mbtiles I think it is useful to give a name that is similar to what you want JOSM to auto-populate in the source field. That way all you have to do is strip off the “MBTiles:” prefix ahead of upload.

Setting both min and max zoom to 15 on export slightly reduces the file size. In JOSM you can zoom until the layer shows then right click on the map, select the relevant layer and untick “Auto zoom” to prevent JOSM complaining that it’s not being sent tiles when you’re zoomed out.

Comment from charles_e on 19 August 2023 at 15:45

Hi, there is now a WMTS server from the Copernicus programme themselves (https://documentation.dataspace.copernicus.eu/APIs/SentinelHub/OGC/WMTS.html) in their new “dataspace”. You need to sign up and configure your WMTS “instance”, basically selecting the imagery (eg true_color) and some optional settings, then you can access it directly from iD, JOSM or whatever. There is a monthly limit of 10.000 requests, so I wouldn’t use it for browsing around, but it works fairly well to get up to date imagery into the editor. I tried it the following way and it worked quite well (using the instance and layer ids from the created instance): https://sh.dataspace.copernicus.eu/ogc/wmts/[INSTANCE_ID]?LAYER=[LAYER_ID]&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&TILEMATRIXSET=PopularWebMercator256&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}

Comment from charles_e on 17 November 2024 at 18:51

Update: The Copernicus WMTS service seems to have issues, but WMS is still working, cf osm.wiki/Sentinel-2#Usage

Log in to leave a comment