I'm simply plotting lat/longs from a file onto a map in R. I'm having some issues as the points I plot are displayed in roughly the correct area - but not accurate enough for me. I don't know if this is my code, the google map, or the resultion of the lat/longs? I think I've eliminated the latter (see below).
Code:
library (ggmap)
library (gdata)
whitelee_boundary <- c(left = -4.6, bottom = 55.5, right = -3.8, top = 55.8)
map2 <- get_stamenmap(whitelee_boundary, zoom = 12, maptype = "toner-lite")
ggmap(map2)
df <- read.table("WhiteleeLatLong.txt", header = FALSE)
lat=df[1]
lon=df[2]
lati=as.numeric(unlist(lat))
long= as.numeric(unlist(lon))
points(lati, long, col = "blue", cex = 1.0)
which results in blue circles plotted in a very tight(incorrect) geographical range
I then attempted to error check the points by manually displaying:
points(55.7, -4.4, col = "blue", cex = 1.0)
This results in no point being visibly added (making me think that this is my code or google map accuracy).
I originally thought this was a precision issue in read.table or numeric conversion, and have already consulted:
How to stop read.table from rounding numbers with different degrees of precision in R?
as.numeric() removes decimal places in R, how to change?
However it seems that the rounding is only aesthetic, and the numbers are stored with the requisite precision.
Apologies in advance - its been a very long time since my last coding task!
EDIT: When I command
points(-4.4, 55.7, col = "blue", cex = 1.0)
THe output is (ignore large circles):