4

I have a spatial Grid dataframe, Elev, that I want to crop by a spatial polygon object (state.sp).

I assigned the CRS to both objects with spTransform and the CRS defined as:

CRS.new<-CRS("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")  #EPSG:102003

Both objects seem to be in conformity CRS, because when I type

 > Elev@proj4string
    CRS arguments:
     +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83
    +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 

  > state.sp@proj4string
    CRS arguments:
     +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0+datum=NAD83
    +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 

Nevertheless, when I do

Felev <- Elev[state.sp, ]

It returns the following error:

Error: identicalCRS(x, y) is not TRUE 

Does anyone know why this might be happening?

  • 1
    Typo: there's a space missing in your first code block: "+y_0=0+datum=NAD83" - whether that's a typo in your work or just your post here we don't know... – Spacedman Jan 12 '17 at 16:56
3

Well, in case anyone has this problem, here's a solution I just realized that works. By simply:

proj4string(state.sp) <- CRS.new 
proj4string(Elev) <- CRS.new

before doing the over() and it works perfectly. I'm letting the question stay here, in the hope that it might help someone in the future. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.