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

Error in .pointsToMatrix(p1) : latitude > 90 In addition: Warning message: In .pointsToMatrix(p1) : longitude > 180 #69

Closed
MatteoSebastianelli opened this issue May 20, 2019 · 1 comment

Comments

@MatteoSebastianelli
Copy link

Hi all,
I'm also working with my own dataset (in LongLat format) and I'm getting an error message when trying to align my movement data with align_move(). My code is as following:

R.move<-move(as.numeric(R.ready$Longitude.decimal),as.numeric(R.ready$Latitude.decimal),
time = R.ready$Timestamp.1,
proj="+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
unique(timestamps(R.move))
timeLag(R.move,unit="mins")
m<-align_move(R.move, res = 1200, unit = "mins")

When I run this i get the following Error message:

Error in .pointsToMatrix(p1) : latitude > 90
In addition: Warning message:
In .pointsToMatrix(p1) : longitude > 180

Cannot figure out what is wrong here. Hope you can help me. See the data attached.
Many thanks in advance!
Matteo
Move_sample.txt

@16EAGLE
Copy link
Owner

16EAGLE commented May 21, 2019

Hi,

I could not reproduce the error but my guess is the column names of your data.frame R.ready were shifted, since " " is used as separator in Move_sample.txt, but " " is also contained in Timestamp1. When simply using read.csv or read.table with sep = " " to load your file, the number of column names and the number of columns differ and thus column names point to the wrong columns shifted by 1.

I based my guess on the fact that the following example works for your sample dataset and align_move does not throw an error here.

# read csv without header and row.names since no row.names contained
# sep = " " will split the last field (Timestamp.1) into two, thus the header would not match
df <- read.csv("Move_sample.txt", sep = " ", header = F, row.names = NULL,
               stringsAsFactors = F)
df <- df[-1,] # remove header row

# create data frame with lat, lon and timestamps from merging column 18 and 19
df <- data.frame(lat = as.numeric(df[,14]),
                 lon = as.numeric(df[,15]),
                 time = as.POSIXct(paste0(df[,18], " ", df[,19]), tz = "UTC"))

# remove rows with NA locations
df <- df[apply(df, MARGIN = 1, function(x) !any(is.na(x))),]

# create move object from df (you could also use move() for this)
m.df <- df2move(df, proj="+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0",
                x = "lat", y = "lon", time = "time")

# align movement
m.aligned <- align_move(m.df, res = 1200, unit = "mins")

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

2 participants