I have several file with the following format: lat,lon,value. I would like to plot a colored grid map with such value for each one of the lat,lon point and overlapping it over the EU map.
Thanks for support.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are roughly two options: one using the lattice and sp package and the other using the ggplot2 package:
lattice / sp
First you have to transform your data to a
SpatialPixelsDataFrame(provided by the sp-package), assuming your data is calleddf:and then plotting:
overlaying additional information such as country boundaries can be done using the
sp.layoutargument:where
cntry_boundariesis aSpatialLines(DataFrame), orSpatialPolygons(DataFrame). Reading a polygonset into R can be done using thergdalpackage, or themaptoolspackage (readShapeLines).ggplot2
I personally prefer using
ggplot2overspplot.ggplot2is more flexible and has a more clear syntax. Note thatggplot2works with normaldata.frame‘s, and not with the spatial objects of the sp-package.A minimal example would look something like:
For more information see these earlier answers of mine: