[GRASS-user] issues with netCDF import

I am having some difficulty with the import of a netCDF dataset into GRASS 7. The dataset I am attempting to import is a 30 second global LAI dataset that can be found here: http://globalchange.bnu.edu.cn/research/lai/

I have successfully imported other netCDF files into this build (worldCLIM and the soils data from the same source as this LAI data, for example), but this particular data is giving me issues. I have tried several files from several of the years available of the global LAI product. I get the same results.

I am running the following commands in a global lat/lon location:

g.region n=90 s=-90 e=-180 w=180 res=0.008333333767951 (I have also tried res=00:00:30.)
r.in.gdal input=NETCDF:"global_30s_2009_153.nc":lai output=testNETCDF -o

The file imports with some warnings.

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
WARNING: Over-riding projection check
WARNING: Fixing subtle input data rounding error of south boundary
          (-9.38773e-06>4.62963e-08)

It appears to be null when plotted, though r.info reports min of 0 and max of 70. r.info hints at an issue with the e-w resolution:

  | N: 90N S: 90S Res: 0:00:30
  | E: 179:59:59.932408W W: 180W Res: 0:00:00.000002

r.stats seems to indicate that all data is null?

r.stats testNETCDF -cp
100%
* 900072000 100.00%

d.histogram plots nothing.

Any hints would be greatly appreciated.

Thanks!!

-Damian

Hi Damian,

···

On Wed, Mar 19, 2014 at 1:47 PM, Damian Maddalena <damianmaddalena@gmail.com> wrote:

I am having some difficulty with the import of a netCDF dataset into GRASS 7. The dataset I am attempting to import is a 30 second global LAI dataset that can be found here: http://globalchange.bnu.edu.cn/research/lai/

I have successfully imported other netCDF files into this build (worldCLIM and the soils data from the same source as this LAI data, for example), but this particular data is giving me issues. I have tried several files from several of the years available of the global LAI product. I get the same results.

I am running the following commands in a global lat/lon location:

g.region n=90 s=-90 e=-180 w=180 res=0.008333333767951 (I have also tried res=00:00:30.)

r.in.gdal does not respect region

r.in.gdal input=NETCDF:“global_30s_2009_153.nc”:lai output=testNETCDF -o

The file imports with some warnings.

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
WARNING: Over-riding projection check
WARNING: Fixing subtle input data rounding error of south boundary
(-9.38773e-06>4.62963e-08)

It appears to be null when plotted, though r.info reports min of 0 and max of 70. r.info hints at an issue with the e-w resolution:

| N: 90N S: 90S Res: 0:00:30
| E: 179:59:59.932408W W: 180W Res: 0:00:00.000002

r.stats seems to indicate that all data is null?

r.stats testNETCDF -cp
100%

  • 900072000 100.00%

d.histogram plots nothing.

Any hints would be greatly appreciated.

I wanted to try it myself, but it’s too big to download it now. Could you post output of:

gdalinfo NETCDF:“global_30s_2009_153.nc”:lai

I am not an expert on netcdf but others might have some idea based on the gdalinfo output.

Regards,

Anna

Thanks!!

-Damian


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi Anna,

Thank you for the reply.

The output from running gdalinfo NETCDF:“global_30s_2009_153.nc”:lai is below. I do not see anything in the metadata that suggests a problem. Perhaps a more experienced eye can find the issue.

Thanks!!

-Damian

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: global_30s_2009_153.nc
Size is 43200, 21600
Coordinate System is `’
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.008333333767951,-0.008333333767951)
Metadata:
lai#long_name=leaf area index
lai#scale_factor=0.1
lai#units=m2/m2
lat#long_name=coordinate latitude
lat#units=degrees_north
lon#long_name=coordinate longitude
lon#units=degrees_east
NC_GLOBAL#citation=Yuan, H., Dai, Y., Xiao, Z., Ji, D., Shangguan, W., 2011. Reprocessing the MODIS Leaf Area Index Products for Land Surface and Climate Modelling. Remote Sensing of Environment, 115(5), 1171-1187. doi:10.1016/j.rse.2011.01.001
NC_GLOBAL#creation_date=2011/09/27
NC_GLOBAL#institution=Land-Atmosphere Interaction Research Group at Beijing Normal University (http://globalchange.bnu.edu.cn)
NC_GLOBAL#title=LAI data sets for land surface and climate modelling
NETCDF_DIM_EXTRA={time}
NETCDF_DIM_time_DEF={1,4}
NETCDF_DIM_time_VALUES=153
time#long_name=day of year 2009
time#units=day
Corner Coordinates:
Upper Left (-180.0000000, 90.0000000)
Lower Left (-180.0000000, -90.0000094)
Upper Right ( 180.0000188, 90.0000000)
Lower Right ( 180.0000188, -90.0000094)
Center ( 0.0000094, -0.0000047)
Band 1 Block=43200x1 Type=Int16, ColorInterp=Undefined
NoData Value=-32767
Offset: 0, Scale:0.100000001490116
Metadata:
long_name=leaf area index
NETCDF_DIM_time=153
NETCDF_VARNAME=lai
scale_factor=0.1
units=m2/m2

···

On 03/20/2014 11:12 PM, Anna Petrášová wrote:

Hi Damian,

On Wed, Mar 19, 2014 at 1:47 PM, Damian Maddalena <damianmaddalena@gmail.com> wrote:

I am having some difficulty with the import of a netCDF dataset into GRASS 7. The dataset I am attempting to import is a 30 second global LAI dataset that can be found here: http://globalchange.bnu.edu.cn/research/lai/

I have successfully imported other netCDF files into this build (worldCLIM and the soils data from the same source as this LAI data, for example), but this particular data is giving me issues. I have tried several files from several of the years available of the global LAI product. I get the same results.

I am running the following commands in a global lat/lon location:

g.region n=90 s=-90 e=-180 w=180 res=0.008333333767951 (I have also tried res=00:00:30.)

r.in.gdal does not respect region

r.in.gdal input=NETCDF:“global_30s_2009_153.nc”:lai output=testNETCDF -o

The file imports with some warnings.

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
WARNING: Over-riding projection check
WARNING: Fixing subtle input data rounding error of south boundary
(-9.38773e-06>4.62963e-08)

It appears to be null when plotted, though r.info reports min of 0 and max of 70. r.info hints at an issue with the e-w resolution:

| N: 90N S: 90S Res: 0:00:30
| E: 179:59:59.932408W W: 180W Res: 0:00:00.000002

r.stats seems to indicate that all data is null?

r.stats testNETCDF -cp
100%

  • 900072000 100.00%

d.histogram plots nothing.

Any hints would be greatly appreciated.

I wanted to try it myself, but it’s too big to download it now. Could you post output of:

gdalinfo NETCDF:“global_30s_2009_153.nc”:lai

I am not an expert on netcdf but others might have some idea based on the gdalinfo output.

Regards,

Anna

Thanks!!

-Damian


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On 21/03/14 15:28, Damian Maddalena wrote:

Hi Anna,

Thank you for the reply.

The output from running gdalinfo NETCDF:"global_30s_2009_153.nc
<http://global_30s_2009_153.nc/>":lai is below. I do not see anything in
the metadata that suggests a problem. Perhaps a more experienced eye can
find the issue.

Thanks!!

-Damian

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: global_30s_2009_153.nc
Size is 43200, 21600
Coordinate System is `'
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.008333333767951,-0.008333333767951)
Metadata:
   lai#long_name=leaf area index
   lai#scale_factor=0.1
   lai#units=m2/m2
   lat#long_name=coordinate latitude
   lat#units=degrees_north
   lon#long_name=coordinate longitude
   lon#units=degrees_east
   NC_GLOBAL#citation=Yuan, H., Dai, Y., Xiao, Z., Ji, D., Shangguan,
W., 2011. Reprocessing the MODIS Leaf Area Index Products for Land
Surface and Climate Modelling. Remote Sensing of Environment, 115(5),
1171-1187. doi:10.1016/j.rse.2011.01.001
   NC_GLOBAL#creation_date=2011/09/27
   NC_GLOBAL#institution=Land-Atmosphere Interaction Research Group at
Beijing Normal University (http://globalchange.bnu.edu.cn)
   NC_GLOBAL#title=LAI data sets for land surface and climate modelling
   NETCDF_DIM_EXTRA={time}
   NETCDF_DIM_time_DEF={1,4}
   NETCDF_DIM_time_VALUES=153
   time#long_name=day of year 2009
   time#units=day
Corner Coordinates:
Upper Left (-180.0000000, 90.0000000)
Lower Left (-180.0000000, -90.0000094)
Upper Right ( 180.0000188, 90.0000000)
Lower Right ( 180.0000188, -90.0000094)
Center ( 0.0000094, -0.0000047)

Try running r.in.gdal with the -l flag to force fit within -180,180.

Moritz

Damian wrote:

...

Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.008333333767951,-0.008333333767951)

...

Corner Coordinates:
Upper Left (-180.0000000, 90.0000000)
Lower Left (-180.0000000, -90.0000094)
Upper Right ( 180.0000188, 90.0000000)
Lower Right ( 180.0000188, -90.0000094)
Center ( 0.0000094, -0.0000047)

Moritz:

Try running r.in.gdal with the -l flag to force fit within -180,180.

technically it's the illegal >90 deg latitude it is unhappy with, GRASS's raster engine can deal with wrapping around 180 longitude (0-360 is supported too). keep an eye on g.region, sometimes minor +/- adjustments are needed to tell it which way to go around the world, the long way or the (very) short way!

In this case it looks like simple cumulative rounding error because 'Pixel Size' got cast to single precision floating point somewhere along the way (3's don't repeat to infinity as they should), and as Moritz explains, 'r.in.gdal -l' will fix it.

In other cases where the convention is grid-centered not cell-centered you get half a cell of overlap at the poles and it's a bit uglier to clean up. (note to self: need to work on a script to handle that automatically; see r.in.srtm)

see also http://grasswiki.osgeo.org/wiki/NetCDF

regards,
Hamish