dimanche 28 décembre 2014

Fetch from WMTS with gdal_translate


I'm trying to create an input XML file for gdal_translate to fetch tiles from a WMTS service. The service I'm interested in is the Polish Geoportal's scans of topographics maps. The XML format is documented on GDAL site.


They provide tiles in the WMTS format. GetCapalities response is available here: http://mapy.geoportal.gov.pl/wss/service/WMTS/guest/wmts/TOPO?SERVICE=WMTS&REQUEST=GetCapabilities&VERSION=1.3.0


I was able to fetch maps from the site using gdal_translate previously, thanks to a great blog post (in Polish). Back then they provided the tiles in some obscure ARS tile coordinate format. Then the gdal's XML input file looked like this:



<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://ars.geoportal.gov.pl/ARS/getTile.aspx?service=RASTER_TOPO&amp;cs=EPSG2180&amp;fileIDX=L${z}X${x}Y${y}.jpg</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>0</UpperLeftX>
<UpperLeftY>819200</UpperLeftY>
<LowerRightX>1228800</LowerRightX>
<LowerRightY>0</LowerRightY>
<TileLevel>9</TileLevel>
<TileCountX>3</TileCountX>
<TileCountY>2</TileCountY>
<YOrigin>bottom</YOrigin>
</DataWindow>
<Projection>EPSG:2180</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
<BandsCount>3</BandsCount>
<Cache>
<Extension>.jpg</Extension>
</Cache>
</GDAL_WMS>


Now, that URL in no longer available.




So far I collected this much information:



  1. Sample URL to a tile looks like this http://mapy.geoportal.gov.pl/wss/service/WMTS/guest/wmts/TOPO?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=MAPA%20TOPOGRAFICZNA&STYLE=default&FORMAT=image/jpeg&TILEMATRIXSET=EPSG:2180&TILEMATRIX=EPSG:2180:0&TILEROW=0&TILECOL=0

  2. Geoportal uses PUWG-92 coordinates.

  3. The command to fetch a map by PUWG-92 coords looks like this:

    gdal_translate -of JPEG -projwin 620000 500000 625000 495000 in.xml out.jpg. The expected output: http://i.stack.imgur.com/nvhzM.jpg


  4. I'm interested only in layer 9, so the important part of GetCapabilites is



    <TileMatrix>
    <ows:Identifier>EPSG:2180:9</ows:Identifier>
    <ScaleDenominator>9449.404761904761</ScaleDenominator>
    <TopLeftCorner>850000.0 100000.0</TopLeftCorner>
    <TileWidth>512</TileWidth>
    <TileHeight>512</TileHeight>
    <MatrixWidth>598</MatrixWidth>
    <MatrixHeight>562</MatrixHeight>
    </TileMatrix>



Does anyone know how to write the gdal's XML input file based on this information?





Aucun commentaire:

Enregistrer un commentaire