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

Adding scalebar: Error in .pointsToMatrix(p1) : longitude < -360 #68

Closed
J-Schaus opened this issue May 16, 2019 · 6 comments
Closed

Adding scalebar: Error in .pointsToMatrix(p1) : longitude < -360 #68

J-Schaus opened this issue May 16, 2019 · 6 comments
Labels

Comments

@J-Schaus
Copy link

Hello,
I am having some issues when trying to add the scale bar to the frame. If I don't add any scale bar, then everything works fine and I get the frames and video. This is the error I get:
Error in .pointsToMatrix(p1) : longitude < -360

My study area is small, so the scale bar should be lower than 1 km, so I am guessing it has to do with that. Is there any way to work around it.
This is my code. Thanks for your help.

GPS<-df2move(GPS, proj = "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0",
x = "Longitude" , y = "Latitude", time = "dt", track_id = "ID")

unique(timestamps(GPS))
timeLag(GPS, unit = "mins")

move_data <- align_move(GPS, res = 240, digit = 0, unit = "secs")

move_data <- sp::spTransform(move_data, crs("+init=epsg:3857"))
frames <- frames_spatial(move_data, path_colours = c("red"),
map_service = "osm",path_legend_title = NULL, map_type = "streets", map_res = 0.8, equidistant = F)

frames <- add_labels(frames, title = " (UK) 2019",
x = "Longitude", y = "Latitude") %>%
add_progress() %>%
add_scalebar() %>%
add_northarrow() %>%
add_timestamps(move_data, type = "label")

@16EAGLE
Copy link
Owner

16EAGLE commented May 21, 2019

Hello,
could you please run apply(sp::coordinates(GPS), MARGIN = 2, range) with your GPS object that you generated using df2move and post the result? This will display the minimum and maximum for both your longitude and latitude values.

Apart from that, the distance that should be displayed by the scale bar can be set in km using the distance argument in add_scalebar(), e.g. add_scalebar(distance = 0.2).

@J-Schaus
Copy link
Author

Hello,
I get:

apply(sp::coordinates(GPS), MARGIN = 2, range)
coords.x1 coords.x2
[1,] -0.97877 53.05509
[2,] -0.95424 53.06505
I have tried several things with the add_scalebar() but still not working, as I said it before, if I don't include this command, the video is generated without any problems, but without scale. Any idea what else could I try? Thanks,

@16EAGLE
Copy link
Owner

16EAGLE commented May 22, 2019

Thanks for the info. Could you provide me with a sample of your data set with which I can reproduce the error? Otherwise it is difficult to track it down.

@J-Schaus
Copy link
Author

GPS.xlsx
Sure, please find attached it. Thanks a lot for your help.
Regards,

@J-Schaus
Copy link
Author

Hi,
Just wondering if you had time to have a look at the data.
Thanks for the help!
Regard,

@16EAGLE
Copy link
Owner

16EAGLE commented Apr 29, 2020

Hi,

sorry, I lost track of this issue. This should be fixed by now. Originally, add_scalebar had issues with projections other than unprojected lat/lon. Your code works for me with the latest version:

library(moveVis)

gps <- xlsx::read.xlsx("GPS.xlsx", sheetIndex = 1)[1:58,1:6]
gps$dt <- as.POSIXct(gps$dt, format = "%d/%m/%Y %H:%M:%S")

GPS <- df2move(gps, proj = "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0",
             x = "Longitude" , y = "Latitude", time = "dt", track_id = "ID")

unique(timestamps(GPS))
timeLag(GPS, unit = "mins")

move_data <- align_move(GPS, res = 240, digit = 0, unit = "secs")
move_data <- sp::spTransform(move_data, crs("+init=epsg:3857"))

frames <- frames_spatial(move_data, path_colours = c("red"),
                         map_service = "osm", path_legend_title = NULL, map_type = "streets", map_res = 0.8, equidistant = F)

frames <- add_labels(frames, title = " (UK) 2019",
                     x = "Longitude", y = "Latitude") %>%
  add_progress() %>%
  add_scalebar() %>%
  add_northarrow() %>%
  add_timestamps(move_data, type = "label")

plot_zoom_png

@16EAGLE 16EAGLE closed this as completed Apr 29, 2020
@16EAGLE 16EAGLE added the bug label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants