Projected data in R-Gstat
On Mon, 18 Jun 2012, kapo coulibaly wrote:
As stated on the help page for proj4string, it "Sets or retrieves projection attributes on classes extending SpatialData". So proj4string does not reproject. There are various ways to do projection in R but from what you are describing maybe the simplest way for you would be to use the package *proj4* and the commands *project* or* ptransform* from this package. The help page for project is pasted below to give you an idea.
You may use proj4 if you like, but it does not support sp classes. For these, use the equivalent implementation in rgdal, see ?spTransform. Note, however, that gstat *does* work with data in geographical coordinates if the data are in the form of an object of a class defined in sp with the coordinate reference system set - see the example to variogram(). Roger
Hope it helps.
Cheers
Description
Projection of lat/long coordinates or its inverse.
Usage
project(xy, proj, inverse = FALSE, degrees = TRUE, silent = FALSE,
ellps.default="sphere")
Argumentsxy
input (list, matrix or 2d-array) - see details below.
proj
projection definition
inverse
if TRUE inverse projection is performed (from a cartographic projection
into lat/long), otherwise projects from lat/long into a cartographic
projection.
degrees
if TRUE then the lat/long data is assumed to be in degrees, otherwise in
radians
silent
if set to TRUE, warnings will be suppressed
ellps.default
default ellipsoid that will be added if no datum or ellipsoid parameter is
specified in proj. Older versions of PROJ.4 didn't require a datum (and
used sphere by default), but 4.5.0 and higher always require a datum or an
ellipsoid. Set to NA if no datum should be added to proj (e.g. if you
specify an ellipsoid directly).
On Sun, Jun 17, 2012 at 3:36 PM, Lindia99 <feimaobaobao at hotmail.com> wrote:
I am a beginner to geoStatistics and searched this thread when I have the same trouble to project latitude and longitude data to use krige. my location data is a n*2 matrix with colnames and 1 example below.
colnames(location)
[1] "latitude" "longitude"
location[1,]
latitude longitude 1 47.46947 -122.2829 and I use proj4string and get the error. How to fix this?
proj4string(location) = "+proj=longlat +datum=WGS84"
Error in function (classes, fdef, mtable) : unable to find an inherited method for function "proj4string<-", for signature "data.frame", "character" Thanks much! Lindia -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Projected-data-in-R-Gstat-tp7549970p7580233.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no