forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverview.py
executable file
·39 lines (28 loc) · 872 Bytes
/
overview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# SPDX-License-Identifier: MIT
# Copyright 2020 Even Rouault
import time
from osgeo import gdal
def doit(compress, threads):
gdal.SetConfigOption("GDAL_NUM_THREADS", str(threads))
filename = "/vsimem/test.tif"
ds = gdal.GetDriverByName("GTiff").Create(
filename, 20000, 20000, 3, options=["COMPRESS=" + compress, "TILED=YES"]
)
ds.GetRasterBand(1).Fill(50)
ds.GetRasterBand(3).Fill(100)
ds.GetRasterBand(3).Fill(200)
ds = None
ds = gdal.Open(filename, gdal.GA_Update)
start = time.time()
ds.BuildOverviews("CUBIC", [2, 4, 8])
end = time.time()
print("COMPRESS=%s, NUM_THREADS=%d: %.2f" % (compress, threads, end - start))
gdal.SetConfigOption("GDAL_NUM_THREADS", None)
doit("NONE", 0)
doit("NONE", 2)
doit("NONE", 4)
doit("NONE", 8)
doit("ZSTD", 0)
doit("ZSTD", 2)
doit("ZSTD", 4)
doit("ZSTD", 8)