OSGeo / gdal

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

gdal2tiles too slow while add transparent parameter. #11302

Open sendreams opened 2 days ago

sendreams commented 2 days ago

What is the bug?

During the use of gdal2tiles, I encountered a few issues:

  1. After adding the -a parameter (to set the transparency color), the process runs very slowly.
    gdal2tiles D:\gis\data\hbsd\jsx\2996-UTM50.vrt D:\gis\tile\vrt -z 12 --xyz -w none -a 0
  2. If I use nested VRTs, the process is also very slow even without adding the -a parameter.
1732032873007

the snapshot source image

1732032925654

after set nodata value

1732032997090

the vrt file info

Driver: VRT/Virtual Raster
Files: D:\gis\data\hbsd\jsx\2996-UTM50.vrt
       D:\gis\data\hbsd\jsx\2996-UTM50.tif
Size is 147808, 50153
Coordinate System is:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    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]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (115.485182239101078,30.076076451982868)
Pixel Size = (0.000001022178749,-0.000001022178749)
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  ( 115.4851822,  30.0760765) (115d29' 6.66"E, 30d 4'33.88"N)
Lower Left  ( 115.4851822,  30.0248111) (115d29' 6.66"E, 30d 1'29.32"N)
Upper Right ( 115.6362684,  30.0760765) (115d38'10.57"E, 30d 4'33.88"N)
Lower Right ( 115.6362684,  30.0248111) (115d38'10.57"E, 30d 1'29.32"N)
Center      ( 115.5607253,  30.0504438) (115d33'38.61"E, 30d 3' 1.60"N)
Band 1 Block=512x128 Type=Byte, ColorInterp=Red
  Min=0.000 Max=255.000
  Minimum=0.000, Maximum=255.000, Mean=3.642, StdDev=23.192
  Overviews: 73904x25077, 36952x12538, 18476x6269, 9239x3135, 4620x1568, 2310x784, 1155x392, 578x196, 289x98
  Metadata:
    STATISTICS_COVARIANCES=537.8738799377072,472.54864919093,367.2624707721893
    STATISTICS_MAXIMUM=255
    STATISTICS_MEAN=3.6419380563056
    STATISTICS_MINIMUM=0
    STATISTICS_SKIPFACTORX=1
    STATISTICS_SKIPFACTORY=1
    STATISTICS_STDDEV=23.192108139143
Band 2 Block=512x128 Type=Byte, ColorInterp=Green
  Min=0.000 Max=255.000
  Minimum=0.000, Maximum=255.000, Mean=3.219, StdDev=20.444
  Overviews: 73904x25077, 36952x12538, 18476x6269, 9239x3135, 4620x1568, 2310x784, 1155x392, 578x196, 289x98
  Metadata:
    STATISTICS_COVARIANCES=472.54864919093,417.9571549986692,323.5913342639855
    STATISTICS_MAXIMUM=255
    STATISTICS_MEAN=3.2194881108267
    STATISTICS_MINIMUM=0
    STATISTICS_SKIPFACTORX=1
    STATISTICS_SKIPFACTORY=1
    STATISTICS_STDDEV=20.444000464651
Band 3 Block=512x128 Type=Byte, ColorInterp=Blue
  Min=0.000 Max=255.000
  Minimum=0.000, Maximum=255.000, Mean=2.483, StdDev=15.952
  Overviews: 73904x25077, 36952x12538, 18476x6269, 9239x3135, 4620x1568, 2310x784, 1155x392, 578x196, 289x98
  Metadata:
    STATISTICS_COVARIANCES=367.2624707721893,323.5913342639855,254.459050195018
    STATISTICS_MAXIMUM=255
    STATISTICS_MEAN=2.4828870904195
    STATISTICS_MINIMUM=0
    STATISTICS_SKIPFACTORX=1
    STATISTICS_SKIPFACTORY=1
    STATISTICS_STDDEV=15.951772634883

Steps to reproduce the issue

just add -a 0 to gdal2tiles parameter.

Versions and provenance

gdalversion: 3.10.0

Additional context

No response

sendreams commented 2 days ago

Without the -a parameter, it takes 10 seconds, but after adding it, 30 minutes have passed and it's still not finished.

jratike80 commented 2 days ago

I suppose that your source data is somehow special. My test with a 12000x12000 RGB image took about 210 seconds to run with and without -a 0. Without test data I cannot say what is special. Is it that the raster contains mostly zero pixels, or is the reason in the VRT that you use in between.

sendreams commented 1 day ago

@jratike80 i have cliped a tiny data for testing. sended a email to: gdal-dev@lists.osgeo.org

sendreams commented 15 hours ago

@jratike80 do you received the testing data?

jratike80 commented 15 hours ago

I do not see such mail on the list https://lists.osgeo.org/pipermail/gdal-dev/2024-November/date.html. Mailing list is not so good for attachents. If the test data is small you can attach it to this GitHub issue. Or put it into some download service and share a link. Or as a last option send private mail to me.