Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the new cellarea and reproject to Proj #781

Closed
asinghvi17 opened this issue Oct 8, 2024 · 2 comments
Closed

Switch the new cellarea and reproject to Proj #781

asinghvi17 opened this issue Oct 8, 2024 · 2 comments

Comments

@asinghvi17
Copy link
Collaborator

asinghvi17 commented Oct 8, 2024

This should ideally make things faster.

Benchmark MWE (on #768 with ArchGDAL):

# setup
using Rasters, ArchGDAL, Chairmarks
using Rasters.Lookups
dX = 0.0006
dY = -0.0003
lon = X(Projected(166.0:dX:167.0; sampling=Intervals(Start()), order=ForwardOrdered(), span=Regular(dX), crs=EPSG(4326)))
lat = Y(Projected(-78.0:dY:-79.0; sampling=Intervals(Start()), order=ForwardOrdered(), span=Regular(dY), crs=EPSG(4326)))
ras = Raster(rand(lon, lat))
ras2 = Rasters.reproject(ras; crs = Rasters.EPSG(3857))

# benchmarks
julia> @be Rasters.cellarea(Planar(), ras2) seconds=3
Benchmark: 634 samples with 1 evaluation
 min    3.289 ms (18 allocs: 42.518 MiB)
 median 3.646 ms (18 allocs: 42.518 MiB)
 mean   4.695 ms (18 allocs: 42.518 MiB, 7.53% gc time)
 max    185.097 ms (18 allocs: 42.518 MiB, 96.16% gc time)

julia> @be Rasters.cellarea(Spherical(), ras2) seconds=30
Benchmark: 3 samples with 1 evaluation
        12.187 s (161175590 allocs: 6.004 GiB, 5.18% gc time)
        12.258 s (161175590 allocs: 6.004 GiB, 5.32% gc time)
        12.640 s (161175590 allocs: 6.004 GiB, 7.09% gc time)
julia> @be Rasters.reproject($ras; crs = Rasters.EPSG(3857))
Benchmark: 23 samples with 1 evaluation
 min    4.075 ms (35167 allocs: 1.254 MiB)
 median 4.168 ms (35167 allocs: 1.254 MiB)
 mean   4.186 ms (35167 allocs: 1.254 MiB)
 max    4.362 ms (35167 allocs: 1.254 MiB)

With Proj:

julia> @be Rasters.cellarea(Spherical(), ras2) seconds=30
Benchmark: 8 samples with 1 evaluation
 min    3.802 s (22231194 allocs: 1.532 GiB, 3.35% gc time)
 median 3.937 s (22231194 allocs: 1.532 GiB, 3.82% gc time)
 mean   4.170 s (22231194 allocs: 1.532 GiB, 3.92% gc time)
 max    5.337 s (22231194 allocs: 1.532 GiB, 4.70% gc time)

julia> @be Rasters.reproject($ras; crs = Rasters.EPSG(3857))
Benchmark: 120 samples with 1 evaluation
 min    629.834 μs (108 allocs: 42.859 KiB)
 median 676.875 μs (108 allocs: 42.859 KiB)
 mean   772.257 μs (108 allocs: 42.859 KiB)
 max    8.718 ms (108 allocs: 42.859 KiB)

Not bad - x6 improvement in reproject, 3x improvement in cellsize

@asinghvi17
Copy link
Collaborator Author

Implemented in tiemvanderdeure#2

@tiemvanderdeure
Copy link
Contributor

I think we can close this now.

@rafaqz rafaqz closed this as completed Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants