Forum

Author Topic: TMS tiles are exported in the wrong zoom levels  (Read 807 times)

jhm

  • Newbie
  • *
  • Posts: 5
    • View Profile
TMS tiles are exported in the wrong zoom levels
« on: May 27, 2024, 11:04:03 AM »
Hey there,
I'm encountering a really odd bug with 2.1.1 (or more realistically: ever since 1.8.0) - i recently upgraded from 1.7.4 to 2.1.1 and somehow Tiles in RasterFormatTMS get exported in the wrong zoom levels.. The following worked fine in 1.7.4 but ever since 1.8.x it exports zoom levels 0 to 9 rather than 14 to 24:

Code: [Select]
chunk.exportRaster(os.path.join(results_dir, "tiles.zip"), format=Metashape.RasterFormat.RasterFormatTMS, image_format=Metashape.ImageFormat.ImageFormatPNG, source_data=Metashape.DataSource.OrthomosaicData, white_background=True, min_zoom_level=14, max_zoom_level=24, tile_width=256, tile_height=256, progress=progress_print, clip_to_boundary=boundaryClip)
Quote
...
2024-05-27T08:30:49.349647569Z ImportShapes: path = /mnt/b352cd76-98a3-45a6-a4c4-a0a6e5e3701c/cutline.geojson, boundary_type = OuterBoundary, format = 4, crs = WGS 84
2024-05-27T08:30:49.550751682Z ExportRaster: path = /tmp/output/tiles.zip, format = RasterFormatTMS, image_format = PNG, min_zoom_level = 14, max_zoom_level = 24, clip_to_boundary = off
2024-05-27T08:30:49.550823551Z generating levels: 0 .. 8
...

and the following somehow now exports zoom level 0 to 8 instead of 14 to 22...?

Code: [Select]
chunk.exportRaster(os.path.join(results_dir, "tiles_dem.zip"), format=Metashape.RasterFormat.RasterFormatTMS, image_format=Metashape.ImageFormat.ImageFormatPNG, raster_transform=Metashape.RasterTransformType.RasterTransformPalette, source_data=Metashape.DataSource.ElevationData, white_background=True, min_zoom_level=14, max_zoom_level=22, tile_width=256, tile_height=256, progress=progress_print, clip_to_boundary=boundaryClip)

I can't find any changes in the Python API pdf that would indicate any of my parameters have changed/are wrong..? Can anyone help me out?

Cheers,
Jan
« Last Edit: May 27, 2024, 11:38:04 AM by jhm »

jhm

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: TMS tiles are exported in the wrong zoom levels
« Reply #1 on: June 06, 2024, 09:19:54 AM »
Yeah.. So.. After some further inquiry here's a top tip for everyone running into the same problem:
don't trust the documentation:

Quote
exportRaster(path='', format=RasterFormatTiles, image_format=ImageFormatNone,
raster_transform=RasterTransformNone[, projection ][, region ], resolution=0,
resolution_x=0, resolution_y=0, block_width=10000, block_height=10000,
split_in_blocks=False, width=0, height=0[, world_transform ], nodata_value=-32767,
save_kml=False, save_world=False, save_scheme=False, save_alpha=True,
image_description=''[, image_compression ], network_links=True, global_profile=False,
min_zoom_level=-1, max_zoom_level=-1, white_background=True, clip_to_boundary=True,
title='Orthomosaic', description='Generated by Agisoft Metashape',
source_data=OrthomosaicData[, asset], north_up=True, tile_width=256, tile_height=256[,
progress])
Export DEM or orthomosaic to file.

Code: [Select]
global_profile (bool) – Use global profile (GeoPackage format only).
setting global_profile = True fixed it and it becomes pretty obvious that this parameter does not just have an impact on the mentioned GeoPackage format... Maybe that should be in the documentation...

Cheers, this has prevented me from ever upgrading beyond 1.7.4..