[R-sig-Geo] raster brick error cells are not equally spaced

Chagaris, Dave Dave.Chagaris at MyFWC.com
Tue Aug 19 21:42:41 CEST 2014


Thanks Mike.  That appears to be the problem.  I was able to install all the libraries from my laptop onto the workstation and the code now works on both machines (with older version of raster). 

Dave 

-----Original Message-----
From: Michael Sumner [mailto:mdsumner at gmail.com] 
Sent: Thursday, August 14, 2014 10:19 AM
To: Chagaris, Dave
Subject: Re: [R-sig-Geo] raster brick error cells are not equally spaced

On Thu, Aug 14, 2014 at 11:58 PM, Chagaris, Dave <Dave.Chagaris at myfwc.com> wrote:
> [deleted].  Any reason why it would work on one computer and not on the other?  Is it possible I don't have all the required packages (or wrong versions) on the workstation?
>

Only if you had a more recent version of raster on one computer that predated checks for these irregular axes.

(Please use the list in public).

Cheers, Mike.

>
>
> -----Original Message-----
> From: Michael Sumner [mailto:mdsumner at gmail.com]
> Sent: Wednesday, August 13, 2014 8:59 PM
> To: Chagaris, Dave
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] raster brick error cells are not equally 
> spaced
>
> Hello, can you point to or share one of the files? Sometimes these things are just a regular grid under the hood but that has been forgotten in favour of longitude/latitude arrays.
>
> If that's the case you can reconstruct the original grid and all is well, there's not really any precedent for this but I have a lot of examples that work well.  (Also sometimes there's only a small amount of numeric fuzz that you can ignore).
>
> The raster types cannot take grids that have irregular (rectilinear or
> curvilinear) coordinates. There's no way around this except some combination of these:
>
> - read the data in the raw using ncdf/ncdf4 or RNetCDF and use base 
> graphics with image() (which can deal with rectilinear grids), or
> points() or maybe polygons (which with care can  deal with curvilinear grids).
> - use the hidden argument "stopIfNotEqualSpaced=FALSE" to raster() to 
> get the data out and deal with the arrays as "index-only" grids
>
>
> Cheers, Mike.
>
>
>
> On Thu, Aug 14, 2014 at 2:26 AM, Chagaris, Dave <Dave.Chagaris at myfwc.com> wrote:
>> I am trying to read netcdf files into R using the brick function.  I have many netcdf files and want to process them on a 64bit workstation instead my 32bit laptop.  The code    I'm using works fine on my 32 bit laptop, but on the workstation I get an error "Error in .rasterObjectFromCDF(x, type = objecttype, band = band, ...) :
>>   cells are not equally spaced; you should extract values as points".
>>
>> Any  help is appreciated.
>>
>> On Laptop...
>>> library(raster)
>>
>>> library(ncdf)
>>
>>> windows(record=T)
>>
>>> sessionInfo()
>> R version 2.15.0 (2012-03-30)
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>> [5] LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] grDevices datasets  splines   graphics  stats     tcltk     utils     methods   base
>>
>> other attached packages:
>> [1] ncdf_1.6.6       raster_2.0-41    sp_1.0-11        svSocket_0.9-53  TinnR_1.0-5      R2HTML_2.2       Hmisc_3.9-3      survival_2.36-12
>>
>> loaded via a namespace (and not attached):
>> [1] cluster_1.14.2 grid_2.15.0    lattice_0.20-6 svMisc_0.9-65  tools_2.15.0
>>
>>> i = "expt_31.0_20130226.nc"
>>
>>> open.ncdf(paste(getwd(),i,sep='/'))
>> [1] "file C:/dave.chagaris/HYCOM/expt_31.0_20130226.nc has 4 dimensions:"
>> [1] "MT   Size: 1"
>> [1] "Depth   Size: 40"
>> [1] "Latitude   Size: 213"
>> [1] "Longitude   Size: 290"
>> [1] "------------------------"
>> [1] "file C:/dave.chagaris/HYCOM/expt_31.0_20130226.nc has 8 variables:"
>> [1] "float ssh[Longitude,Latitude,MT]  Longname: sea surf. height  [31.0H] Missval:1.26765060022823e+30"
>> [1] "float u[Longitude,Latitude,Depth,MT]  Longname: u-veloc. [31.0H] Missval:1.26765060022823e+30"
>> [1] "float v[Longitude,Latitude,Depth,MT]  Longname: v-veloc. [31.0H] Missval:1.26765060022823e+30"
>> [1] "float w_velocity[Longitude,Latitude,Depth,MT]  Longname: w-veloc. [31.0H] Missval:1.26765060022823e+30"
>> [1] "float temperature[Longitude,Latitude,Depth,MT]  Longname:  temp [31.0H] Missval:1.26765060022823e+30"
>> [1] "float salinity[Longitude,Latitude,Depth,MT]  Longname: salinity [31.0H] Missval:1.26765060022823e+30"
>> [1] "float mld[Longitude,Latitude,MT]  Longname: MLT (0.20 degC)   [31.0H] Missval:1.26765060022823e+30"
>> [1] "float mlp[Longitude,Latitude,MT]  Longname: MLT (0.03 kg/m3)  [31.0H] Missval:1.26765060022823e+30"
>>
>>> salt =
>>> brick(paste(getwd(),i,sep='/'),varname='salinity',lvar=4,level=2)
>> Warning messages:
>> 1: In rm(.SavedPlots) : object '.SavedPlots' not found
>> 2: In .rasterObjectFromCDF(x, type = objecttype, band = band, ...) :
>>   level set to: 1
>>
>> on workstation...
>>
>>> setwd('E:\\work\\data\\HYCOM')
>>
>>> .libPaths('C:\\Users\\dave.chagaris\\Documents\\R\\win-library\\3.1'
>>> )
>>
>>> library(raster)
>>
>>> library(ncdf)
>>
>>> sessionInfo()
>>
>> R version 2.15.1 (2012-06-22)
>>
>> Platform: x86_64-pc-mingw32/x64 (64-bit)
>>
>>
>>
>> locale:
>>
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>> States.1252
>>
>> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>>
>> [5] LC_TIME=English_United States.1252
>>
>>
>>
>> attached base packages:
>>
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>>
>>
>> other attached packages:
>>
>> [1] ncdf_1.6.6    raster_2.2-31 sp_1.0-15
>>
>>
>>
>> loaded via a namespace (and not attached):
>>
>> [1] grid_2.15.1    lattice_0.20-6 tools_2.15.1
>>
>>> i = "expt_31.0_20130226.nc"
>>
>>> open.ncdf(paste(getwd(),i,sep='/'))
>>
>> [1] "file E:/work/data/HYCOM/expt_31.0_20130226.nc has 4 dimensions:"
>>
>> [1] "MT   Size: 1"
>>
>> [1] "Depth   Size: 40"
>>
>> [1] "Latitude   Size: 213"
>>
>> [1] "Longitude   Size: 290"
>>
>> [1] "------------------------"
>>
>> [1] "file E:/work/data/HYCOM/expt_31.0_20130226.nc has 8 variables:"
>>
>> [1] "float ssh[Longitude,Latitude,MT]  Longname: sea surf. height  [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float u[Longitude,Latitude,Depth,MT]  Longname: u-veloc. [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float v[Longitude,Latitude,Depth,MT]  Longname: v-veloc. [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float w_velocity[Longitude,Latitude,Depth,MT]  Longname: w-veloc. [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float temperature[Longitude,Latitude,Depth,MT]  Longname:  temp [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float salinity[Longitude,Latitude,Depth,MT]  Longname: salinity [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float mld[Longitude,Latitude,MT]  Longname: MLT (0.20 degC)   [31.0H] Missval:1.26765060022823e+30"
>>
>> [1] "float mlp[Longitude,Latitude,MT]  Longname: MLT (0.03 kg/m3)  [31.0H] Missval:1.26765060022823e+30"
>>
>>> salt =
>>> brick(paste(getwd(),i,sep='/'),varname='salinity',lvar=4,level=2)
>>
>> Error in .rasterObjectFromCDF(x, type = objecttype, band = band, ...) :
>>
>>   cells are not equally spaced; you should extract values as points
>>
>> In addition: Warning message:
>>
>> In .rasterObjectFromCDF(x, type = objecttype, band = band, ...) :
>>
>>   level set to: 1
>>
>>
>>
>> David Chagaris, PhD
>> Associate Research Scientist
>> Florida Fish and Wildlife Conservation Commission Fish and Wildlife 
>> Research Institute
>> 100 8th Ave SE
>> St. Petersburg, FL  33701
>> 727-502-4959
>> fax: 727-893-1374
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsumner at gmail.com



--
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner at gmail.com


More information about the R-sig-Geo mailing list