eems
eems copied to clipboard
Error while plotting map in eems.plots
Hello,
I am trying to add a map to my eems plot.
This is the code I ran:
library(rworldxtra)
library(rworldmap)
library(rgdal)
cmcpath='/eems/runeems_snps/run1'
plotpath='/eems/runeems_snps/run1'
coord__long_lat <- read.table(paste0('inputeems', ".coord"))
projection_none<-"+proj=longlat +datum=WGS84"
projection_mercator<-"+proj=merc
+datum=WGS84"`
eems.plots(mcmcpath='/Users/nitinr/eems/runeems_snps/run1/', plotpath= '/Users/nitinr/eems/runeems_snps/run1/eems', longlat=TRUE, m.plot.xy = { points(coord__long_lat, col = "purple", pch=18) }, q.plot.xy = { points(coord__long_lat, col = "purple", pch=18) },out.png=FALSE),
projection.in = projection_none, projection.out = projection_mercator,
add.map =TRUE, col.map ="black", lwd.map =5)
This is the error I get:
Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'nlayers': cannot do this transformation In addition: Warning message: In rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, : 701 projected point(s) not finite
How do I get around it? Thank you!
If I read this correctly, the coordinates are in longitude/latitude but the contour plot of the migration rates is in Mercator. So that might be the issue.
To diagnose the error, I suggest that you start with the basic EEMS plot and then add components one by one. For example, first add the map, then change the projection, then add the original sampling locations. At the very least it will help you figure out what causes the error.
I got this error when I did not add the same GPS point at the beginning and end of the .outer file.