[R-sig-Geo] list to points, reproject, interpolate

Robert J. Hijmans r.hijmans at gmail.com
Thu Oct 28 21:28:34 CEST 2010


Dear Tom,

Here are some hints:

Do you really have a "list" object? Or do you have a matrix or data.frame?
If you have a matrix 'xyz', create a data.frame like:

xyv <- data.frame(xyv)

library(sp)
#define crs
crs <- CRS("+proj=longlat +datum=WGS84")

# create sp object
pts <-  SpatialPointsDataFrame(coords=xyv[,1:2],
data=xyv[,3,drop=FALSE], proj4string=crs )

# alternative route:
pts <- data.frame(xyv)
colnames(pts) <- c('lon', 'lat')
coordinates(pts) <- ~ lon + lat
pts at proj4string <- crs


# However, if you got the data from a RasterLayer (it looks like it)
# you can avoid the above and simply do:
library(raster)
pts <- rasterToPoints(r, spatial=TRUE)


# Either way, now you can use spTransform

prpts <- spTransform( pts, crs=CRS("+proj=aea +lat_1=55 +lat_2=65
+lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m
+no_defs"  ))

# and perhaps extract the coordinates again

newxy <- coordinates(prpts)

For spline interpolation see fields (and the example in
raster::interpolate) and perhaps akima package. I do not know if
natural neighbor is available.

Robert

On Thu, Oct 28, 2010 at 11:23 AM, Tom Kurkowski
<tom.kurkowski at alaska.edu> wrote:
> I have a list of points as (X,Y,value) corresponding to longitude, latitude,
> value.  The points come from files that are assigned crs="+proj=longlat
> +datum=WGS84"
>
> My goal is to convert this list into some type of geographically referenced
> vector format, and then to reproject it to NAD83 Alaska Albers
> (crs="+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0
> +ellps=GRS80 +datum=NAD83 +units=m +no_defs")
>
> I am familiar with the raster package, but is there a similar package that
> can do the above using vector formats?
>
> The next step would be to interpolate these newly projected points using
> natural neighbor or the spline methods setting a specific cell size.  Which
> packages can use these methods?
>
> In summary, list > pts > reproject pts > interpolate pts
>
> I appreciate any guidance immensely,
> Tom
>
>  Tom Kurkowski | Data Solutions Lead
> Scenarios Network for Alaska & Arctic Planning <http://www.snap.uaf.edu/>
> University of Alaska | 3352 College Rd | Fairbanks AK 99709
> tom.kurkowski at alaska.edu | 907.474.5539
> Find us on Facebook!<http://www.facebook.com/pages/SNAP-and-ACCAP/112992248723524?v=wall>
>
>        [[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
>



More information about the R-sig-Geo mailing list