1

I want to clip this WMS https://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS& to a specific extent.

I have tried what was suggested in these two posts, but they did not work:

  1. Trying to use gdal_translate on WMS
  2. Download Sentinel-2 WMS layer using GDAL?

In 1, I have created my XML file, it looks like:

<GDAL_WMS>
<Service name="WMS">
<Version>1.1.1</Version>
<ServerUrl>https://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&</ServerUrl>
<Layers>OI.OrthoimageCoverage</Layers>
</Service>
<DataWindow>
<UpperLeftX>671040.086</UpperLeftX>
<UpperLeftY>4649319.710</UpperLeftY>
<LowerRightX>671079.380</LowerRightX>
<LowerRightY>4649285.156</LowerRightY>
<SizeX>80</SizeX>
<SizeY>80</SizeY>
</DataWindow>
<Projection>EPSG:25830</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
</GDAL_WMS>

Then I ran:

gdal_translate -of JPEG -outsize 250 250 GDAL_WMS.xml GDAL_WMS.jpg

But the GDAL_WMS.jpg image is empty.

In 2, I ran first gdalinfo to the service, and I got:

Driver: WMS/OGC Web Map Service
Files: none associated
Size is 512, 512
Subdatasets:
  SUBDATASET_1_NAME=WMS:http://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=OI.MosaicElement&SRS=EPSG:25830&BBOX=109307060.38723111,-330884374.4651429,151426332.56359124,-151440450.8291666
  SUBDATASET_1_DESC=Mosaico
  SUBDATASET_2_NAME=WMS:http://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=OI.OrthoimageCoverage&SRS=EPSG:25830&BBOX=109307060.38723111,-330884374.4651429,151426332.56359124,-151440450.8291666
  SUBDATASET_2_DESC=Ortoimagen
  SUBDATASET_3_NAME=WMS:http://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=fondo&SRS=EPSG:25830&BBOX=109307060.38723111,-330884374.4651429,151426332.56359124,-151440450.8291666
  SUBDATASET_3_DESC=Fondo
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 I ran this gdal_translate command:

gdal_translate -of JPEG -outsize 80 80 "WMS:http://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=OI.OrthoimageCoverage&SRS=EPSG:25830&BBOX=671040.086,4649319.710,671079.380,4649285.156&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=17&MINRESOLUTION=0.5&TILED=true" pnoa_test.jpeg

But I get this error message:

ERROR 4: `WMS:http://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=OI.OrthoimageCoverage&SRS=EPSG:25830&BBOX=671040.086,4649319.710,671079.380,4649285.156&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=17&MINRESOLUTION=0.5&TILED=true' does not exist in the file system, and is not recognized as a supported dataset name.
3
  • You are getting an error WMS server error. Invalid values for BBOX. - so check those
    – Ian Turton
    Commented Feb 3 at 10:37
  • Thanks, @IanTurton; the problem was that the order of the BBOX coordinates should be Lower Left X, Lower Left Y, Upper Right X, and Upper Right Y.
    – Isa
    Commented Feb 5 at 10:57
  • as the standard mandates
    – Ian Turton
    Commented Feb 5 at 11:34

0

Browse other questions tagged or ask your own question.