OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.9k stars 2.55k forks source link

gdal2tiles TypeError: sequence item 0: expected str instance, tuple found when using -v #9272

Closed lopezvoliver closed 8 months ago

lopezvoliver commented 8 months ago

Expected behavior and actual behavior.

I got this error when trying to generate xyz tiles:

TypeError: sequence item 0: expected str instance, tuple found

Before the error, the tiles for the previous zoom level (13) were generated, the error occurred on the zoom level 12.

More details of the error:

Generating Overview Tiles:
tile_test/12/2483/1690.png
Traceback (most recent call last):
  File "/rhome/lopezom/ecrc/env/bin/gdal2tiles.py", line 17, in <module>
    sys.exit(main(sys.argv, called_from_main=True))
  File "/rhome/lopezom/ecrc/env/lib/python3.10/site-packages/osgeo_utils/gdal2tiles.py", line 4528, in main
    return submain(argv, called_from_main=called_from_main)
  File "/rhome/lopezom/ecrc/env/lib/python3.10/site-packages/osgeo_utils/gdal2tiles.py", line 4547, in submain
    single_threaded_tiling(input_file, output_folder, options)
  File "/rhome/lopezom/ecrc/env/lib/python3.10/site-packages/osgeo_utils/gdal2tiles.py", line 4414, in single_threaded_tiling
    create_overview_tile(base_tz, base_tiles, output_folder, conf, options)
  File "/rhome/lopezom/ecrc/env/lib/python3.10/site-packages/osgeo_utils/gdal2tiles.py", line 1576, in create_overview_tile
    logger.debug(f"\tbuild from zoom {base_tz}, tiles: %s" % ",".join(base_tiles))
TypeError: sequence item 0: expected str instance, tuple found

This is the raster info:

Driver: GTiff/GeoTIFF
Files: rgbtest.tif
Size is 3422, 2767
Coordinate System is:
GEOGCRS["WGS 84",
    ENSEMBLE["World Geodetic System 1984 ensemble",
        MEMBER["World Geodetic System 1984 (Transit)"],
        MEMBER["World Geodetic System 1984 (G730)"],
        MEMBER["World Geodetic System 1984 (G873)"],
        MEMBER["World Geodetic System 1984 (G1150)"],
        MEMBER["World Geodetic System 1984 (G1674)"],
        MEMBER["World Geodetic System 1984 (G1762)"],
        MEMBER["World Geodetic System 1984 (G2139)"],
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]],
        ENSEMBLEACCURACY[2.0]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["Horizontal component of 3D system."],
        AREA["World."],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (38.234400000000001,29.980100000000004)
Pixel Size = (0.000100000000000,-0.000100000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=PIXEL
  LAYOUT=COG
Corner Coordinates:
Upper Left  (  38.2344000,  29.9801000) ( 38d14' 3.84"E, 29d58'48.36"N)
Lower Left  (  38.2344000,  29.7034000) ( 38d14' 3.84"E, 29d42'12.24"N)
Upper Right (  38.5766000,  29.9801000) ( 38d34'35.76"E, 29d58'48.36"N)
Lower Right (  38.5766000,  29.7034000) ( 38d34'35.76"E, 29d42'12.24"N)
Center      (  38.4055000,  29.8417500) ( 38d24'19.80"E, 29d50'30.30"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Undefined
  NoData Value=0
  Overviews: 1711x1383, 855x691, 427x345
Band 2 Block=512x512 Type=Byte, ColorInterp=Undefined
  NoData Value=0
  Overviews: 1711x1383, 855x691, 427x345
Band 3 Block=512x512 Type=Byte, ColorInterp=Undefined
  NoData Value=0
  Overviews: 1711x1383, 855x691, 427x345

Steps to reproduce the problem.

This is the command I used:

 gdal2tiles.py --xyz -z 0-13 -v rgbtest.tif tile_test

Operating system

Ubuntu 22.04.4 LTS

GDAL version and provenance

Installed from conda-forge:

# Name                    Version                   Build  Channel
gdal                      3.8.3           py310haaa150b_0    conda-forge
libgdal                   3.8.3                hcd1fc54_0    conda-forge

I also tested on another environment using version 3.73 and got the same error.

I found this issue https://github.com/OSGeo/gdal/issues/8208 but it got closed because the user was trying to generate kmz file, which is not supported. Here, I am trying to generate xyz tiles.

lopezvoliver commented 8 months ago

The command works as expected using GDAL 3.6.2, released 2023/01/02.

jratike80 commented 8 months ago

Could you study the gdal_create utility https://gdal.org/programs/gdal_create.html and write a command that creates a similar file that you have for testing?

jratike80 commented 8 months ago

Like this it should be: gdal_create -of COG -outsize 3422 2767 -bands 3 -burn 255 -burn 50 -burn 50 -ot byte -a_srs epsg:4326 -a_ullr 38.2344 29.9801 38.5766 29.7034 gdal2tilestest.tif

I confirm that I get the same error on Windows with GDAL 3.8.3 (OSGeo4W) and Python 3.9.18.

rouault commented 8 months ago

fix in https://github.com/OSGeo/gdal/pull/9282 . Simple workaround is to remove the -v flag

lopezvoliver commented 8 months ago

fix in #9282 . Simple workaround is to remove the -v flag

Yep, this worked.