# lists:
p1 <- sgo_points(list(-3.9369, 56.1165), epsg=4326)
lon <- c(-4.25181,-3.18827)
lat <- c(55.86424, 55.95325)
p2 <- sgo_points(list(longitude=lon, latitude=lat), epsg=4326)
#p3 will fill up the list 'desc' with NA's to have the same number of
#elements as coordinates in the list:
p3 <- sgo_points(list(longitude=lon, latitude=lat, desc="c1"),
coords=c("longitude", "latitude"), epsg=4326)
# dataframe:
ln <- c(-4.22472, -2.09908)
lt <- c(57.47777, 57.14965)
n <- c("Inverness", "Aberdeen")
df <- data.frame(n, ln, lt, stringsAsFactors = FALSE)
p4 <- sgo_points(df, coords=c("ln", "lt"), epsg=4326)
# plotting on a map:
if (require(maps)) {
map('world', regions=('uk'), xlim=c(-9, 0), ylim=c(54.5, 60.9))
points(x=p1$x, y=p1$y, pch=0, col="green") #Stirling
points(p4, pch=0, col="red")
text(p4, labels=p4$n, pos=1, cex=0.9)
}
Run the code above in your browser using DataLab