Error: identicalCRS(x, y) is not TRUE after using the over() command
Hi Angel, We cannot reproduce your problem as we dont have access to your files, but it seems only one of the objects in your over-command is projected (border). Probably it will work better if you set proj4string also for pts1. Cheers, Jon
On 10/24/2014 5:12 PM, Angel Ferrero wrote:
Hi everyone,
I am new to doing this kind of thing in R, but I have been trying to perform co-kriging for a set of datapoints in relation to climate from the worldclim project based on a previous example I found using the meuse shp.
This is my code, and at the end of it, you can see the error I get: identicalCRS(x, y) is not TRUE after using the over() command.
I would appreciate if anybody could help me out this this.
Best
?ngel
#Let's first create a prediction grid for the interpolation, starting from the shape file
setwd(?*")
data<-read.table(?/*",header=T)
coordinates(data)=~long+lat
proj4string(data)=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
border0<-readOGR("country.shp","country")
border <- spTransform(border0, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))
proj4string(border)=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
bio <- getData("worldclim", var="bio", res=10) # this will download global data on minimum temperature at 10 min resolution
# can also get other climatic data, elevation, administrative boundaries, etc
bio1 <- raster(?*/wc10/bio1.bil") # Tmin for January
fromDisk(bio1) # values are stored on disk instead of memory! (useful for
bio1 <-bio1/10 # Worldclim temperature data come in decimal degrees
bio1
proj4string(bio1)=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
data <- spTransform(data, CRS("+proj=longlat +ellps=GRS80"))
border <- spTransform(border, CRS("+proj=longlat +ellps=GRS80"))
vals <-border at bbox
deltaLong <- as.integer((vals[1,2] - vals[1,1]) + 1.5)
deltaLat <- as.integer((vals[2,2] - vals[2,1]) + 1.5)
gridRes <-20 #change this value to change the grid size (in metres)
gridSizeX <- deltaLong / gridRes
gridSizeY <- deltaLat / gridRes
grd <- GridTopology(vals[,1],c(gridRes,gridRes),c(gridSizeX,gridSizeY))
pts <- SpatialPoints(coordinates(grd))
pts1 <- SpatialPointsDataFrame(as.data.frame(pts), data=as.data.frame(rep(1,nrow(as.data.frame(pts)))))
Over=over(pts1,border)
pts$border=Over
espinete<-na.exclude(as.data.frame(pts1))
coordinates(nona)=~x+y
gridded(espinete) <- TRUE
proj4string(espinete)=CRS("+proj=longlat +ellps=GRS80")
writeAsciiGrid(nona,"prediction_grid.asc")
When I run the
Over=over(pts1,border)
command, I get this error:
Error: identicalCRS(x, y) is not TRUE
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Jon Olav Sk?ien Joint Research Centre - European Commission Institute for Environment and Sustainability (IES) Climate Risk Management Unit Via Fermi 2749, TP 100-01, I-21027 Ispra (VA), ITALY jon.skoien at jrc.ec.europa.eu Tel: +39 0332 789205 Disclaimer: Views expressed in this email are those of the individual and do not necessarily represent official views of the European Commission.