Skip to content

Clip smaller domain from large domain netCDF file

3 messages · Michael Sumner, Aseem Sharma

#
Hi,
I have this huge ( ~30GB) .nc file (NC_FORMAT_NETCDF4_CLASSIC)) for the
whole country 141.00 to 52.00 W, 41.00 to 84.00 N".
I am trying to clip this big dataset for a small region specific domain
(120.00 to 130.00 W, 50.00 to 60.00 N).
I am trying to do using netCDF4 r package but could not figure out how to
do so.
Kindly please suggest me how should i proceed.


Thank you,
#
First see if raster can open it:

library(raster)
r <- raster("/path/to/hugefile.nc")
r

That will require you have the ncdf4 package installed (I don't know
of any such package "netCDF4").

If that works, try to crop with

rc <- crop(r, extent(-130, -120, 50, 60))

possibly with an added filename argument, e.g.

rc <- crop(r, extent(-130, -120, 50, 60), filename =
"/different/physical/disk/out.grd")

But, this assumes you are only reading one slice in a possibly 3D or
even 4D data set. 30Gb suggests that you are dealing with at least a
time series here, so please report on the first attempt with raster.
You must also have some idea of what is in there so please include
that in your queries here.

If raster can't deal with it you'll need to use the general NetCDF
tools in ncdf4, so start with its documentation.

And please read the posting guide.

Cheers, Mike.
On Wed, Aug 27, 2014 at 9:48 AM, Aseem Sharma <nature.aseem at gmail.com> wrote:

  
    
#
Hi Michael, Thank you and regrets for poor questioning and typo. I mean
ncdf4.
Yes the .nc file has three variables namely precipitation, Tmin and Tmax
with their time series. I can read it using raster.
the print function give details of data as below.
(NC_FORMAT_NETCDF4_CLASSIC):"
[1] ""
[1] "     3 variables (excluding dimension variables):"
[1] "        float pr[lon,lat,time]   "
[1] "            standard_name: precipitation_flux"
[1] "            long_name: Precipitation"
[1] "            units: mm day-1"
[1] "            _FillValue: -32768"
[1] "            cell_methods: time: mean"
[1] "        float tasmax[lon,lat,time]   "
[1] "            standard_name: air_temperature"
[1] "            long_name: Daily Maximum Near-Surface Air Temperature"
[1] "            units: degC"
[1] "            _FillValue: -32768"
[1] "            cell_methods: time: maximum"
[1] "        float tasmin[lon,lat,time]   "
[1] "            standard_name: air_temperature"
[1] "            long_name: Daily Minimum Near-Surface Air Temperature"
[1] "            units: degC"
[1] "            _FillValue: -32768"
[1] "            cell_methods: time: minimum"
[1] ""
[1] "     3 dimensions:"
[1] "        lon  Size:1068"
[1] "            standard_name: longitude"
[1] "            long_name: longitude"
[1] "            units: degrees_east"
[1] "            axis: X"
[1] "        lat  Size:510"
[1] "            standard_name: latitude"
[1] "            long_name: latitude"
[1] "            units: degrees_north"
[1] "            axis: Y"
[1] "        time  Size:22280   *** is unlimited ***"
[1] "            standard_name: time"
[1] "            long_name: time"
[1] "            units: days since 1950-01-01 00:00:00"
[1] "            calendar: standard"

I am trying to using netCDf tools in ncdf4 but not figure out how to do so.
Thank you,



------------------

"Namaste ??????"

Aseem Sharma

Graduate Research Assistant

Northern Hydrometeorology Group(NHG)

Natural Resources and Environmental Studies Institute(NRESi)

University of Northern British Columbia

Prince George, BC, V2N 4Z9, Canada

Tel: 250-960-5427

Web: http://www.unbc.ca/


 "All know the Way, but few actually walk it."
"????? ?????? ???? ?"
On Tue, Aug 26, 2014 at 4:59 PM, Michael Sumner <mdsumner at gmail.com> wrote: