[gdal-dev] WMTS gdal_translate vs RasterIO
Michał Kowalczuk
michkowalczuk at gmail.com
Fri Aug 30 02:49:34 PDT 2024
- When debugging *gdal_translate *I noticed that both gdal_translate and
GDALRasterIO chose tilematrix=22 (*WMTS: Using tilematrix=22 (zoom level
22)*
- The difference is in the next log line:
- gdal_translate uses XML as argument for GdalOpen:
*HTTP:
Fetch(https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/WMTS/1.0.0/WMTSCapabilities.xml
<https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/WMTS/1.0.0/WMTSCapabilities.xml>)
*
*WMTS: Using tilematrix=22 (zoom level 22) *
*WMS: Using
C:\Users\Michal\.cache\gdalwmscache\4112649712971ece915a619d7334b09c for
cache *
*GDAL: GDALOpen(<GDAL_WMS><Service name="TMS">
<ServerUrl>https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/WMTS/tile/1.0.0/USGSHydroCached/default/default028mm/22/${y}/${x}.png
<https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/WMTS/tile/1.0.0/USGSHydroCached/default/default028mm/22/$%7By%7D/$%7Bx%7D.png></ServerUrl></Service><DataWindow>
<UpperLeftX>-20037508.342787</UpperLeftX>
<UpperLeftY>20037508.342787</UpperLeftY>
<LowerRightX>49090487.0664309</LowerRightX>
<LowerRightY>-36387522.4405195</LowerRightY>
<TileLevel>0</TileLevel>
<TileX>0</TileX> <TileY>0</TileY> <SizeX>1852166912</SizeX>
<SizeY>1511812608</SizeY>
<YOrigin>top</YOrigin></DataWindow><BlockSizeX>256</BlockSizeX><BlockSizeY>256</BlockSizeY><BandsCount>4</BandsCount><DataType>Byte</DataType><Cache
/><UnsafeSSL>true</UnsafeSSL><ZeroBlockHttpCodes>204,404</ZeroBlockHttpCodes><ZeroBlockOnServerException>true</ZeroBlockOnServerException></GDAL_WMS>,
this=0000025616415250) succeeds as WMS. **WMS: Using
C:\Users\Michal\.cache\gdalwmscache\9c7d5f9a99f1b710170c225a59a5ee4c for
cache*
- log from my code shows different approach...But this approach works
fine for the other subdataset from this server
"tilematrixset=GoogleMapsCompatible"
*[Fri Aug 30 11:12:41 2024].3130, 14.4900: HTTP:
Fetch(https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml
<https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml>)*
*[Fri Aug 30 11:12:41 2024].9710, 15.1480: WMTS: Using tilematrix=22
(zoom level 22)*
*[*
*Fri Aug 30 11:12:41 2024].9730, 15.1500: GDAL:
GDALOpen(WMTS:https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=USGSImageryOnly,tilematrixset=default028mm
<https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=USGSImageryOnly,tilematrixset=default028mm>,
this=0000028EE0F1AA30) succeeds as WMTS. [**Fri Aug 30 11:12:41
2024].9970, 15.1740: CPLError:
WMTSCapabilities.xml,layer=USGSImageryOnly,tilematrixset=default028mm:
Access window out of range in RasterIO(). Requested (0,0) of size
1073741760x764544 on raster of 1073741756x1347126255.*
*ERROR 5:
WMTSCapabilities.xml,layer=USGSImageryOnly,tilematrixset=default028mm:
Access window out of range in RasterIO(). Requested (0,0) of size
1073741760x764544 on raster of 1073741756x1347126255.*
- gdal_translate also works for -ovr NONE
- when I hardcode to use *nxSize=1073741756* instead of *1073741760*,
similar problem occurs later:
GDAL CPL Error 5:
WMTSCapabilities.xml,layer=USGSImageryOnly,tilematrixset=default028mm:
Access window out of range in RasterIO(). Requested (0,1344795604) of size
1073741756x2330668 on raster of 1073741756x1347126255.
- answering to you last question - I fill windows bitmap using Delphi
where I need to copy byte values line-by-line (using scanline approach).
I guess we're still stuck :-(
pt., 30 sie 2024 o 09:50 Rahkonen Jukka <jukka.rahkonen at maanmittauslaitos.fi>
napisał(a):
> Hi,
>
>
>
> I do not know either, I am not a programmer. I have used sometimes a local
> proxy server for capturing the http traffic. With gdal_translate the http
> requests are printed when the command is run with -- debug on. It would
> probably be good to run gdal_translate with -ovr NONE
> https://gdal.org/en/latest/programs/gdal_translate.html#cmdoption-gdal_translate-ovr
> and force it to use the full resolution image, because I quess that your
> code is also hitting the full resolution. Maybe gdal_translate is already
> hitting the same resolution, but by using -ovr it is you who makes the
> decision.
>
>
>
> By reading the values it seems that you request 1073741760 pixels but for
> some reason GDAL believes that there are only 1073741756 pixels available.
> If I were a programmer, I think I would have a try with nXSize=1073741756.
>
>
>
> May I ask why do you want to compress quite a large area of a raster into
> a single line of pixels? You have probably some interesting use case.
>
>
>
> -Jukka Rahkonen-
>
>
>
> *Lähettäjä:* Michał Kowalczuk <michkowalczuk at gmail.com>
> *Lähetetty:* perjantai 30. elokuuta 2024 10.28
> *Vastaanottaja:* Rahkonen Jukka <jukka.rahkonen at maanmittauslaitos.fi>
> *Kopio:* Robert Coup <robert.coup at koordinates.com>;
> gdal-dev at lists.osgeo.org
> *Aihe:* Re: [gdal-dev] WMTS gdal_translate vs RasterIO
>
>
>
> Full GDAL log attached.
>
> Sorry, but I do not know how to test your suggestion. GDAL logger creates
> some caches and I do not know which http request i should use...
>
>
>
> Thanks, Michał
>
>
>
> pt., 30 sie 2024 o 09:23 Rahkonen Jukka <
> jukka.rahkonen at maanmittauslaitos.fi> napisał(a):
>
> Hi,
>
>
>
> Capture and show the http request that your code generates and sends to
> the WMTS server. Does it work if you send the same request with curl or
> with a browser? Or does the error come before the GetTile request is
> generated?
>
>
>
> -Jukka Rahkonen-
>
>
>
> *Lähettäjä:* Michał Kowalczuk <michkowalczuk at gmail.com>
> *Lähetetty:* perjantai 30. elokuuta 2024 9.59
> *Vastaanottaja:* Robert Coup <robert.coup at koordinates.com>
> *Kopio:* gdal-dev at lists.osgeo.org; Rahkonen Jukka <
> jukka.rahkonen at maanmittauslaitos.fi>
> *Aihe:* Re: [gdal-dev] WMTS gdal_translate vs RasterIO
>
>
>
> Sorry for incorrect sample commands in the last message.
>
> I fixed it. The problem stays the same, because the problem was in email
> not in my tested code.
>
> *gdal_translate -srcwin 0 0 1073741760 1553779 -outsize 691 1
> "WMTS:https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=USGSHydroCached,tilematrixset=default028mm
> <https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=USGSHydroCached,tilematrixset=default028mm>"
> tile.png*
>
>
>
> *GDALDatasetRasterIO(*
>
> *handle_to_wmts_subdataset,*
>
> *eRWFlag=GF_Read,*
>
> *nXOff=0,*
>
> *nYOff=0,*
>
> *nXSize=1073741760,*
>
> *nYSize=1553779,*
>
> *pBuffer - buffer for data,*
>
> *nBufXSize=691,*
>
> *nBufYSize=1,*
>
> *eBufType=GDT_Byte,*
>
> *nBandCount=4,*
>
> *panBandMap=[bIndex ,gIndex, rIndex, aIndex],*
>
> *nPixelSpace=4,*
>
> *nLineSpace=0,*
>
> *nBandSpace=1)*
>
>
>
> Can anyone help me to understand why gdal_translate works and generates
> output file, where GDALRasterIO raises error:
>
> *Requested (0,0) of size 1073741760x1553779 on raster of
> 1073741756x1347126255?*
>
>
>
> czw., 29 sie 2024 o 12:22 Michał Kowalczuk <michkowalczuk at gmail.com>
> napisał(a):
>
> I see. I will double check commands, fix and return to this.
>
>
>
> W dniu czw., 29.08.2024 o 12:20 Robert Coup <robert.coup at koordinates.com>
> napisał(a):
>
> Hi Michał,
>
>
> In addition to Jukka's key point:
>
> nBufXSize=1,
> nBufYSize=691,
>
> appears to be backwards wrt:
>
>
> -outsize 691 1
>
>
>
> Rob :)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240830/de6cfd9c/attachment-0001.htm>
More information about the gdal-dev
mailing list