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) : longitude > 360 after projecting data #42

Closed
StephPeriquet opened this issue Mar 12, 2019 · 4 comments
Closed

Comments

@StephPeriquet
Copy link

Hi there,

I am trying to work with my own dataset and I have issue with move_align() after projecting my data using spTransform. My initial data in LatLong format and I would like to plot it in UTM. Here is the code I used:
move_data <- df2move(d1, x="long",y="lat", proj="+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0", time = "Local", track_id="name")
move_data <- sp::spTransform(move_data, crs("+proj=utm +zone=33 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 "))
move_data1 <- align_move(move_data, res = 60, digit = "mean", unit = "mins")
Which result in the following error:
Error in .pointsToMatrix(p1) : longitude > 360

If I used the already projected data
move_data <- df2move(d1, x="x",y="y", proj="+proj=utm +zone=33 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 ", time = "Local", track_id="name")
move_data1 <- align_move(move_data, res = 60, digit = "mean", unit = "mins")
It results in the same error...
I did check and all the long, lat, x and y columns are numeric not factors.

What am I getting wrong?
Attached is a sample of my data.

Thanks in advance for the help!
Stephanie
test_file.txt

@16EAGLE
Copy link
Owner

16EAGLE commented Mar 12, 2019

Hi, the default interpolation method used by align_move is greatcircle which cannot be used with tracks not projected as lat/lon. Thus, if you want to use greatcricle, you could first align your data and then reproject them:

library(moveVis)
library(move)

df <- read.csv("dev/user_data/test_file.txt", sep = ";", stringsAsFactors = F)
df$Local <- as.POSIXct(df$Local)

move_data <- df2move(df, x = "long", y = "lat", proj = crs("+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"),
                     time = "Local", track_id= "name")
move_data <- align_move(move_data, res = 60, digit = "mean", unit = "mins")
move_data <- sp::spTransform(move_data, crs("+proj=utm +zone=33 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 "))

To stick to the order you applied, you need to switch spaceMethod to euclidean:

library(moveVis)
library(move)

df <- read.csv("dev/user_data/test_file.txt", sep = ";", stringsAsFactors = F)
df$Local <- as.POSIXct(df$Local)

move_data <- df2move(df, x = "long", y = "lat", proj = crs("+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"),
                     time = "Local", track_id= "name")

move_data <- sp::spTransform(move_data, crs("+proj=utm +zone=33 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 "))
move_data <- align_move(move_data, res = 60, digit = "mean", unit = "mins",
                         spaceMethod = "euclidean")

I hope this helps. I will replace the current error message with something pointing the user towards changing spaceMethod.

@StephPeriquet
Copy link
Author

StephPeriquet commented Mar 12, 2019 via email

@16EAGLE 16EAGLE closed this as completed Mar 12, 2019
@MatteoSebastianelli
Copy link

Hi all,
I'm also working with my own dataset (in LongLat format) and I'm getting a similar 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

please see #69

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