[R-sig-Geo] make a raster from Aquarius files

Michael Sumner mdsumner at gmail.com
Fri Dec 1 21:44:44 CET 2017


Ah thanks, and sorry I didn't think any of those old HDF4 files were still
there!

This is HDF5 with subdatasets, from gdalinfo:

Subdatasets:

SUBDATASET_1_NAME=HDF5:"Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg"://l3m_data
  SUBDATASET_1_DESC=[180x360] //l3m_data (32-bit floating-point)

SUBDATASET_2_NAME=HDF5:"Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg"://palette
  SUBDATASET_2_DESC=[3x256] //palette (8-bit unsigned character)

so you need to use the subdataset string directly i.e.

raster("HDF5:"Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg")

or spit them out to seperate files at the command line first e.g.

gdal_translate Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg
Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg.tif -sds

and this assumes a suitable system with HDF5 etc. etc.

rgdal on Windows now has HDF5 drivers so should work there too, and Ben's
method also.

Cheers, Mike.

On Sat, 2 Dec 2017 at 07:27 Antonio Silva <aolinto.lst at gmail.com> wrote:

> Thanks Ben and Michael for the attention
>
> The file I'm trying to rasterize can be downloaded at
> https://oceancolor.gsfc.nasa.gov/cgi/l3
>
> I selected the Aquarius sea surface salinity smoothed file from June 2015
> (SMI HDF).
>
> As Ben pointed it is also available from OBPG Nasa Ocean Color site at
> https://oceandata.sci.gsfc.nasa.gov/Aquarius/Mapped/Monthly/1deg/V5.0_SSS/
>
> or directly from
> https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg.bz2
>
> Thanks again
>
> Antonio Olinto Avila da Silva
> Fisheries Institute
> São Paulo, Brasil
>
>
> 2017-12-01 12:35 GMT-02:00 Ben Tupper <btupper at bigelow.org>:
>
>> Hi,
>>
>> Those Aquarius files look quite different from others I have used from
>> OBPG (mostly MODISA and SeaWiFS).
>>
>> As a short-cut alternative, you could read all of the values into a
>> matrix and make a global raster from that.  An example is shown below.  You
>> can also subset the extraction as you have shown, but it might be easier to
>> subset after making the raster using raster::crop()
>>
>> CHeers,
>> Ben
>>
>>
>> ### START
>>
>> library(raster)
>> library(ncdf4)
>> library(rasterVis)
>>
>> filename = "Q20151522015181.L3m_MO_SCIA_V5.0_SSS_1deg"
>>
>> nc = ncdf4::nc_open(filename)
>> m = ncdf4::ncvar_get(nc, 'l3m_data')
>> ncdf4::nc_close(nc)
>> r = raster::raster(t(m))
>> rasterVis::levelplot(r)
>>
>> ### END
>>
>> > On Dec 1, 2017, at 6:24 AM, Michael Sumner <mdsumner at gmail.com> wrote:
>> >
>> > That file name does not correspond to the standard patterns used by the
>> > oceancolor site. All the L3m products from there are now (NetCDF 4.0)
>> .nc
>> > and so will work fine with raster/ncdf4.  (Some years ago they were
>> HDF4 -
>> > without an extension, as the shortcuts in the image thumbnails hints
>> > (SMI/HDF and BIN/HDF - SMI/L3m standard mapped image in your case).
>> >
>> > I think you've got some other provider's version of a file, but there's
>> not
>> > enough information here to know where you got it or what form it's in.
>> I'm
>> > happy to look if you can point us to the source of
>> > Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg.
>> >
>> > But otherwise, can you share with us the output of
>> >
>> > nc.data<-nc_open("Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg")
>> > print(nc.data)
>> >
>> > and if you're on a suitable system with HDF4 support a gdalinfo output
>> of
>> > the file would be useful too.
>> >
>> > Given that you can read it with ncdf4, and if it actually is NetCDF4
>> (not
>> > HDF4 or something else) you might help raster work with it by renaming
>> it
>> > to "Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg.nc" since (unlike GDAL
>> and
>> > the NetCDF lib itself) raster uses explicit extension to dispatch to
>> > different format logic code, though it ultimately sends it down to
>> rgdal to
>> > deal with if it can't recognize it - which is why I'm surprised you
>> can't
>> > get it to work and ( I'm guessing wildly now):
>> >
>> > Do you not have rgdal installed?
>> >
>> >
>> > What system are you on? Please use sessionInfo() to share details.
>> >
>> > Cheers, Mike.
>> > On Fri, 1 Dec 2017, 06:14 Antonio Silva, <aolinto.lst at gmail.com> wrote:
>> >
>> >> Hello
>> >>
>> >> Some time ago I prepared scripts to extract temperature data from Modis
>> >> Aqua files. It can be found at https://gist.github.com/aolinto
>> >>
>> >> HDF files can be downloaded at https://oceancolor.gsfc.nasa.gov/cgi/l3
>> >>
>> >> I got the Aquarius sea surface salinity smoothed file from June 2015.
>> >>
>> >> I could open and read the file:
>> >>
>> >> library(ncdf4)
>> >> library(raster)
>> >>
>> >> nc.data<-nc_open("Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg")
>> >> print(nc.data)
>> >> dim(ncvar_get(nc.data,"l3m_data"))
>> >> ncvar_get(nc.data,"l3m_data")[c(110:160),c(110:117)]
>> >>
>> >> But I could not prepare a raster from it. I tryed many things as:
>> >>
>> >> rst.data <-
>> >> raster("Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg",varname="l3m_data")
>> >> Error in .local(.Object, ...) :
>> >>  `AQUARIUS/Q20151522015181.L3m_MO_SCISM_V5.0_SSS_1deg' not recognised
>> as a
>> >> supported file format.
>> >>
>> >> Error in .rasterObjectFromFile(x, band = band, objecttype =
>> "RasterLayer",
>> >> :
>> >>  Cannot create a RasterLayer object from this file.
>> >>
>> >> and variations with band and layer.
>> >>
>> >> I would greatly appreciate any suggestions to solve this issue.
>> >>
>> >> Thanks
>> >>
>> >> --
>> >> Antônio Olinto Ávila da Silva
>> >> Fisheries Institute
>> >> São Paulo, Brasil
>> >>
>> >>        [[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
>> >
>> > --
>> > Dr. Michael Sumner
>> > Software and Database Engineer
>> > Australian Antarctic Division
>> > 203 Channel Highway
>> <https://maps.google.com/?q=203+Channel+Highway+%0D+%3E+Kingston+Tasmania+7050+Australia&entry=gmail&source=g>
>>
>> <https://maps.google.com/?q=203+Channel+Highway+%0D+%3E+Kingston+Tasmania+7050+Australia&entry=gmail&source=g>>
>> Kingston Tasmania 7050 Australia
>> <https://maps.google.com/?q=203+Channel+Highway+%0D+%3E+Kingston+Tasmania+7050+Australia&entry=gmail&source=g>
>> >
>> >       [[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
>>
>> Ben Tupper
>> Bigelow Laboratory for Ocean Sciences
>> 60 Bigelow Drive
>> <https://maps.google.com/?q=60+Bigelow+Drive&entry=gmail&source=g>, P.O.
>> Box 380
>> East Boothbay, Maine 04544
>> http://www.bigelow.org
>>
>> Ecocast Reports: http://seascapemodeling.org/ecocast.html
>> Tick Reports: https://report.bigelow.org/tick/
>> Jellyfish Reports: https://jellyfish.bigelow.org/jellyfish/
>>
>>
>>
>>
>
>
>
> --
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list