[R] Adding points to a topo map

Frede Aakmann Tøgersen frtog at vestas.com
Sat Mar 22 09:02:05 CET 2014


Hi

Why didn't you google for "maps in R"?

Both the help pages for the GEOmap functions and the accompanying vignette for GEOmap clearly show how you should ad e.g. points to a map.

Here is what you could have done after a careful  reading of the documentation.

library(geomapdata)
data(japmap)

plotGEOmap(japmap)

points(139, 35.5, col = "red", pch = "*", cex = 5)

Or this:

PLOC=list(LON=c(137.008, 141.000), LAT=c(34.000, 36.992),
    x=c(137.008, 141.000), y=c(34.000, 36.992) )

PROJ = setPROJ(type=2, LAT0=mean(PLOC$y) , LON0=mean(PLOC$x) )
     
plotGEOmapXY(japmap, LIM=c(PLOC$LON[1], PLOC$LAT[1],PLOC$LON[2],
                         PLOC$LAT[2]) , PROJ=PROJ, add = FALSE )

pointsGEOmapXY(lon = 139, lat = 35.5, PROJ = PROJ, col = "red", pch = "*", cex = 5)


Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of kshel
> Sent: 22. marts 2014 00:18
> To: r-help at r-project.org
> Subject: [R] Adding points to a topo map
> 
> Hello R Users,
> 
> 
> I am trying to create a topographical map of Argentina with data
>  points showing the location of 5 species. I first created a map using
> map() with points using latitude and longitude data for all 5 species as
> follows:
> 
> 
> library(maps)
> 
> 
> # Latitude / longitude coordinates of the 5 species:
> 
> lat<-c(-44.000, -43.000, -26.000, -33.000, -36.000)
> 
> lon<-c(-68.000, -70.000, -67.000, -61.000, -68.000)
> 
> 
> map(regions='AR', xlim=c(-75, -53), ylim=c(-56, -20), las=1)
> 
> map.axes()
> 
> points(lon, lat, pch=20, col="gray50", cex=1.8)
> 
> 
> 
> This map does not give me the topographical relief I wanted, so I tried
> using the following code, which first downloads elevation information
> from NOAA and then creates a topo map of southern South American that
> includes Argentina:
> 
> 
> library(geomapdata)
> 
> library(GEOmap)
> 
> 
> data <- file(description =
> "http://www.ngdc.noaa.gov/mgg/global/relief/ETOPO5/TOPO/ETOPO5/ETO
> PO5.DAT", open = "rb", blocking = TRUE, encoding = getOption("encoding"),
> raw = FALSE)
> 
> 
> data(ETOPO5)
> 
> 
> PLOC=list(LON=c(-80.000,-50.000),LAT=c(-56.000,-20.000), x=c(-80.000,-
> 50.000), y=c(-56.000,-20.000) )
> 
> PROJ = setPROJ(type=2, LAT0=mean(PLOC$y) , LON0=mean(PLOC$x) )
> 
> COLS = settopocol()
> 
> JMAT = GEOTOPO(ETOPO5, PLOC, PROJ, COLS$calcol, nx=1000, ny=1000,
> nb=8, mb=8, hb=12, PLOT=TRUE)
> 
> 
> 
> I have attempted to add the 5 species points to this second
> map in a number of different ways, but I haven't been able to figure it
> out. In addition, I can not find documentation for how to do this in the
>  GEOmap pdf or online. Can someone please help me add these lat / long
> points to the topo map?
> 
> 
> Thank you in advance for your time and help.
> 
> K. Sheldon
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Adding-points-
> to-a-topo-map-tp4687330.html
> Sent from the R help mailing list archive at Nabble.com.
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list