Description Usage Arguments Value Author(s) See Also Examples
Sets spatial coordinates to create SpatialSpectraDataFrame
objects. Adapted from the "coordinates<-"
method in the sp package.
1 | coordinates(object) <- value
|
object |
A |
value |
Spatial coordinates: either a matrix, list, or data
frame with numeric data, or column names, column number or a
reference: a formula (in the form of e.g. |
A SpatialSpectraDataFrame
object
Pierre Roudier pierre.roudier@gmail.com, from code from the sp package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Loading example data
data(australia)
spectra(australia) <- sr_no ~ ... ~ 350:2500
# The australia dataset does not have associated coordinates.
# To fake it is a spatial dataset, we will associate each spectra
# in the collection to a location in the meuse dataset provided
# by the sp package
# Loding the meuse.grid dataset from the sp package
library(sp)
data(meuse.grid)
coordinates(meuse.grid) = ~x+y
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
gridded(meuse.grid) = TRUE
# We randomly generate sampling locations on this grid
coords <- spsample(meuse.grid, n=nrow(australia)*2, type="random")
class(coords)
# We associate these locations to the spectra in the collection
#
# First, we add the coordinates in the data slot data
features(australia, safe=FALSE) <- as.data.frame(coords)[1:nrow(australia), ]
names(australia)
# Then we promote the SpectraDataFrame object to a SpatialDataFrame object
coordinates(australia) <- ~x+y
class(australia)
str(australia)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.