OHI-Science/ohi-science.github.io

Sea Ice issue

Opened this issue · 5 comments

Hiya,
I’m working through the sea ice scripts and am really stuck with a particular error. I am making the maps for my regions as suggested here:

https://github.com/OHI-Science/ohiprep/blob/master/globalprep/hab_seaice/v2016/hab_seaice_dataprep.Rmd

and have reprojected my regions following PreparingSpatialFiles.R and I have adjusted ObtainingData.R for my system – I think correctly, but when I try to source it following hab_seaice_dataprep.Rmd I get the same error:

Error in .local(x, filename, ...) :
Attempting to write a file to a path that does not exist:
prep/spatial/pts/tmp2/n_type.tif

I created the path so I think it does exist – I have tried being more explicit, putting the full link in to the code, but it still does not work. I was just wondering if anyone has come across this and where I might be going wrong?

Thanks

Hi @mburgass

Have you walked through ObtainingData.R to see what line is throwing this error? If so, could you point me to it?

Hey - yeh I have. Seems to be line 102

writeRaster(r_type, file.path(maps, sprintf('pts/tmp2/%s_type.tif',p), overwrite=T))

Hi @mburgass

It looks like a file.path error. Here, you have

writeRaster(r_type, file.name= (maps, sprintf('pts/tmp2/%s_type.tif',p)), overwrite=T))

but since maps is a file.path defined in hab_seaice_dataprep, you'll need to change it to:

writeRaster(r_type, file.path(maps,sprintf('pts/tmp2/%s_type.tif',p)), overwrite=T)

I think there was also an extra parentheses in there. Try that and let me know how it goes

Hey - yes this worked thank you. It started running the script and processing all 888 rasters. This was running great up until around 220 when I got this error:

[1] "Retrieving n199705 (221 of 888). Minutes done=61.5, to go=185.5"
Error in setValues(r, x) :
length(values) is not equal to ncell(x), or to 1

I carried on running the script and have also had this problem with 251 and 260. I'm not sure why the error would only occur for a few of these? Is it a big problem?

Thanks,
Mike

@mburgass - I'm not familiar with this script (@Melsteroni worked on this for the global assessment), but I would suggest pulling out those two rasters and running the script step by step on one of them to see where it is hitting the error. Or maybe just looking at those two rasters by plotting them you will see why they are throwing errors - maybe they are all NA?