jmsigner / amt

37 stars 13 forks source link

hr_locoh speedups #36

Closed JoshOBrien closed 3 years ago

JoshOBrien commented 3 years ago

Together, the two commits in this PR speed up a call to hr_locoh() with a track object with 20,000 rows about 4.3 fold, cutting its computation time from ~55 to ~13 seconds. For a track object with 30,000 rows, computation of a home range now takes 20 seconds, whereas the same call completely crashed R with the existing code.

Commit 45202b7 doesn't change the results output by hr_locoh(), whereas commit d117c52 does slightly. The MULTIPOLYGON output by the revised code is slightly larger (on the order of 0.03%) due to what appears to be a slight bit of buffering used by st_union(). The boundaries of the outputted MULTIPOLYGON, representing a home range about 16 km in length, differ nowhere by more than about 0.1 mm, so the discrepancy is -- at least for any practical purposes I can imagine -- insignificant, but is nonetheless present.

jmsigner commented 3 years ago

Great, many thanks for this.