Data projection problem

494 views
Skip to first unread message

Jill Shephard

unread,
May 26, 2017, 1:12:30 AM5/26/17
to ctmm R user group
HI Chris

I have been working with my data by directly importing it, but the orientation of the data is off by approx 90 degrees. My data is in the southern hemisphere so I think I might need to project it. So far I have failed dismally. 

I import a movebank compatible csv file which I turn  into a data frame and change the time format to POSIXct. I then convert the dataframe to an as.telemetry object. I can then run all the analysis as normal - but the orientation is out which is annoying. I tried to set the projection as part of the as.telemetry stage but have not been able to get the syntax right.

As an alternative I tried converting the original dataframe to a move object that had been projected and then tried converting this to an as.telemetry object but it returns the error:

Error in validObject(.Object) : 
  invalid class “SpatialPointsDataFrame” object: invalid object for slot "data" in class "SpatialPointsDataFrame": got class "factor", should be or extend class "data.frame"

and fails to import.

Can you please provide the syntax to apply the following projection (so that I can add it to the as.telemetry step e.g. data <-as.telemetry(data, projection= XXXX) :
 "+proj=longlat +ellps=WGS84"

or if possible even the full CRS which would include CRS('+init=epsg:32750')) for Western Australia.

Thank yo very much for your help

Jill

Christen Fleming

unread,
May 28, 2017, 10:35:55 AM5/28/17
to ctmm R user group
Hi Jill,

The default projection is 2-point equidistant, which is fairly safe and can handle some global migrators for which other projections fail, but it does not preserve north being up. However, if you are going to take the results of analysis in ctmm and export them to plot in other software/packages, then that doesn't matter.

If you have a Movebank formatted CSV file, then you should be able to feed that directly into as.telemetry with a PROJ4 formatted projection argument.

I'm not sure what's happening with that move object. I would need to see the data/object to take a look at it. Feel free to email/message me data & code that can reproduce that error.

For the projection argument, you don't want longlat, because that isn't a locally tangent projection. I am not super familiar with PROJ4, but here is some code I use to center on the data with a 1-point equidistant projection, like what Move uses.

datum <- "WGS84"
lon_0 <- stats::median(lon)
lat_0 <- stats::median(lat)
proj <- paste0("+proj=aeqd +lon_0=",lon_0," +lat_0=",lat_0," +datum=",datum)

Best,
Chris

Jill Shephard

unread,
May 28, 2017, 10:11:24 PM5/28/17
to ctmm R user group
Excellent, thanks Chris, that code fixes the orientation thing completely :) very happy.

Cheers

Jill
Reply all
Reply to author
Forward
0 new messages