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

Chagaris, Dave Dave.Chagaris at MyFWC.com
Wed Aug 13 18:26:53 CEST 2014


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]]



More information about the R-sig-Geo mailing list