5

I have a large number of MODIS snow rasters which I am cropping with the extent of a shapefile. Currently, I am using spTransform so that my shapefile has the same CRS as the rasters.

This code works perfectly, it returns a new raster with the extent of the shapefile. My question is: is there any reason to avoid this sinusoidal projection? Mathematically, it should preserve area better than another projection. Are there any disadvantages?

Here is my code, for reference.

prj.aea="+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"

##Import shapefile with WGS84 projection
dsn=getwd() # assumes current dir is folder with shapefile(s) to import
ut.mgmt1=readOGR(dsn=dsn,layer=paste(GEO,sep="")) 
GEO=spTransform(ut.mgmt1,CRS=CRS(prj.aea))

temp = list.files(pattern="*.tif",recursive=FALSE)
####THIS WRITES A NEW, SMALLER RASTER####
for(x in 1:length(temp)){
    r1 = raster(temp[x])
    test = mask(r1,GEO)
    writeRaster(test,file=temp[x],overwrite=TRUE)
}
  • 1
    What's the down-vote for? – J.W. Powell Feb 26 '18 at 1:00
  • 1
    Downvotes can be for "unclear", and without a sample data set, or a pointer to where to download them, it could be said to be unclear what you are doing exactly. But a downvote without an explanation is a bit rude (PS wasn't me). – Spacedman Feb 26 '18 at 9:20
  • 1
    So maybe this is a bit unclear. When you download the rasters are they in the same sinusoidal projection as your prj.aea string? Do you have a choice to download rasters in another projection? Or are you asking if you should warp your rasters to another projection first? – Spacedman Feb 26 '18 at 9:25
  • @Spacedman The rasters are downloaded from NSIDC (nsidc.org/data/modis/data_summaries) and come in the sinusoidal projection (my prj.aea string). I cannot download them in any other projection. I am wondering if I should reproject them, since this is an uncommon projection, or if my data are fine. Specifically, if someone has had any problems with leaving MODIS snow data in this projection I would like them to let me know. – J.W. Powell Feb 26 '18 at 23:22
  • 1
    Any (non-trivial) reprojection of a raster is going to lose information. Keep it in the supplied projection as much as possible. Vector data reprojections are generally reversible and don't lose information so readily. – Spacedman Feb 26 '18 at 23:26
5

Got rid of the downvote, somebody is just trolling.

I have done this with MODIS rasters without problem before, in sinusoidal, you are right, should retain the area over other projections. That being said that is barely and as long as you are chopping out the same area on both, and they are in the same modern style projection i.e. wgs84 or sinusoidal, it shouldn't matter all that much.

If you are extracting the raster values check out the velox package which does the raster extractions through a c programmed package in r, makes everything a heck of a lot faster. I imagine that is the intention.

You seem like the type of person who would enjoy this: enter image description here

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.