[gdal-dev] [newbie] regridding netCDF

Etienne Tourigny etourigny.dev at gmail.com
Mon Jul 9 19:01:35 PDT 2012


Tom,

gdaltransform is for transforming individual points, not entire datasets

What you want to achieve can be done with the gdalwarp command-line
tool [1] . See [2] and [3] for more information regarding netcdf
support in gdal.

You will need gdal version 1.9 to work properly with netcdf files
(especially to use gdalwarp).

If your other files are in the LCC projection, I assume they conform
to the CF conventions [4] [5], which the gdal netcdf driver supports.

You can get information on the target projection with 'ncdump -h
file.nc' and 'gdalinfo file.nc' and 'gdalsrsinfo file.nc'


I cannot think of good documentation, but here are some pointers:

In a nutshell here is the command you would use:

gdalwarp -t_srs srs_def -te xmin ymin xmax ymax -tr 12000 12000
source.nc dest.nc

The -te parameters depend on the extents of the files you need to
match with, you can find them with 'gdalinfo file.nc' (on an existing
file with desired projection).

The -t_srs  parameter describes the LCC projection you want. To get
it, try 'gdalsrsinfo -o proj4 file.nc' . You should get something
similar to (but with different params):
'+proj=lcc +lat_1=33 +lat_2=45 +lat_0=40 +lon_0=263 +x_0=0 +y_0=0
+a=6371200 +b=6371200 +units=km +no_defs '

The -tr parameters are the resolution of the target file (in your case 12000 m).


If you have further questions post them here.
Etienne

[1] http://www.gdal.org/gdalwarp.html
[2] http://www.gdal.org/frmt_netcdf.html
[3] http://trac.osgeo.org/gdal/wiki/NetCDF
[4] http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html
[5] http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#lambert-conformal-projection



On Mon, Jul 9, 2012 at 8:16 PM, Tom Roche <Tom_Roche at pobox.com> wrote:
>
> summary: new user with limited geoinformatic background (including
> jargon familiarity) wants to know if any of the GDAL tools (e.g.,
> gdaltransform) can "regrid" netCDF data, such that data attributed to
> each gridcell in a source dataset at a given {projection, resolution}
> tuple is appropriately allocated to each gridcell in a target dataset
> at a different {projection, resolution}. If so, please give or point
> to an example.
>
> details:
>
> I'd appreciate advice suitability of GDAL tools for transforming values
> contained in one 2-d netCDF spatial grid in one {projection, resolution}
> to another, or pointers to other resources to consult. I see GDAL
> supports netCDF as a "raster format"
>
> http://gdal.org/formats_list.html
>
> but don't know if the following counts as "image processing" (which is
> what I tend to associate GDAL with), or if that matters. Further
> apologies in advance if the following is too verbose (I'm guessing this
> is a common usecase--or hoping :-) or uses the wrong vocabulary (please
> correct where needed), but here's what I mean:
>
> I want to take emissions of gaseous N2O from various sources in the
> contiguous US (CONUS) and input them to a particular atmospheric model
> (CMAQ). My group has other inputs (notably, meteorology) for our
> usecase on a 12 km x 12 km Lambert conformal conic (LCC) grid, and the
> model wants everything in one format, so I need to get our N2O
> emissions on that 12x12 LCC. However, most of my N2O emissions will be
> coming from global inventories (EDGAR, GEIA, GFED), which are all
> gridded lat-lon, but at differing resolutions (e.g., 0.1x0.1°). So
> I need to "regrid" the latter emissions, such that the mass emitted in
> each lat-lon gridcell in the source dataset is appropriately
> attributed (probably by spatial averaging) to one or more gridcells in
> the 12-km LCC target dataset (the extents of which are a subset of the
> global source dataset).
>
> How to do programmatically (driven by bash, python, R) on linux?
>
> Your coding recommendations are appreciated, as would be pointers to
> helpful resources, esp example code. TIA, and feel free to forward,
> Tom Roche <Tom_Roche at pobox.com>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list