I want to plot the data on the map and interpolate it but i do not know how to do it in r. This is what i have done so far.
library(ggmap)
gc <- geocode("Rakiraki,Fiji")
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Rakiraki,Fiji&sensor=false
map <- get_map(gc)
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=-17.399264,178.070532&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
(bb <- attr(map, "bb"))
ll.lat ll.lon ur.lat ur.lon
1 -17.81878 177.6318 -16.9801 178.5107
(bbox <- bb2bbox(bb))
left bottom right top
177.63177 -17.81878 178.51067 -16.98010
ggmap(map)
+ geom_point(
+ + aes(x = lon, y = lat),
+ + data = gc, colour = "red", size = 3
Error: unexpected '=' in:
"+ aes(x = lon, y = lat),
+ data ="
+ )
Error: unexpected ')' in "+ )"
data1 <-read.csv(file.choose(),header=T)
data1
Longitude Latitude Wind.Speed
1 177.8 -17.6 4.0
2 177.5 -17.5 3.5
3 178.0 -17.4 4.5
4 178.1 -17.6 4.0
5 178.2 -17.3 6.0
6 178.3 -17.7 6.5
7 178.3 -17.5 5.0
8 178.4 -17.6 5.5
Can anyone tell me how can i plot these data and how to interpolate it on the map.
I want the final map to look something like this. Please find attached enter image description here
There are quite a lot of issues with the code in your question. The parentheses are not closed at the end of geom_point
and there are +
symbols present which should not be there.
I am assuming you want to add the data in data1
to the map, ie wind speed at different locations. Something like this should work:
ggmap(map) +
geom_point(aes(x = Longitude,
y = Latitude,
size = Wind.Speed),
data = data1,
colour = "red")
It's not clear exactly what you mean by "interpolate" but perhaps something like stat_density2d
is what you had in mind? Add this to the above code:
+ stat_density2d(data = data1,
aes(x = Longitude, y = Latitude))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.