[R-sig-Geo] Maintaining band names in multiband raster objects

Michael Sumner mdsumner at gmail.com
Thu Nov 20 21:14:33 CET 2014


There's just no model for the names in NetCDF, since it *really* stores a
3D array. The analogue in R would be the array's "dimnames", but with
NetCDF you'd have to store these names as another variable (sharing the
third dimension of your data), and restore them from there.



Do the end user's of the NetCDF really expect these character names, or do
they expect a "time" variable on one of the available dimensions? I would
just ensure that the "Z dimension" of the object is properly set before
writing (see setZ and getZ), and that this round-trips in the expected way.
The names can be easily added in R from getZ(x).


Cheers, Mike.

On Fri Nov 21 2014 at 03:34:24 Dutrieux, Loic <loic.dutrieux at wur.nl> wrote:

If you create a header for the file, using hrd(), with e.g. format='ENVI',
then you should be able to open it in pretty much any GIS software. You
have to point to the .gri file.
That will preserve band names for when you re-import in R, and make the
file possible to import in ArcGIS. I'm afraid you won't be able to get the
band names outside of R though.

Best regards,
Loïc
________________________________________
From: Wall, Wade A ERDC-RDE-CERL-IL [Wade.A.Wall at usace.army.mil]
Sent: Thursday, November 20, 2014 5:23 PM
To: Dutrieux, Loic; r-sig-geo at r-project.org
Subject: RE: Maintaining band names in multiband raster objects

It is convenient for me, unfortunately it is not convenient for downstream
users. They need a format that can be imported in (I hate to say it)
ArcGIS. They are having trouble importing the native raster format into
ArcGIS and I haven't had any luck either.

Wade A. Wall
US Army ERDC-CERL
P.O. Box 9005
Champaign, IL 61826-9005
1-217-373-4420
Wade.A.Wall at usace.army.mil




-----Original Message-----
From: Dutrieux, Loic [mailto:loic.dutrieux at wur.nl]
Sent: Thursday, November 20, 2014 9:33 AM
To: Wall, Wade A ERDC-RDE-CERL-IL; r-sig-geo at r-project.org
Subject: [EXTERNAL] RE: Maintaining band names in multiband raster objects

Hi Wade,

If that's convenient for you, try to store your data in the native format
of the raster package (.grd). It has the advantage of preserving layer
names.

Best regards,
Loïc
________________________________________
From: r-sig-geo-bounces at r-project.org [r-sig-geo-bounces at r-project.org] on
behalf of Wall, Wade A ERDC-RDE-CERL-IL [Wade.A.Wall at usace.army.mil]
Sent: Thursday, November 20, 2014 4:21 PM
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] Maintaining band names in multiband raster objects

Hi all,

I am trying to keep band names from imported netcdf files intact when I
export them using the writeRaster() function from the Raster package, but
they are removed and replaced with "Band1, band2, band3, etc."

The .nc files I am importing are located at
http://gdo-dcp.ucllnl.org/downscaled_cmip_projections/dcpInterface.html#Welcome

When I import the .nc files, names(raster object) yields band names such as
x2006.01.15 (January 15 2006). These names are interpretable and I would
like to preserve them.

Is there a way to specify band names for exported raster objects in R? I
have seen posts suggesting it is not possible, but if they can be read,
then they should be able to be written.

Wade A. Wall
US Army ERDC-CERL
P.O. Box 9005
Champaign, IL 61826-9005
1-217-373-4420
Wade.A.Wall at usace.army.mil<mailto:Wade.A.Wall at usace.army.mil>




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

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list