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.
Related
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.
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.
I have analysed tree core images through the raster package in an attempt to perform image analysis. In the image:
http://dx.doi.org/10.6084/m9.figshare.1555854
You can see the measured "vessels" (black and numbered) and also annual lines (red) which have been drawn using the locator function and represent each year of growth of the tree core.
By generating a list of the maximum y coordinates of each annual line I have been able to sort the vessels into years for this image. Which is what I am looking for. However, it has occurred to me that in reality things can get a little more difficult as seen in the next image:
http://figshare.com/articles/Complicated/1555855
The approach above will not work on this image as vessels from each year overrun so using the maximum y coordinates will not return the correct result.
So can anyone suggest another approach which may overcome this limitation? I have thought about using spatialpolygons but not sure this will achieve what I am looking for.
If you are creating the lines by clicking on the plot, you can use raster function drawLine or, for polygons, drawPoly. You could rasterize the polygons and mask that with the original image to get the vessels grouped by polygon (year).
Here is what I need: I have an image and want to plot on specific rectangle-shaped parts of it (e.g., imagine having a picture of a chessboard and wanting to fill every square with a different color). I would like to be able to easily specify the coordinates for these parts and take these coordinates into R for plotting.
I don't have any experience with making such plots. I've thought of simply inserting an image into a plot with rasterImage (), then plotting with polygon (), but the task of setting up the coordinates for the polygon function seemed too time consuming - hence the question above.
If you have any better ideas than using a set of coordinates for the polygon function, please share. Any leads or packages suggestions would also be helpful.
thank you. Marko.
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.