[R-sig-Geo] plotting geographic coordinates on a map

atlasrrg atlasrrg at gmail.com
Thu Jul 14 17:36:04 CEST 2011


Hello, 

I am pretty sure that I am making a novice mistake here as I've only just
begun exploring spatial data in R. I have a data.csv file that contains
geographic coordinates as follows:

SEQUENCE,longitude,latitude,altitude
AF196835_Pc_40.77_73.96_1999.71,-73.96,40.77,18
AF202541_Hs_42.76_75.82_1999.66,-75.82,42.76,456
AF260967_Ec_40.77_73.96_1999.50,-73.96,40.77,18
AF404753_Cb_39.43_76.78_2000.50,-76.78,39.43,154
AF404754_Cp_40.95_74.07_2000.50,-74.07,40.95,18
...

I simply would like to plot these on a map of the US. I've tried all sorts
of approaches, including
> map('usa', project='albers', par=c(39,34))
> points(x=data$LONGITUDE, y=data$LATITUTUDE, col='red')

[as well as several other maps in the maps package]

and 

> all_states <-map_data("state")
> p <- ggplot()
> p <-p + geom_polygon( data=all_states, aes(x=long, y=lat, group = group),
> colour='white', fill = 'grey10')
> p
> mydata <-read.csv("geo.csv", header=TRUE, row.names=1, sep=",")
> p <- ggplot()
> p <- p+ geom_point( data=mydata) 

 and 

> library(sp)
> coordinates(WNV) <- c("latitude", "longitude")
> map('world')
> plot(WNV$latitude, WNV$longitude)


I was able to plot an example file coordinates on the world map in the maps
package, but not on the US map. If someone could please point me in the
right direction I would greatly appreciate your help!!

Thank you

Rebecca

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/plotting-geographic-coordinates-on-a-map-tp6583747p6583747.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list