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 while plotting map in eems.plots #49

Open
nitinra opened this issue Jan 6, 2021 · 2 comments
Open

Error while plotting map in eems.plots #49

nitinra opened this issue Jan 6, 2021 · 2 comments

Comments

@nitinra
Copy link

nitinra commented Jan 6, 2021

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!

@dipetkov
Copy link
Owner

dipetkov commented Aug 8, 2021

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.

@emilyostrow
Copy link

I got this error when I did not add the same GPS point at the beginning and end of the .outer file.

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