Amandine Chevalier
2007-Nov-13 14:29 UTC
[R] map - mapproj : problem of states localisation
Hi R-user, I am new with R and I have a problem with the map and mapproj fonctions : with the following code :>test_proj=mapproject(LONG_d01_vec_t1, LAT_d01_vec_t1, projection="lambert",parameters=c(30,60))>longitude_vec=test_proj$x >latitude_vec=test_proj$y>longitude_mat=matrix(longitude_vec,ncol=e_sn_d01) >latitude_mat=matrix(latitude_vec,ncol=e_sn_d01)>coordonnees=data.frame(longitude_vec,latitude_vec)>image.plot(as.image(MOD_VENT_d01_t1,coordonnees,nrow=e_we_d01,ncol=e_sn_d01),zlim=c(0,20),xlab="LONG",ylab="LAT",col=positiv_color(20),axes=FALSE)>map("world",proj="lambert",pa=c(30,60),lwd=1,col="slategrey",add=TRUE)>map.grid(c(-20,30,35,55),labels=TRUE,nx=5,ny=5,pretty=TRUE)>map("france",proj="lambert",pa=c(30,60),lwd=1,col="slategrey",add=TRUE)>map.grid(c(-20,30,35,55),labels=TRUE,nx=5,ny=5,pretty=TRUE)>map("italy",proj="lambert",pa=c(30,60),lwd=1,col="slategrey",add=TRUE)>map.grid(c(-20,30,35,55),labels=TRUE,nx=5,ny=5,pretty=TRUE)France and Italy are not co-localised with France and Italy from the world map… Now, I suppose that any of the three maps are well situated… Do you have any idea for my problem? Thanks very much for any help, Regards, Amandine [[alternative HTML version deleted]]
Unfortunately, your code is not self-contained. Please provide a completely self-contained set of commands which illustrate the problem (as described in the posting guide). If you mean a problem that the boundaries don't quite line up, as illustrated by: map("france") map("world", col=2, add=T) then try using the "worldHires" database from the mapdata package. HTH, Ray Brownrigg On Wed, 14 Nov 2007, Amandine Chevalier wrote:> Hi R-user, > > I am new with R and I have a problem with the map and mapproj fonctions : > > with the following code : > >test_proj=mapproject(LONG_d01_vec_t1, LAT_d01_vec_t1, > > projection="lambert", > > parameters=c(30,60)) > > >longitude_vec=test_proj$x > >latitude_vec=test_proj$y > > > >longitude_mat=matrix(longitude_vec,ncol=e_sn_d01) > >latitude_mat=matrix(latitude_vec,ncol=e_sn_d01) > > > > > >coordonnees=data.frame(longitude_vec,latitude_vec) > > > >image.plot(as.image(MOD_VENT_d01_t1,coordonnees,nrow=e_we_d01,ncol=e_sn_d0 > >1 > > ),zlim=c(0,20),xlab="LONG",ylab="LAT",col=positiv_color(20),axes=FALSE) > > >map("world",proj="lambert",pa=c(30,60), > > lwd=1,col="slategrey",add=TRUE) > > >map.grid(c(-20,30,35,55),labels=TRUE,nx=5,ny=5,pretty=TRUE) > > > >map("france",proj="lambert",pa=c(30,60), > > lwd=1,col="slategrey",add=TRUE) > > >map.grid(c(-20,30,35,55),labels=TRUE,nx=5,ny=5,pretty=TRUE) > > > >map("italy",proj="lambert",pa=c(30,60), > > lwd=1,col="slategrey",add=TRUE) > > >map.grid(c(-20,30,35,55),labels=TRUE,nx=5,ny=5,pretty=TRUE) > > France and Italy are not co-localised with France and Italy from the world > map> Now, I suppose that any of the three maps are well situated> > Do you have any idea for my problem? > > Thanks very much for any help, > > Regards, > > Amandine > > > > [[alternative HTML version deleted]]
On Wed, 14 Nov 2007, Amandine Chevalier wrote:> Thank you very much for your help, > > I work about my code so as to give you the example (attached file) : > > In the first case (azequalarea projection), france from the "france" map > and from the "world" map are well superimposed, whereas in the second case > (lambert projection), it is not. However, due to projections I used to > produce my data, it would be better to use the lambert projection...That is > not only a problem of boundaries that do not line up...it is like the map > of France (it would be the same with the Italy's map) was centered on the > figure without taking into account the lat-long...Can I also trust the > location of the world map ? > > Do you have any idea of the problem? > > Thank you veru much for your help, > > Regards, > > Amandine >It seems to me the problem doesn't need 200 lines of code and data to describe, it is merely: library(mapproj) map("france", proj="lambert", pa=c(30, 60)) map("world", proj="lambert", pa=c(30, 60), lwd=1, col="red", add=TRUE) So I've punted it to the maintainer of mapproj, who isn't me. Ray