Hi, Funny to see how you can do things in multiple ways in R :). To add to the possibilities, you could probably also get this functionality using R and Grass. I would personally recommend to use overlay() as you don't have to install anything apart from the sp package, unlike using rsaga and SAGA. Especially if the only thing you want is to do an overlay. When there was other SAGA specific functionality you needed, SAGA would be a good option. In addition to not having to install a lot of software, overlay() has been used extensively, this in contrast to the raster package which is still experimental. But this is strictly my personal opinion ofcourse :). cheers, Paul
Kamran Safi Radolfzell wrote:
Hi all,
the raster package is although in its alpha stage very helpful in this
respect:
install.packages("raster", repos="http://R-Forge.R-project.org")
library(raster)
library(maptools)
X <-
Y <-
raster <- rasterFromFile("C:/yourfile")
(result <- data.frame(Long=x, Lat=y, Value=xyValues(raster, matrix(c(x,y),
ncol=2)))))
That should work. Remember to take out the install.package after initial
install. Of course you can work with several coordinates. Peadagogically
better is the overlay() function...
Very straight forward.
Kami
On Tue, 10 Mar 2009 11:04:23 +0100, Paul Hiemstra wrote
Hi,
An option using only R is to use the overlay() command from the sp
package, try running this example:
# Load data
library(sp)
data(meuse)
# point data
coordinates(meuse) = ~x+y
data(meuse.grid)
# grid data
gridded(meuse.grid) = ~x+y
overlay(meuse.grid, meuse)
# Returns the indices in meuse.grid correpsonding to the points in meuse
# get the data from meuse.grid, for example the column "dist"
# a non spatial vector
dist = meuse.grid$dist[overlay(meuse.grid, meuse)]
# A spatialPointsDataFrame
dist = meuse.grid[overlay(meuse.grid, meuse), "dist"]
Also check out the rgdal pacakge to get your data into R-spatial objects.
cheers,
Paul
Frauke Barthold wrote:
Dear list,
I have a soilmap as an Ascii grid and a dataframe with x and y
coordinates (these are sampling points). I would now like to extract values from the soilmap to the dataframe based on location, the x and y values. Is there any way to do this in R?
Cheers, Frauke
_________________________________________________________________ [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- Open WebMail Project (http://openwebmail.org)
Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul