satellogic / telluric

telluric is a Python library to manage vector and raster geospatial data in an interactive and easy way
MIT License
87 stars 18 forks source link

Make GeoRaster2.resize faster #293

Closed drnextgis closed 3 years ago

drnextgis commented 3 years ago

Before (in-memory raster):

In [1]: import telluric as tl

In [2]: r = tl.GeoRaster2.open("creaf_gmap.tif", lazy_load=False)

In [3]: %time r.resize(ratio=0.5)
CPU times: user 3.38 s, sys: 23 ms, total: 3.4 s
Wall time: 3.4 s

Before (on-disk raster):

In [1]: import telluric as tl

In [2]: r = tl.GeoRaster2.open("creaf_gmap.tif", lazy_load=True)

In [3]: %time r.resize(ratio=0.5)
CPU times: user 193 ms, sys: 346 µs, total: 193 ms
Wall time: 193 ms

After (in-memory raster):

In [1]: import telluric as tl

In [2]: r = tl.GeoRaster2.open("creaf_gmap.tif", lazy_load=False)

In [3]: %time r.resize(ratio=0.5)  # 50x faster
CPU times: user 58.1 ms, sys: 8.62 ms, total: 66.7 ms
Wall time: 65.8 ms

After (on-disk raster):

In [1]: import telluric as tl

In [2]: r = tl.GeoRaster2.open("creaf_gmap.tif", lazy_load=True)

In [3]: %time r.resize(ratio=0.5)  # 2.5x faster
CPU times: user 64.9 ms, sys: 11.1 ms, total: 75.9 ms
Wall time: 75.2 ms
codecov-io commented 3 years ago

Codecov Report

Merging #293 (a94dd0c) into master (8103980) will increase coverage by 0.05%. The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   90.66%   90.71%   +0.05%     
==========================================
  Files          37       37              
  Lines        5956     5967      +11     
==========================================
+ Hits         5400     5413      +13     
+ Misses        556      554       -2     
Impacted Files Coverage Δ
telluric/georaster.py 93.49% <93.33%> (-0.03%) :arrow_down:
tests/test_georaster.py 100.00% <100.00%> (ø)
telluric/util/raster_utils.py 91.07% <0.00%> (+1.78%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8103980...a94dd0c. Read the comment docs.