calbertsen / argosTrack

R package for fitting animal movement models to Argos (or other types of location) data
12 stars 7 forks source link

date line crossing animals, mapping functions centered on 0 #2

Open autumnlynn opened 6 years ago

autumnlynn commented 6 years ago

The plotting functions currently do not allow for date-line crossing (i.e. Pacific Ocean centered data in which the origin is 180 longitude). This makes it difficult to use the built in visualization functions for my data which cross the Pacific. Are there additional implications of this? I would have thought the lat and long data would have needed to be projected. Thanks very much!

calbertsen commented 6 years ago

Every function in the package works with any kind of coordinates/projections - not just latitude/longitude. Results are always in the same units as the input. As a consequence, the functions don't "know" that longitudes -180 and 180 are the same; every function will treat them as 360 degrees apart.

When you have data where this is a problem, you have to shift the longitude coordinates to be between e.g. 0 and 360 with something like:

y <- ifelse(x < 0, x + 360, x)

It is not just an issue for plotting but also for fitting the movement models. If you want the results back between -180 and 180, you can extract both fitted and observed positions using the getTrack function and transform using something like:

x <- ifelse(y > 180, y - 360, y)
autumnlynn commented 6 years ago

Gotcha, thanks. I tend to convert to 360, but you never know what a package has built in. In the package an error check if longitudes cross the dateline and an automatic conversion to 360 if this condition is met, or an explanation in the vignette where lats/longs are used as the example could be useful. Some animal movement functions have you indicate if you are using lat/long ("ll") and this would trigger the error check. Thanks for the great work.

On Mar 28, 2018, at 5:28 AM, Christoffer Moesgaard Albertsen notifications@github.com wrote:

Every function in the package works with any kind of coordinates/projections - not just latitude/longitude. Results are always in the same units as the input. As a consequence, the functions don't "know" that longitudes -180 and 180 are the same; every function will treat them as 360 degrees apart.

When you have data where this is a problem, you have to shift the longitude coordinates to be between e.g. 0 and 360 with something like:

y <- ifelse(x < 0, x + 360, x) It is not just an issue for plotting but also for fitting the movement models. If you want the results back between -180 and 180, you can extract both fitted and observed positions using the getTrack function and transform using something like:

x <- ifelse(y > 180, y - 360, y) — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.