5

I want to download Sentinel-2 WMS layer from https://s2maps.eu/ using gdal_translate option. I have an XML file to fetch the image. But I am not getting a proper output. I believe it is due to the XML file which I am not an expert to fine tune properly. I can't find out where I went wrong.

<GDAL_WMS>
  <Service name="WMS">
    <Version>1.1.1</Version>
    <ServerUrl>https://tiles.maps.eox.at/?SERVICE=WMS</ServerUrl>
    <Layers>s2cloudless-2019</Layers>
    <SRS>EPSG:4326</SRS>
    <ImageFormat>image/jpeg</ImageFormat>
    <Transparent>FALSE</Transparent>
    <BBoxOrder>xyXY</BBoxOrder>
  </Service>
  <DataWindow>
    <UpperLeftX>94.9998611110000013</UpperLeftX>
    <UpperLeftY>26.9998611110000013</UpperLeftY>
    <LowerRightX>97.0001388889999987</LowerRightX>
    <LowerRightY>29.0001388889999987</LowerRightY>
    <SizeX>7201</SizeX>
    <SizeY>7201</SizeY>
  </DataWindow>
  <BandsCount>3</BandsCount>
  <UnsafeSSL>true</UnsafeSSL>
  <ZeroBlockHttpCodes>204,403,404,500,502,503,504</ZeroBlockHttpCodes>
</GDAL_WMS>

The output of gdal_translate -of GTiff wms.xml sent12.tif is like:

output

If I check the pixel size it is not 10m and is nearly around 28m. So how do I get the imagery with 10m resolution?

3
  • 1
    What output do you get?
    – nmtoken
    Commented Aug 26, 2020 at 7:35
  • I have attached the output in the link link . I do in command prompt gdal_translate -of GTiff wms.xml sent12.tif to get the same output Commented Aug 26, 2020 at 9:12
  • It appears that you have swapped your coordinates
    – nmtoken
    Commented Aug 26, 2020 at 9:43

1 Answer 1

10

One way of doing this...

Do a gdalinfo on the service endpoint

gdalinfo "WMS:https://tiles.maps.eox.at/?SERVICE=WMS&"

Gives a list of Subdatasets (WMS layers) with example GetMap requests:

Driver: WMS/OGC Web Map Service
Files: none associated
Size is 512, 512
Subdatasets:
  SUBDATASET_1_NAME=WMS:https://tiles.maps.eox.at/?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=s2cloudless-2018_3857&SRS=EPSG:900913&BBOX=-20037508.342789,-20037508.342789,20037508.342789,20037508.342789&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=18&MINRESOLUTION=0.5971642834779395&TILED=true
  SUBDATASET_1_DESC=Sentinel-2 cloudless layer for 2018 by EOX - 3857
  ...
  SUBDATASET_22_NAME=WMS:https://tiles.maps.eox.at/?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=s2cloudless-2019&SRS=EPSG:4326&BBOX=-180.000000,-90.000000,180.000000,90.000000&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=17&MINRESOLUTION=0.0000053644180298&TILED=true
  SUBDATASET_22_DESC=Sentinel-2 cloudless layer for 2019 by EOX - 4326
  ...
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

Then you can do a gdal_translate on the subdataset like:

gdal_translate -of JPEG -outsize 256 256 "WMS:https://tiles.maps.eox.at/?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=s2cloudless-2019&SRS=EPSG:4326&BBOX=-180.000000,-90.000000,180.000000,90.000000&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=17&MINRESOLUTION=0.0000053644180298&TILED=true" out.jpeg

Creates a JPEG and associated out.jpeg.aux.xml file:

JPEG created

Similarly, for your bounds

gdal_translate -of JPEG -outsize 700 700 "WMS:https://tiles.maps.eox.at/?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=s2cloudless-2019&SRS=EPSG:4326&BBOX=94.9998611110000013,26.9998611110000013,97.0001388889999987,29.0001388889999987&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=17&MINRESOLUTION=0.0000053644180298&TILED=true" out2.jpeg

gives:

BBOX=94.9998611110000013,26.9998611110000013,97.0001388889999987,29.0001388889999987

3
  • It is really working well. If I want to convert it in tif and keep the native resolution to 10m how to I do that? Commented Aug 26, 2020 at 10:38
  • 1
    @GokulAnand for TIFF output you just need to the -of GTiff as you had already
    – nmtoken
    Commented Aug 27, 2020 at 16:02
  • 1
    WMS only give a representation of the native data, so not sure if you'' be able to get native resolution. You can experiment with bounding box and image size in the GetMap request.
    – nmtoken
    Commented Aug 27, 2020 at 16:17

Your Answer

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

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