Sunday, 11 February 2018

How to read netCDF raster data in GRASS or QGIS?


How to read netCDF raster data in GRASS or QGIS?


I have a file with this characteristics:


Command: gdalinfo C:\Users\XXXX\gisdata\Test\mb.grd


Output:


Driver: netCDF/Network Common Data Format
Files: C:\Users\XXXX\gisdata\Test\mb.grd

Size is 412, 433
Coordinate System is `'
Origin = (-87.389553008819831,11.262298195006528)
Pixel Size = (0.000778017639680,-0.000768428196547)
Metadata:
NC_GLOBAL#Conventions=COARDS, CF-1.5
NC_GLOBAL#description=
Projection: Geographic
Grid created by mbgrid
MB-system Version 5.5.2318

Run by on at
NC_GLOBAL#GMT_version=5.2.1 (r15220) [64-bit] [MP]
NC_GLOBAL#history=mbgrid
NC_GLOBAL#title=Topography Grid
x#actual_range={-87.38916399999999,-87.06939875009137}
x#long_name=Longitude
y#actual_range={10.929953,11.26191398090825}
y#long_name=Latitude
z#actual_range={-4783.08984375,-760.27880859375}
z#long_name=Topography (m)

z#_FillValue=1.#QNAN
Corner Coordinates:
Upper Left ( -87.3895530, 11.2622982)
Lower Left ( -87.3895530, 10.9295688)
Upper Right ( -87.0690097, 11.2622982)
Lower Right ( -87.0690097, 10.9295688)
Center ( -87.2292814, 11.0959335)
Band 1 Block=412x1 Type=Float32, ColorInterp=Undefined
NoData Value=nan
Metadata:

actual_range={-4783.08984375,-760.27880859375}
long_name=Topography (m)
NETCDF_VARNAME=z
_FillValue=1.#QNAN

My first attemp to read it was with the standard gdal procedure


command: r.in.gdal -o -k input="C:\Users\XXXX\gisdata\Test\mb.grd" outpu\ | | t="mb" memory=300 offset=0 num_digits=0


but it looks to have just zeros, not the z#actual_range={-4783.08984375,-760.27880859375}


Here the r.info map=mb


|----------------------------------------------------------------------------|

| |
| Type of Map: raster Number of Categories: 0 |
| Data Type: FCELL |
| Rows: 433 |
| Columns: 412 |
| Total Cells: 178396 |
| Projection: Latitude-Longitude |
| N: 11:15:44.273502N S: 10:55:46.447629N Res: 0:00:02.76634 |
| E: 87:04:08.435069W W: 87:23:22.390832W Res: 0:00:02.80086 |
| Range of data: min = 0 max = 0 |

| |
| Data Description: |
| generated by r.in.gdal

There is a link with the file https://ufile.io/3i2ix and this belongs to this question How to restore a scarp surface grid to calculate material loss


System info:


GRASS version: 7.2.0                                                            
GRASS SVN revision: r70156
Build date: 2016-12-29
Build platform: x86_64-w64-mingw32

GDAL: 2.1.2
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.14.1
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

Answer



@Kazuhito pointed me to the solution, it was solved with the update of QGIS from 2.18.7 to 2.18.14, which comes with GDAL 2.2.2 and GRASS 7.2.2.


It worked smoothly in both QGIS and GRASS.



r.import input=C:\Users\XXXX\gisdata\Test\mb.grd output=mb -o --overwrite
r.info map=mb
+----------------------------------------------------------------------------+
| |
| Type of Map: raster Number of Categories: 0 |
| Data Type: FCELL |
| Rows: 433 |
| Columns: 412 |
| Total Cells: 178396 |
| Projection: Latitude-Longitude |

| N: 11:15:44.273502N S: 10:55:46.447629N Res: 0:00:02.76634 |
| E: 87:04:08.435069W W: 87:23:22.390832W Res: 0:00:02.80086 |
| Range of data: min = -4783.09 max = -760.2788 |
| |
| Data Description: |
| generated by r.in.gdal |

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...