Sử dụng API GDAL Python để tạo mbtiles
Aug 19 2020
Tôi muốn tạo mbtiles bằng API GDAL Python. Làm cách nào tôi có thể tích hợp các tùy chọn định dạng cụ thể như "TILE_FORMAT = 'jpeg', QUALITY='90'"cho mbtiles?
from osgeo import gdal
path = r'C:\Users\go\my.vrt'
pathout = r'C:\Users\go\my.mbtiles'
src_ds = gdal.Open(path)
ds = gdal.Translate(pathout , src_ds, format = 'mbtiles')
ds = No
Trả lời
2 bugmenot123 Aug 19 2020 at 20:47
Đó là các tùy chọn sáng tạo . Bạn có thể chuyển Tùy chọn tạo để gdal.Translatesử dụng creationOptionstham số. Các tên giống như đối với gdal.TranslateOptionshàm:https://gdal.org/python/osgeo.gdal-module.html#TranslateOptions
Chúng phải là key=valuecặp dưới dạng chuỗi trong một danh sách.
Ví dụ của bạn:
creation_options = ["TILE_FORMAT=JPEG", "QUALITY=90"]
ds = gdal.Translate(
pathout, src_ds,
format='mbtiles', creationOptions=creation_options
)