-
Notifications
You must be signed in to change notification settings - Fork 2
Projecting data
Grid datum definition and transformation is performed by function projectGrid.
In the first example we use VALUE station data in the form of a climate4R object (included in package transformeR).
library(transformeR)
data("VALUE_Iberia_pr")For an overview of the spatial shape of this data we can extract the coordinates of the object (with getCoordinates) and plot them:
plot(getCoordinates(VALUE_Iberia_pr))This object has not a defined projection, however, we do know from the data provider that the datum and other projection arguments are: "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0" as passed to function CRS (package rgdal). Therefore we give this information to argument original.CRS to define the original projection. In this case we also transform the datum of the object (new.CRS = "+init=epsg:28992")
new <- projectGrid(VALUE_Iberia_pr,
original.CRS = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0",
new.CRS = "+init=epsg:28992")
plot(getCoordinates(new))We can perform the same operation for gridded data (e.g. object EOBS_Iberia_pr). In this case we also use package visualizeR (function spatialPlot) to plot the resulting projected data.
data("EOBS_Iberia_pr")
plot(get2DmatCoordinates(EOBS_Iberia_pr))
grid <- projectGrid(EOBS_Iberia_pr,
original.CRS = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0",
new.CRS = "+init=epsg:28992")
plot(get2DmatCoordinates(grid))
require(visualizeR)
spatialPlot(climatology(grid))