Create land surface temperature map in R - r

I have a csv file containing latitude, longitude and temperature for san joaquin valley. I want to plot the latitude and longitude on the y and x axes respectively.I want to use the google base map. The temperature at a particular latitude and longitude should be plotted as a surface map like shown in the image below.
Please guide me to achieve the output as shown in the picture.
http://i.stack.imgur.com/r8loG.png
Thank you so much.

You can very easily use ggvis to make the type of map that you want. You will need more than just lat and lon to make it happen if you are looking ot have some kind of color transition based on a prevalence of some kind. It may be in another column and tied to your labeling method.
Here is a solid site to help you get started.
ggvis mapping
Work through the examples to figure out what is happening beneath the code before you dive right into your own unless you are very familiar with R and the ggvis environment.
Without a starting code base, no one is going to be able to help you more than this...get started and then ask more specific questions.

Related

Producing a map across the date line in R studio

I'm trying to produce a map with points which are where earthquakes happen.
I have a region in the Aleutian Islands which crosses the date line, as in longitude -180/180.
The problem is the R map creates one around the whole world, with points being on either end of the map. As in, the range of longitude is (-180,180).
I'd like the map to be centered around the Aleutian ranges, i.e. range of longitude is (150,-150). Please find below code with mock data, which makes a map with the issue.
library("maps")
SC=3
longitude=c(170,175,179,-180,-175,-170)
latitude=rep(50,6)
x=data.frame(longitude,latitude)
xmin=floor(min(x$longitude))-SC
xmax=ceiling(max(x$longitude))+SC
ymin=floor(min(x$latitude))-SC
ymax=ceiling(max(x$latitude))+SC
xlim=c(floor(min(x$longitude))-SC,ceiling(max(x$longitude))+SC)
ylim=c(floor(min(x$latitude))-SC,ceiling(max(x$latitude))+SC)
map("world",xlim=xlim,ylim=ylim,
main="EQ map")
map.axes(cex.axis=1)
points(x$longitude,x$latitude,pch=17)
Any suggestions on how to fix this would be much appreciated.

How to obtain koppen-geiger climate map for ggmap

I would like to use ggmap to plot several data points on top of a koppen-geiger climate map.
The kopper-geiger data and GIS/KMZ maps can be downloaded here:
http://koeppen-geiger.vu-wien.ac.at/present.htm
I've managed to have a code to plot the points on regular maps, obtained through the get_map function but I fail to use other maps such as koppen-geiger.
Any help will be appreaciated!
Your basic problem is that the map you are attmepting to use is an image file that is not georeferenced. So unless you want to go through the unnecessary and probably time consuming process of georeferencing this image yourself, you will be better taking an alternative approach. There are perhaps a few ways to do this. But, unless you have very few data points to overlay on the map which you can place manually using the lat-long grid of the image, then the least painful method will certainly be to redraw the map yourself using the shapefile.
This is not the right place to give you an introductory lesson on GIS, but the basic steps are to
Download shapefile (which is available at the same website as the image you linked)
Project map to desired coordinate system
Plot map, coloring by climate class
Color the ocean layer
Add labels, legend, and graticule, as desired
Overplot with your own climate data, and legend for these.
If you are unsure how to approach any of these steps, then take an introductory course on GIS, and search the Web for instructional materials. You may find this resource useful.
https://cran.r-project.org/doc/contrib/intro-spatial-rl.pdf

Plotting Long and Latitude in R

I would like to know how to plot latitude and longitude readings in R.
Drive Route:
I want something like the above image. The route is for a street in Nigeria and the lat/long readings were obtained from a GPS. The plot was done with MapInfo but I would appreciate if someone can show me how it is done in R. I am still a newbie in R.
I agree with Andy on doing some more research before asking questions, but to get you started I would suggest you have a look at the ggplot2 and ggmap package combination. Which can be used to set up maps and plot gps locations on these maps.
I mainly use it to plot sample locations, but I guess you could also use it to plot routes/lines.

R non gridded filled contour

I have a set of data that I'm trying to create a surface plot of. I have an x,y point and a to colour by.
I can create a xy plot with the points coloured but I can't find a way to create a surface plot with my data. The data isn't on a normal grid and I would prefer to not normalize it if possible (or I could just use a very fine grid).
The data won't be outside the a radius=1 circle so this part would need to be blank.
The code and the plot is shown below.
I've tried using contour, filled.contour as well as surface3d (not what I wanted). I'm not real familiar with many packages in R so I'm not even sure where to begin looking for this info.
Any help in creating this plot would be appreciated.
thanks,
Gordon
dip<-data.frame(dip=seq(0,90,10))
ddr<-data.frame(ddr=seq(0,350,10))
a<-merge(dip,ddr)
a$colour<-hsv(h=runif(nrow(a)))
degrees.to.radians<-function(degrees){
radians=degrees*pi/180
radians
}
a$equal_angle_x<-sin(degrees.to.radians(a$ddr))*tan(degrees.to.radians((90-a$dip)/2))
a$equal_angle_y<-cos(degrees.to.radians(a$ddr))*tan(degrees.to.radians((90-a$dip)/2))
plot(a$equal_angle_x,a$equal_angle_y,col=a$colour,lwd=10)
With regards to the plot I was trying to create is below. I believe the link in the first comment should get me where I'm trying to go.

Using R for extracing data from colour image

I have a scanned map from which i would like to extract the data into form of Long Lat and the corresponding value. Can anyone please tell me about how i can extract the data from the map. Is there any packages in R that would enable me to extract data from the scanned map. Unfortunately, i cannot find the person who made this map.
Thanks you very much for your time and help.
Take a look at OCR. I doubt you'll find anything for R, since R is primarily a statistical programming language.
You're better off with something like opencv
Once you find the appropriate OCR package, you will need to identify the x and y positions of your characters which you can then use to classify them as being on the x or y axis of your map.
This is not trivial, but good luck
Try this:
Read in the image file using the raster package
Use the locator() function to click on all the lat-long intersection points.
Use the locator data plus the lat-long data to create a table of lat-long to raster x-y coordinates
Fit a radial (x,y)->(r,theta) transformation to the data. You'll be assuming the projected latitude lines are circular which they seem to be very close to but not exact from some overlaying I tried earlier.
To sample from your image at a lat-long point, invert the transformation.
The next hard problem is trying to get from an image sample to the value of the thing being mapped. Maybe take a 5x5 grid of pixels and average, leaving out any gray pixels. Its even harder than that because some of the colours look like they are made from combining pixels of two different colours to make a new shade. Is this the best image you have?
I'm wondering what top-secret information has been blanked out from the top left corner. If it did say what the projection was that would help enormously.
Note you may be able to do a lot of the process online with mapwarper:
http://mapwarper.net
but I'm not sure if it can handle your map's projection.

Resources