[GRASS-user] trouble with r.in.gdal to georeference a NetCDF file

I’m trying to import a NetCDF file from the WRF weather forecast model with r.in.gdal, but I can’t get it to georeference. Instead I end up with a x,y coordinate system of rows and columns. The file georeferences fine in a number of other weather graphics programs. I tried to follow the directions at:

http://www.gdal.org/frmt_netcdf.html

but when I run gdalinfo I get the following:

$ gdalinfo geo_em.d03.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: geo_em.d03.nc

Size is 512, 512

Coordinate System is `’

Metadata:

NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0

NC_GLOBAL#CEN_LAT=-8.4095154

NC_GLOBAL#CEN_LON=115.02

NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }

NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }

NC_GLOBAL#DX=3000

NC_GLOBAL#DY=3000

NC_GLOBAL#DYN_OPT=2

NC_GLOBAL#FLAG_MF_XY=1

NC_GLOBAL#grid_id=3

NC_GLOBAL#GRIDTYPE=C

NC_GLOBAL#i_parent_end=99

NC_GLOBAL#i_parent_start=34

NC_GLOBAL#ISICE=24

NC_GLOBAL#ISLAKE=-1

NC_GLOBAL#ISOILWATER=14

NC_GLOBAL#ISURBAN=1

NC_GLOBAL#ISWATER=16

NC_GLOBAL#j_parent_end=84

NC_GLOBAL#j_parent_start=34

NC_GLOBAL#MAP_PROJ=3

NC_GLOBAL#MMINLU=USGS

NC_GLOBAL#MOAD_CEN_LAT=-8.4095078

NC_GLOBAL#NUM_LAND_CAT=24

NC_GLOBAL#parent_grid_ratio=3

NC_GLOBAL#parent_id=2

NC_GLOBAL#POLE_LAT=90

NC_GLOBAL#POLE_LON=0

NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00

NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153

NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1

NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1

NC_GLOBAL#sr_x=1

NC_GLOBAL#sr_y=1

NC_GLOBAL#STAND_LON=115.02

NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4

NC_GLOBAL#TRUELAT1=-8.4095001

NC_GLOBAL#TRUELAT2=0

NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199

NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199

NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198

NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1

NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1

Subdatasets:

SUBDATASET_1_NAME=NETCDF:“geo_em.d03.nc”:Times

SUBDATASET_1_DESC=[1x19] Times (8-bit character)

SUBDATASET_2_NAME=NETCDF:“geo_em.d03.nc”:XLAT_M

SUBDATASET_2_DESC=[1x153x198] XLAT_M (32-bit floating-point)

SUBDATASET_3_NAME=NETCDF:“geo_em.d03.nc”:XLONG_M

SUBDATASET_3_DESC=[1x153x198] XLONG_M (32-bit floating-point)

SUBDATASET_4_NAME=NETCDF:“geo_em.d03.nc”:XLAT_V

.
.
.
.

Corner Coordinates:

Upper Left ( 0.0, 0.0)

Lower Left ( 0.0, 512.0)

Upper Right ( 512.0, 0.0)

Lower Right ( 512.0, 512.0)

Center ( 256.0, 256.0)

The warning -

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

leads me to believe that all the projection info is not being recognized, but I’m not sure why. Is it possible that GDAL wasn’t compiled with libnetcdf? But if that’s the case I would think that gdalinfo wouldn’t work at all.

I’ve imported the data into GRASS using:

r.in.gdal input=“NETCDF:geo_em.d03.nc:HGT_M” output=“d03_HGT_M” location=“bali_d03”

to create a new location.

I also created a location with the Mercator projection of the data and tried importing using:

r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

but as far as I can tell still get an x,y row,column coordinate system.

I also have the lat and lon of each cell. Is there anyway to georeference using that data?

Thanks,
Lee

Hi,

···

On Mon, Nov 11, 2013 at 11:37 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

I’m trying to import a NetCDF file from the WRF weather forecast model with r.in.gdal, but I can’t get it to georeference. Instead I end up with a x,y coordinate system of rows and columns. The file georeferences fine in a number of other weather graphics programs. I tried to follow the directions at:

http://www.gdal.org/frmt_netcdf.html

but when I run gdalinfo I get the following:

$ gdalinfo geo_em.d03.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: geo_em.d03.nc

Size is 512, 512

Coordinate System is `’

Metadata:

NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0

NC_GLOBAL#CEN_LAT=-8.4095154

NC_GLOBAL#CEN_LON=115.02

NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }

NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }

NC_GLOBAL#DX=3000

NC_GLOBAL#DY=3000

NC_GLOBAL#DYN_OPT=2

NC_GLOBAL#FLAG_MF_XY=1

NC_GLOBAL#grid_id=3

NC_GLOBAL#GRIDTYPE=C

NC_GLOBAL#i_parent_end=99

NC_GLOBAL#i_parent_start=34

NC_GLOBAL#ISICE=24

NC_GLOBAL#ISLAKE=-1

NC_GLOBAL#ISOILWATER=14

NC_GLOBAL#ISURBAN=1

NC_GLOBAL#ISWATER=16

NC_GLOBAL#j_parent_end=84

NC_GLOBAL#j_parent_start=34

NC_GLOBAL#MAP_PROJ=3

NC_GLOBAL#MMINLU=USGS

NC_GLOBAL#MOAD_CEN_LAT=-8.4095078

NC_GLOBAL#NUM_LAND_CAT=24

NC_GLOBAL#parent_grid_ratio=3

NC_GLOBAL#parent_id=2

NC_GLOBAL#POLE_LAT=90

NC_GLOBAL#POLE_LON=0

NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00

NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153

NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1

NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1

NC_GLOBAL#sr_x=1

NC_GLOBAL#sr_y=1

NC_GLOBAL#STAND_LON=115.02

NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4

NC_GLOBAL#TRUELAT1=-8.4095001

NC_GLOBAL#TRUELAT2=0

NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199

NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199

NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198

NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1

NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1

Subdatasets:

SUBDATASET_1_NAME=NETCDF:“geo_em.d03.nc”:Times

SUBDATASET_1_DESC=[1x19] Times (8-bit character)

SUBDATASET_2_NAME=NETCDF:“geo_em.d03.nc”:XLAT_M

SUBDATASET_2_DESC=[1x153x198] XLAT_M (32-bit floating-point)

SUBDATASET_3_NAME=NETCDF:“geo_em.d03.nc”:XLONG_M

SUBDATASET_3_DESC=[1x153x198] XLONG_M (32-bit floating-point)

SUBDATASET_4_NAME=NETCDF:“geo_em.d03.nc”:XLAT_V

.
.
.
.

Corner Coordinates:

Upper Left ( 0.0, 0.0)

Lower Left ( 0.0, 512.0)

Upper Right ( 512.0, 0.0)

Lower Right ( 512.0, 512.0)

Center ( 256.0, 256.0)

The warning -

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

leads me to believe that all the projection info is not being recognized, but I’m not sure why. Is it possible that GDAL wasn’t compiled with libnetcdf? But if that’s the case I would think that gdalinfo wouldn’t work at all.

I’ve imported the data into GRASS using:

r.in.gdal input=“NETCDF:geo_em.d03.nc:HGT_M” output=“d03_HGT_M” location=“bali_d03”

to create a new location.

I also created a location with the Mercator projection of the data and tried importing using:

r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

but as far as I can tell still get an x,y row,column coordinate system.

I also have the lat and lon of each cell. Is there anyway to georeference using that data?

try to create a WGS84 latitude-longitude projection (EPSG 4326) and then run r.in.gdal with -o flag. At least that worked for me and I had similar gdalinfo output.

Anna

Thanks,
Lee


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

Anna,

I tried your suggestion, but now I’m unable to import the data. Here’s some output showing the region and the error messages:

GRASS 6.4.3 (bali_d03_ll):~ > g.proj -p

-PROJ_INFO-------------------------------------------------

name : Lat/Lon

proj : ll

datum : wgs84

ellps : wgs84

no_defs : defined

towgs84 : 0.000,0.000,0.000

-PROJ_UNITS------------------------------------------------

unit : degree

units : degrees

meters : 1.0

GRASS 6.4.3 (bali_d03_ll):~ > g.region -p

projection: 3 (Latitude-Longitude)

zone: 0

datum: wgs84

ellipsoid: wgs84

north: 6:19:40.44S

south: 10:27:59.04S

west: 112:19:46.2E

east: 117:43:20.64E

nsres: 0:01:36.12

ewres: 0:01:37.56

rows: 155

cols: 199

cells: 30845

GRASS 6.4.3 (bali_d03_ll):~ > r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

WARNING: Over-riding projection check

WARNING: G_set_window(): Illegal latitude for North

···

On Mon, Nov 11, 2013 at 9:21 PM, Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

On Mon, Nov 11, 2013 at 11:37 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

I’m trying to import a NetCDF file from the WRF weather forecast model with r.in.gdal, but I can’t get it to georeference. Instead I end up with a x,y coordinate system of rows and columns. The file georeferences fine in a number of other weather graphics programs. I tried to follow the directions at:

http://www.gdal.org/frmt_netcdf.html

but when I run gdalinfo I get the following:

$ gdalinfo geo_em.d03.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: geo_em.d03.nc

Size is 512, 512

Coordinate System is `’

Metadata:

NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0

NC_GLOBAL#CEN_LAT=-8.4095154

NC_GLOBAL#CEN_LON=115.02

NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }

NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }

NC_GLOBAL#DX=3000

NC_GLOBAL#DY=3000

NC_GLOBAL#DYN_OPT=2

NC_GLOBAL#FLAG_MF_XY=1

NC_GLOBAL#grid_id=3

NC_GLOBAL#GRIDTYPE=C

NC_GLOBAL#i_parent_end=99

NC_GLOBAL#i_parent_start=34

NC_GLOBAL#ISICE=24

NC_GLOBAL#ISLAKE=-1

NC_GLOBAL#ISOILWATER=14

NC_GLOBAL#ISURBAN=1

NC_GLOBAL#ISWATER=16

NC_GLOBAL#j_parent_end=84

NC_GLOBAL#j_parent_start=34

NC_GLOBAL#MAP_PROJ=3

NC_GLOBAL#MMINLU=USGS

NC_GLOBAL#MOAD_CEN_LAT=-8.4095078

NC_GLOBAL#NUM_LAND_CAT=24

NC_GLOBAL#parent_grid_ratio=3

NC_GLOBAL#parent_id=2

NC_GLOBAL#POLE_LAT=90

NC_GLOBAL#POLE_LON=0

NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00

NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153

NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1

NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1

NC_GLOBAL#sr_x=1

NC_GLOBAL#sr_y=1

NC_GLOBAL#STAND_LON=115.02

NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4

NC_GLOBAL#TRUELAT1=-8.4095001

NC_GLOBAL#TRUELAT2=0

NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199

NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199

NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198

NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1

NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1

Subdatasets:

SUBDATASET_1_NAME=NETCDF:“geo_em.d03.nc”:Times

SUBDATASET_1_DESC=[1x19] Times (8-bit character)

SUBDATASET_2_NAME=NETCDF:“geo_em.d03.nc”:XLAT_M

SUBDATASET_2_DESC=[1x153x198] XLAT_M (32-bit floating-point)

SUBDATASET_3_NAME=NETCDF:“geo_em.d03.nc”:XLONG_M

SUBDATASET_3_DESC=[1x153x198] XLONG_M (32-bit floating-point)

SUBDATASET_4_NAME=NETCDF:“geo_em.d03.nc”:XLAT_V

.
.
.
.

Corner Coordinates:

Upper Left ( 0.0, 0.0)

Lower Left ( 0.0, 512.0)

Upper Right ( 512.0, 0.0)

Lower Right ( 512.0, 512.0)

Center ( 256.0, 256.0)

The warning -

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

leads me to believe that all the projection info is not being recognized, but I’m not sure why. Is it possible that GDAL wasn’t compiled with libnetcdf? But if that’s the case I would think that gdalinfo wouldn’t work at all.

I’ve imported the data into GRASS using:

r.in.gdal input=“NETCDF:geo_em.d03.nc:HGT_M” output=“d03_HGT_M” location=“bali_d03”

to create a new location.

I also created a location with the Mercator projection of the data and tried importing using:

r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

but as far as I can tell still get an x,y row,column coordinate system.

I also have the lat and lon of each cell. Is there anyway to georeference using that data?

try to create a WGS84 latitude-longitude projection (EPSG 4326) and then run r.in.gdal with -o flag. At least that worked for me and I had similar gdalinfo output.

Anna

Thanks,
Lee


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

On Tue, Nov 12, 2013 at 12:55 AM, Lee Eddington
<lee.w.eddington@gmail.com>wrote:

Anna,

I tried your suggestion, but now I'm unable to import the data. Here's
some output showing the region and the error messages:

What does the gdalinfo says about the subdataset?
gdalinfo NETCDF:geo_em.d03.nc:HGT_M

GRASS 6.4.3 (bali_d03_ll):~ > g.proj -p

-PROJ_INFO-------------------------------------------------

name : Lat/Lon

proj : ll

datum : wgs84

ellps : wgs84

no_defs : defined

towgs84 : 0.000,0.000,0.000

-PROJ_UNITS------------------------------------------------

unit : degree

units : degrees

meters : 1.0

GRASS 6.4.3 (bali_d03_ll):~ > g.region -p

projection: 3 (Latitude-Longitude)

zone: 0

datum: wgs84

ellipsoid: wgs84

north: 6:19:40.44S

south: 10:27:59.04S

west: 112:19:46.2E

east: 117:43:20.64E

nsres: 0:01:36.12

ewres: 0:01:37.56

rows: 155

cols: 199

cells: 30845

GRASS 6.4.3 (bali_d03_ll):~ > r.in.gdal -o
input="NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M" output="d03_HGT_M"

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

WARNING: Over-riding projection check

WARNING: G_set_window(): Illegal latitude for North

On Mon, Nov 11, 2013 at 9:21 PM, Anna Petrášová <kratochanna@gmail.com>wrote:

Hi,

On Mon, Nov 11, 2013 at 11:37 PM, Lee Eddington <
lee.w.eddington@gmail.com> wrote:

I'm trying to import a NetCDF file from the WRF weather forecast model
with r.in.gdal, but I can't get it to georeference. Instead I end up with
a x,y coordinate system of rows and columns. The file georeferences fine
in a number of other weather graphics programs. I tried to follow the
directions at:

http://www.gdal.org/frmt_netcdf.html

but when I run gdalinfo I get the following:

$ gdalinfo geo_em.d03.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: geo_em.d03.nc

Size is 512, 512

Coordinate System is `'

Metadata:

  NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0

  NC_GLOBAL#CEN_LAT=-8.4095154

  NC_GLOBAL#CEN_LON=115.02

  NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445,
-10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785,
-6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871,
-10.46785 }

  NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679,
112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679,
117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }

  NC_GLOBAL#DX=3000

  NC_GLOBAL#DY=3000

  NC_GLOBAL#DYN_OPT=2

  NC_GLOBAL#FLAG_MF_XY=1

  NC_GLOBAL#grid_id=3

  NC_GLOBAL#GRIDTYPE=C

  NC_GLOBAL#i_parent_end=99

  NC_GLOBAL#i_parent_start=34

  NC_GLOBAL#ISICE=24

  NC_GLOBAL#ISLAKE=-1

  NC_GLOBAL#ISOILWATER=14

  NC_GLOBAL#ISURBAN=1

  NC_GLOBAL#ISWATER=16

  NC_GLOBAL#j_parent_end=84

  NC_GLOBAL#j_parent_start=34

  NC_GLOBAL#MAP_PROJ=3

  NC_GLOBAL#MMINLU=USGS

  NC_GLOBAL#MOAD_CEN_LAT=-8.4095078

  NC_GLOBAL#NUM_LAND_CAT=24

  NC_GLOBAL#parent_grid_ratio=3

  NC_GLOBAL#parent_id=2

  NC_GLOBAL#POLE_LAT=90

  NC_GLOBAL#POLE_LON=0

  NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00

  NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154

  NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154

  NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153

  NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1

  NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1

  NC_GLOBAL#sr_x=1

  NC_GLOBAL#sr_y=1

  NC_GLOBAL#STAND_LON=115.02

  NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4

  NC_GLOBAL#TRUELAT1=-8.4095001

  NC_GLOBAL#TRUELAT2=0

  NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199

  NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199

  NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198

  NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1

  NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1

Subdatasets:

  SUBDATASET_1_NAME=NETCDF:"geo_em.d03.nc":Times

  SUBDATASET_1_DESC=[1x19] Times (8-bit character)

  SUBDATASET_2_NAME=NETCDF:"geo_em.d03.nc":XLAT_M

  SUBDATASET_2_DESC=[1x153x198] XLAT_M (32-bit floating-point)

  SUBDATASET_3_NAME=NETCDF:"geo_em.d03.nc":XLONG_M

  SUBDATASET_3_DESC=[1x153x198] XLONG_M (32-bit floating-point)

  SUBDATASET_4_NAME=NETCDF:"geo_em.d03.nc":XLAT_V
.
.
.
.

Corner Coordinates:

Upper Left ( 0.0, 0.0)

Lower Left ( 0.0, 512.0)

Upper Right ( 512.0, 0.0)

Lower Right ( 512.0, 512.0)

Center ( 256.0, 256.0)

The warning -

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

leads me to believe that all the projection info is not being
recognized, but I'm not sure why. Is it possible that GDAL wasn't compiled
with libnetcdf? But if that's the case I would think that gdalinfo
wouldn't work at all.

I've imported the data into GRASS using:

r.in.gdal input="NETCDF:geo_em.d03.nc:HGT_M" output="d03_HGT_M"
location="bali_d03"

to create a new location.

I also created a location with the Mercator projection of the data and
tried importing using:

r.in.gdal -o input="NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M"
output="d03_HGT_M"

but as far as I can tell still get an x,y row,column coordinate system.

I also have the lat and lon of each cell. Is there anyway to
georeference using that data?

try to create a WGS84 latitude-longitude projection (EPSG 4326) and then
run r.in.gdal with -o flag. At least that worked for me and I had similar
gdalinfo output.

Anna

Thanks,
Lee

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

OK, here it is:

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: none associated
Size is 198, 153
Coordinate System is `’
Metadata:
HGT_M#description=Topography height
HGT_M#FieldType=104
HGT_M#MemoryOrder=XY
HGT_M#sr_x=1
HGT_M#sr_y=1
HGT_M#stagger=M
HGT_M#units=meters MSL
NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0
NC_GLOBAL#CEN_LAT=-8.4095154
NC_GLOBAL#CEN_LON=115.02
NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }
NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }
NC_GLOBAL#DX=3000
NC_GLOBAL#DY=3000
NC_GLOBAL#DYN_OPT=2
NC_GLOBAL#FLAG_MF_XY=1
NC_GLOBAL#grid_id=3
NC_GLOBAL#GRIDTYPE=C
NC_GLOBAL#i_parent_end=99
NC_GLOBAL#i_parent_start=34
NC_GLOBAL#ISICE=24
NC_GLOBAL#ISLAKE=-1
NC_GLOBAL#ISOILWATER=14
NC_GLOBAL#ISURBAN=1
NC_GLOBAL#ISWATER=16
NC_GLOBAL#j_parent_end=84
NC_GLOBAL#j_parent_start=34
NC_GLOBAL#MAP_PROJ=3
NC_GLOBAL#MMINLU=USGS
NC_GLOBAL#MOAD_CEN_LAT=-8.4095078
NC_GLOBAL#NUM_LAND_CAT=24
NC_GLOBAL#parent_grid_ratio=3
NC_GLOBAL#parent_id=2
NC_GLOBAL#POLE_LAT=90
NC_GLOBAL#POLE_LON=0
NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00
NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154
NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154
NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153
NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1
NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1
NC_GLOBAL#sr_x=1
NC_GLOBAL#sr_y=1
NC_GLOBAL#STAND_LON=115.02
NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4
NC_GLOBAL#TRUELAT1=-8.4095001
NC_GLOBAL#TRUELAT2=0
NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199
NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199
NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198
NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1
NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 153.0)
Upper Right ( 198.0, 0.0)
Lower Right ( 198.0, 153.0)
Center ( 99.0, 76.5)
Band 1 Block=198x1 Type=Float32, ColorInterp=Undefined
NoData Value=9.96920996838686905e+36
Metadata:
description=Topography height
FieldType=104
MemoryOrder=XY
NETCDF_DIMENSION_Time=1
NETCDF_VARNAME=HGT_M
sr_x=1
sr_y=1
stagger=M
units=meters MSL

···

On Tue, Nov 12, 2013 at 5:44 AM, Anna Petrášová <kratochanna@gmail.com> wrote:

On Tue, Nov 12, 2013 at 8:38 AM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

SUBDATASET_26_NAME=NETCDF:“geo_em.d03.nc”:HGT_M
SUBDATASET_26_DESC=[1x153x198] HGT_M (32-bit floating-point)

no, I mean when you run this command (in the directory with the netcdf file):
gdalinfo NETCDF:geo_em.d03.nc:HGT_M

On Tue, Nov 12, 2013 at 5:28 AM, Anna Petrášová <kratochanna@gmail.com> wrote:

On Tue, Nov 12, 2013 at 12:55 AM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

Anna,

I tried your suggestion, but now I’m unable to import the data. Here’s some output showing the region and the error messages:

What does the gdalinfo says about the subdataset?
gdalinfo NETCDF:geo_em.d03.nc:HGT_M

GRASS 6.4.3 (bali_d03_ll):~ > g.proj -p

-PROJ_INFO-------------------------------------------------

name : Lat/Lon

proj : ll

datum : wgs84

ellps : wgs84

no_defs : defined

towgs84 : 0.000,0.000,0.000

-PROJ_UNITS------------------------------------------------

unit : degree

units : degrees

meters : 1.0

GRASS 6.4.3 (bali_d03_ll):~ > g.region -p

projection: 3 (Latitude-Longitude)

zone: 0

datum: wgs84

ellipsoid: wgs84

north: 6:19:40.44S

south: 10:27:59.04S

west: 112:19:46.2E

east: 117:43:20.64E

nsres: 0:01:36.12

ewres: 0:01:37.56

rows: 155

cols: 199

cells: 30845

GRASS 6.4.3 (bali_d03_ll):~ > r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

WARNING: Over-riding projection check

WARNING: G_set_window(): Illegal latitude for North

On Mon, Nov 11, 2013 at 9:21 PM, Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

On Mon, Nov 11, 2013 at 11:37 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

I’m trying to import a NetCDF file from the WRF weather forecast model with r.in.gdal, but I can’t get it to georeference. Instead I end up with a x,y coordinate system of rows and columns. The file georeferences fine in a number of other weather graphics programs. I tried to follow the directions at:

http://www.gdal.org/frmt_netcdf.html

but when I run gdalinfo I get the following:

$ gdalinfo geo_em.d03.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: geo_em.d03.nc

Size is 512, 512

Coordinate System is `’

Metadata:

NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0

NC_GLOBAL#CEN_LAT=-8.4095154

NC_GLOBAL#CEN_LON=115.02

NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }

NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }

NC_GLOBAL#DX=3000

NC_GLOBAL#DY=3000

NC_GLOBAL#DYN_OPT=2

NC_GLOBAL#FLAG_MF_XY=1

NC_GLOBAL#grid_id=3

NC_GLOBAL#GRIDTYPE=C

NC_GLOBAL#i_parent_end=99

NC_GLOBAL#i_parent_start=34

NC_GLOBAL#ISICE=24

NC_GLOBAL#ISLAKE=-1

NC_GLOBAL#ISOILWATER=14

NC_GLOBAL#ISURBAN=1

NC_GLOBAL#ISWATER=16

NC_GLOBAL#j_parent_end=84

NC_GLOBAL#j_parent_start=34

NC_GLOBAL#MAP_PROJ=3

NC_GLOBAL#MMINLU=USGS

NC_GLOBAL#MOAD_CEN_LAT=-8.4095078

NC_GLOBAL#NUM_LAND_CAT=24

NC_GLOBAL#parent_grid_ratio=3

NC_GLOBAL#parent_id=2

NC_GLOBAL#POLE_LAT=90

NC_GLOBAL#POLE_LON=0

NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00

NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153

NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1

NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1

NC_GLOBAL#sr_x=1

NC_GLOBAL#sr_y=1

NC_GLOBAL#STAND_LON=115.02

NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4

NC_GLOBAL#TRUELAT1=-8.4095001

NC_GLOBAL#TRUELAT2=0

NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199

NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199

NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198

NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1

NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1

Subdatasets:

SUBDATASET_1_NAME=NETCDF:“geo_em.d03.nc”:Times

SUBDATASET_1_DESC=[1x19] Times (8-bit character)

SUBDATASET_2_NAME=NETCDF:“geo_em.d03.nc”:XLAT_M

SUBDATASET_2_DESC=[1x153x198] XLAT_M (32-bit floating-point)

SUBDATASET_3_NAME=NETCDF:“geo_em.d03.nc”:XLONG_M

SUBDATASET_3_DESC=[1x153x198] XLONG_M (32-bit floating-point)

SUBDATASET_4_NAME=NETCDF:“geo_em.d03.nc”:XLAT_V

.
.
.
.

Corner Coordinates:

Upper Left ( 0.0, 0.0)

Lower Left ( 0.0, 512.0)

Upper Right ( 512.0, 0.0)

Lower Right ( 512.0, 512.0)

Center ( 256.0, 256.0)

The warning -

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

leads me to believe that all the projection info is not being recognized, but I’m not sure why. Is it possible that GDAL wasn’t compiled with libnetcdf? But if that’s the case I would think that gdalinfo wouldn’t work at all.

I’ve imported the data into GRASS using:

r.in.gdal input=“NETCDF:geo_em.d03.nc:HGT_M” output=“d03_HGT_M” location=“bali_d03”

to create a new location.

I also created a location with the Mercator projection of the data and tried importing using:

r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

but as far as I can tell still get an x,y row,column coordinate system.

I also have the lat and lon of each cell. Is there anyway to georeference using that data?

try to create a WGS84 latitude-longitude projection (EPSG 4326) and then run r.in.gdal with -o flag. At least that worked for me and I had similar gdalinfo output.

Anna

Thanks,
Lee


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

···

I’m looking for a solution to the same problem. The WRF netcdf files have two variables XLONG, XLAT which indicate the real (center?) coordinates of each grid cell. Apparently gdal doesn’t read these variables, so it cannot do any geotransform.

I did find this post with some hints:

http://geoexamples.blogspot.co.il/2013/09/reading-wrf-netcdf-files-with-gdal.html

If anyone has additional tips, I’d appreciate hearing.

Thanks,
Micha

On 11/12/2013 04:43 PM, Lee Eddington wrote:

OK, here it is:

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: none associated
Size is 198, 153
Coordinate System is `’
Metadata:
HGT_M#description=Topography height
HGT_M#FieldType=104
HGT_M#MemoryOrder=XY
HGT_M#sr_x=1
HGT_M#sr_y=1
HGT_M#stagger=M
HGT_M#units=meters MSL
NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0
NC_GLOBAL#CEN_LAT=-8.4095154
NC_GLOBAL#CEN_LON=115.02
NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }
NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }
NC_GLOBAL#DX=3000
NC_GLOBAL#DY=3000
NC_GLOBAL#DYN_OPT=2
NC_GLOBAL#FLAG_MF_XY=1
NC_GLOBAL#grid_id=3
NC_GLOBAL#GRIDTYPE=C
NC_GLOBAL#i_parent_end=99
NC_GLOBAL#i_parent_start=34
NC_GLOBAL#ISICE=24
NC_GLOBAL#ISLAKE=-1
NC_GLOBAL#ISOILWATER=14
NC_GLOBAL#ISURBAN=1
NC_GLOBAL#ISWATER=16
NC_GLOBAL#j_parent_end=84
NC_GLOBAL#j_parent_start=34
NC_GLOBAL#MAP_PROJ=3
NC_GLOBAL#MMINLU=USGS
NC_GLOBAL#MOAD_CEN_LAT=-8.4095078
NC_GLOBAL#NUM_LAND_CAT=24
NC_GLOBAL#parent_grid_ratio=3
NC_GLOBAL#parent_id=2
NC_GLOBAL#POLE_LAT=90
NC_GLOBAL#POLE_LON=0
NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00
NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154
NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154
NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153
NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1
NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1
NC_GLOBAL#sr_x=1
NC_GLOBAL#sr_y=1
NC_GLOBAL#STAND_LON=115.02
NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4
NC_GLOBAL#TRUELAT1=-8.4095001
NC_GLOBAL#TRUELAT2=0
NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199
NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199
NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198
NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1
NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 153.0)
Upper Right ( 198.0, 0.0)
Lower Right ( 198.0, 153.0)
Center ( 99.0, 76.5)
Band 1 Block=198x1 Type=Float32, ColorInterp=Undefined
NoData Value=9.96920996838686905e+36
Metadata:
description=Topography height
FieldType=104
MemoryOrder=XY
NETCDF_DIMENSION_Time=1
NETCDF_VARNAME=HGT_M
sr_x=1
sr_y=1
stagger=M
units=meters MSL

On Tue, Nov 12, 2013 at 5:44 AM, Anna Petrášová <kratochanna@gmail.com> wrote:

On Tue, Nov 12, 2013 at 8:38 AM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

SUBDATASET_26_NAME=NETCDF:“geo_em.d03.nc”:HGT_M
SUBDATASET_26_DESC=[1x153x198] HGT_M (32-bit floating-point)

no, I mean when you run this command (in the directory with the netcdf file):
gdalinfo NETCDF:geo_em.d03.nc:HGT_M

On Tue, Nov 12, 2013 at 5:28 AM, Anna Petrášová <kratochanna@gmail.com> wrote:

On Tue, Nov 12, 2013 at 12:55 AM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

Anna,

I tried your suggestion, but now I’m unable to import the data. Here’s some output showing the region and the error messages:

What does the gdalinfo says about the subdataset?
gdalinfo NETCDF:geo_em.d03.nc:HGT_M

GRASS 6.4.3 (bali_d03_ll):~ > g.proj -p

-PROJ_INFO-------------------------------------------------

name : Lat/Lon

proj : ll

datum : wgs84

ellps : wgs84

no_defs : defined

towgs84 : 0.000,0.000,0.000

-PROJ_UNITS------------------------------------------------

unit : degree

units : degrees

meters : 1.0

GRASS 6.4.3 (bali_d03_ll):~ > g.region -p

projection: 3 (Latitude-Longitude)

zone: 0

datum: wgs84

ellipsoid: wgs84

north: 6:19:40.44S

south: 10:27:59.04S

west: 112:19:46.2E

east: 117:43:20.64E

nsres: 0:01:36.12

ewres: 0:01:37.56

rows: 155

cols: 199

cells: 30845

GRASS 6.4.3 (bali_d03_ll):~ > r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

WARNING: Over-riding projection check

WARNING: G_set_window(): Illegal latitude for North

On Mon, Nov 11, 2013 at 9:21 PM, Anna Petrášová <kratochanna@gmail.com> wrote:

Hi,

On Mon, Nov 11, 2013 at 11:37 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

I’m trying to import a NetCDF file from the WRF weather forecast model with r.in.gdal, but I can’t get it to georeference. Instead I end up with a x,y coordinate system of rows and columns. The file georeferences fine in a number of other weather graphics programs. I tried to follow the directions at:

http://www.gdal.org/frmt_netcdf.html

but when I run gdalinfo I get the following:

$ gdalinfo geo_em.d03.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: geo_em.d03.nc

Size is 512, 512

Coordinate System is `’

Metadata:

NC_GLOBAL#BOTTOM-TOP_GRID_DIMENSION=0

NC_GLOBAL#CEN_LAT=-8.4095154

NC_GLOBAL#CEN_LON=115.02

NC_GLOBAL#corner_lats={ -10.454437, -6.3537445, -6.3537445, -10.454437, -10.454437, -6.3537445, -6.3537445, -10.454437, -10.46785, -6.3401871, -6.3401871, -10.46785, -10.46785, -6.3401871, -6.3401871, -10.46785 }

NC_GLOBAL#corner_lons={ 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044, 112.3332, 112.3332, 117.70679, 117.70679, 112.31956, 112.31956, 117.72044, 117.72044 }

NC_GLOBAL#DX=3000

NC_GLOBAL#DY=3000

NC_GLOBAL#DYN_OPT=2

NC_GLOBAL#FLAG_MF_XY=1

NC_GLOBAL#grid_id=3

NC_GLOBAL#GRIDTYPE=C

NC_GLOBAL#i_parent_end=99

NC_GLOBAL#i_parent_start=34

NC_GLOBAL#ISICE=24

NC_GLOBAL#ISLAKE=-1

NC_GLOBAL#ISOILWATER=14

NC_GLOBAL#ISURBAN=1

NC_GLOBAL#ISWATER=16

NC_GLOBAL#j_parent_end=84

NC_GLOBAL#j_parent_start=34

NC_GLOBAL#MAP_PROJ=3

NC_GLOBAL#MMINLU=USGS

NC_GLOBAL#MOAD_CEN_LAT=-8.4095078

NC_GLOBAL#NUM_LAND_CAT=24

NC_GLOBAL#parent_grid_ratio=3

NC_GLOBAL#parent_id=2

NC_GLOBAL#POLE_LAT=90

NC_GLOBAL#POLE_LON=0

NC_GLOBAL#SIMULATION_START_DATE=0000-00-00_00:00:00

NC_GLOBAL#SOUTH-NORTH_GRID_DIMENSION=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_STAG=154

NC_GLOBAL#SOUTH-NORTH_PATCH_END_UNSTAG=153

NC_GLOBAL#SOUTH-NORTH_PATCH_START_STAG=1

NC_GLOBAL#SOUTH-NORTH_PATCH_START_UNSTAG=1

NC_GLOBAL#sr_x=1

NC_GLOBAL#sr_y=1

NC_GLOBAL#STAND_LON=115.02

NC_GLOBAL#TITLE=OUTPUT FROM GEOGRID V3.4

NC_GLOBAL#TRUELAT1=-8.4095001

NC_GLOBAL#TRUELAT2=0

NC_GLOBAL#WEST-EAST_GRID_DIMENSION=199

NC_GLOBAL#WEST-EAST_PATCH_END_STAG=199

NC_GLOBAL#WEST-EAST_PATCH_END_UNSTAG=198

NC_GLOBAL#WEST-EAST_PATCH_START_STAG=1

NC_GLOBAL#WEST-EAST_PATCH_START_UNSTAG=1

Subdatasets:

SUBDATASET_1_NAME=NETCDF:“geo_em.d03.nc”:Times

SUBDATASET_1_DESC=[1x19] Times (8-bit character)

SUBDATASET_2_NAME=NETCDF:“geo_em.d03.nc”:XLAT_M

SUBDATASET_2_DESC=[1x153x198] XLAT_M (32-bit floating-point)

SUBDATASET_3_NAME=NETCDF:“geo_em.d03.nc”:XLONG_M

SUBDATASET_3_DESC=[1x153x198] XLONG_M (32-bit floating-point)

SUBDATASET_4_NAME=NETCDF:“geo_em.d03.nc”:XLAT_V

.
.
.
.

Corner Coordinates:

Upper Left ( 0.0, 0.0)

Lower Left ( 0.0, 512.0)

Upper Right ( 512.0, 0.0)

Lower Right ( 512.0, 512.0)

Center ( 256.0, 256.0)

The warning -

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

leads me to believe that all the projection info is not being recognized, but I’m not sure why. Is it possible that GDAL wasn’t compiled with libnetcdf? But if that’s the case I would think that gdalinfo wouldn’t work at all.

I’ve imported the data into GRASS using:

r.in.gdal input=“NETCDF:geo_em.d03.nc:HGT_M” output=“d03_HGT_M” location=“bali_d03”

to create a new location.

I also created a location with the Mercator projection of the data and tried importing using:

r.in.gdal -o input=“NETCDF:grassdata/bali/geo_em.d03.nc:HGT_M” output=“d03_HGT_M”

but as far as I can tell still get an x,y row,column coordinate system.

I also have the lat and lon of each cell. Is there anyway to georeference using that data?

try to create a WGS84 latitude-longitude projection (EPSG 4326) and then run r.in.gdal with -o flag. At least that worked for me and I had similar gdalinfo output.

Anna

Thanks,
Lee


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

This mail was received via Mail-SeCure System.

_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[http://lists.osgeo.org/mailman/listinfo/grass-user](http://lists.osgeo.org/mailman/listinfo/grass-user)
This mail was received via Mail-SeCure System.

On Tue, Nov 12, 2013 at 5:37 AM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

I'm trying to import a NetCDF file from the WRF weather forecast model with
r.in.gdal, but I can't get it to georeference. Instead I end up with a x,y
coordinate system of rows and columns. The file georeferences fine in a
number of other weather graphics programs.

I used some other netCDF files recently. However, I always first
convert those files to GeoTIFF using gdalwarp, then I use r.in.gdal.

Markus

Lee wrote:

I'm trying to import a NetCDF file from the WRF weather forecast model
with r.in.gdal, but I can't get it to georeference. Instead I end
up with a x,y coordinate system of rows and columns. The file
georeferences fine in a number of other weather graphics programs.

Hi Lee,

see http://grasswiki.osgeo.org/wiki/NetCDF
http://www.gdal.org/frmt_netcdf.html

can you get the WRF data in GRIB format instead of NetCDF? I'm doing
that and it is working well. (note for GRIB you should have GDAL version
1.9 or newer to avoid a bug)

if not, try using gdal_translate to extract the subband to a geotiff
or other intermediate format before loading into grass.
if you can get r.in.gdal working directly, also consider r.external
to avoid a zillion maps everywhere on the disk.

see also ncdump and I've got a small program here called ncreformat.c that
extracts wrf NetCDF to an ascii file. It might be from an old WRF code
distribution?

Hamish

ps- see also the d.barb addon module for GRASS 6. Also there might be
some discussion in the mailing list archive about smoothing isobar
lines created with r.contour using the v.generalize module: you need
to be careful that the tight inner lines don't pinch closed and that
the fine eye of a storm doesn't get discarded with discarded small
noise loops. if it's not online maybe I'll have some private notes
somewhere I could try to dig out.

Markus,

Could you provide me an example of using gdalwarp converting a NetCDF field to a GeoTIFF?

Thanks,
Lee

···

On Tue, Nov 12, 2013 at 9:48 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Tue, Nov 12, 2013 at 5:37 AM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

I’m trying to import a NetCDF file from the WRF weather forecast model with
r.in.gdal, but I can’t get it to georeference. Instead I end up with a x,y
coordinate system of rows and columns. The file georeferences fine in a
number of other weather graphics programs.

I used some other netCDF files recently. However, I always first
convert those files to GeoTIFF using gdalwarp, then I use r.in.gdal.

Markus

On Wed, Nov 13, 2013 at 11:58 PM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

Markus,

Could you provide me an example of using gdalwarp converting a NetCDF field
to a GeoTIFF?

I often due multiple runs here. Initially

gdalwarp thefile.nc thefile.tif

then I check if the target resolution is as expected (if not, see the
-tr parameter) and so on.
Here is an older blog page which may be of interest:

http://blog.neteler.org/gdal-raster-data-tips-and-tricks/

Markus

Markus,

I tried and got the following:

lees-mbp:bali Lee$ gdalwarp test.nc test.tif

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Input file test.nc has no raster bands.

I’ve attached the file in case you’d be willing to see what you can do with it.

Thanks,
Lee

(attachments)

test.nc (240 KB)

···

On Sun, Nov 17, 2013 at 1:29 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Nov 13, 2013 at 11:58 PM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

Markus,

Could you provide me an example of using gdalwarp converting a NetCDF field
to a GeoTIFF?

I often due multiple runs here. Initially

gdalwarp thefile.nc thefile.tif

then I check if the target resolution is as expected (if not, see the
-tr parameter) and so on.
Here is an older blog page which may be of interest:

http://blog.neteler.org/gdal-raster-data-tips-and-tricks/

Markus

Markus,

I can read a raster from the file into GRASS using:

r.in.gdal input=“NETCDF:test.nc:V10” output=“V10_test3”

and I get the following:

GRASS 6.4.3 (bali_d03):~ > r.info V10_test3
±---------------------------------------------------------------------------+
| Layer: V10_test3 Date: Sat Nov 23 20:56:28 2013 |
| Mapset: PERMANENT Login of Creator: Lee |
| Location: bali_d03 |
| DataBase: /Users/Lee/grassdata |
| Title: ( V10_test3 ) |

Timestamp: none
Type of Map: raster Number of Categories: 255
Data Type: FCELL
Rows: 153
Columns: 198
Total Cells: 30294
Projection: x,y
N: 153 S: 0 Res: 1
E: 198 W: 0 Res: 1
Range of data: min = -12.64637 max = 7.255654
Data Description:
generated by r.in.gdal
Comments:
r.in.gdal input=“NETCDF:test.nc:V10” output=“V10_test3”
±---------------------------------------------------------------------------+

gdalinfo on test.nc gives the following (I’ve stripped out a lot of the metadata, but left the info the describes the Mercator projection):

lees-mbp:bali Lee$ gdalinfo test.nc
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Driver: netCDF/Network Common Data Format
Files: test.nc
Size is 512, 512
Coordinate System is `’
Metadata:
.
.
.
NC_GLOBAL#CEN_LAT=-8.4095154
NC_GLOBAL#CEN_LON=115.02
.

.

.
NC_GLOBAL#MAP_PROJ=3
.
.
.
NC_GLOBAL#STAND_LON=115.02
.
.
NC_GLOBAL#TRUELAT1=-8.4095001
NC_GLOBAL#TRUELAT2=0
.
.
.
Subdatasets:
SUBDATASET_1_NAME=NETCDF:“test.nc”:U10
SUBDATASET_1_DESC=[1x153x198] U10 (32-bit floating-point)
SUBDATASET_2_NAME=NETCDF:“test.nc”:V10
SUBDATASET_2_DESC=[1x153x198] V10 (32-bit floating-point)
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 512.0)
Upper Right ( 512.0, 0.0)
Lower Right ( 512.0, 512.0)
Center ( 256.0, 256.0)

I can display the data in GRASS (see attachment).

I have the latitude and longitude values for every raster point from another file and can read them into collocated rasters. I was able to interactively georectify the raster, but my goal is produce automated scripts and it doesn’t appear that there’s a way to automate the georectify process (please correct me if I’m wrong). I tried using g.setproj to change the projection as I know what it is, but it wouldn’t allow me to because the current projection is x,y.

Thanks for sticking with me on this,

Lee

On Nov 23, 2013, at 7:43 AM, Markus Neteler <neteler@osgeo.org> wrote:

Lee,

I am not much familiar with non-map netCDF files. I do not know how to
deal with this specific file…
Let’s hope that an answer from the community arrives. To me it doesn’t
look like a file containing maps.

Best
Markus

On Sat, Nov 23, 2013 at 9:58 AM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

Markus,

I tried and got the following:

lees-mbp:bali Lee$ gdalwarp test.nc test.tif

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Input file test.nc has no raster bands.

I’ve attached the file in case you’d be willing to see what you can do with
it.

Thanks,
Lee

On Sun, Nov 17, 2013 at 1:29 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Nov 13, 2013 at 11:58 PM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

Markus,

Could you provide me an example of using gdalwarp converting a NetCDF
field
to a GeoTIFF?

I often due multiple runs here. Initially

gdalwarp thefile.nc thefile.tif

then I check if the target resolution is as expected (if not, see the
-tr parameter) and so on.
Here is an older blog page which may be of interest:

http://blog.neteler.org/gdal-raster-data-tips-and-tricks/

Markus

I got a python script from someone on the gdal-dev list that reads in the WRF NetCDF data and outputs a GeoTIFF file in the native Mercator projection and I’m able to read it into GRASS OK. But the coordinate units are meters and I’d prefer to have degrees lat/lon. I reposted asking about this on gdal-dev, but have not heard back yet, and am wondering if anyone here knows a simple way to change to angular units of degrees instead of meters. I’ve been hunting through the GRASS manual, but haven’t found anything that works except reprojecting to a lat/lon location, but then I loose the native mercator aspect ratio of the location. There is also a SetAngularUnits gdal Python call that I found, but I can’t get it to work. Here is the Python code used to transform from WRF NetCDF to GetTIFF:

from osgeo import gdal
from osgeo import osr
import numpy
import numpy.ma as ma
datafile = ‘wrfout_d03_2013-11-20_12:00:00.nc
proj_out = osr.SpatialReference()
proj_out.SetMercator(0.0, 115.02, 0.98931892612652, 0.0, 0.0)
ds_in = gdal.Open(datafile)
subdatasets = ds_in.GetSubDatasets()
variables =
for subdataset in subdatasets:
variables.append(subdataset[1].split(" “)[1])
variables.append(subdataset[1].split(” “)[1])
ds_lon = gdal.Open(‘NETCDF:“wrfout_d03_2013-11-20_12:00:00.nc”:XLONG’)
ds_lat = gdal.Open(‘NETCDF:“wrfout_d03_2013-11-20_12:00:00.nc”:XLAT’)
longs = ds_lon.GetRasterBand(1).ReadAsArray()
lats = ds_lat.GetRasterBand(1).ReadAsArray()
ds_lon = None
ds_lat = None
proj_gcp = osr.SpatialReference()
proj_gcp.ImportFromEPSG(4326)
transf = osr.CoordinateTransformation(proj_gcp, proj_out)
ul = transf.TransformPoint(float(longs[0][0]), float(lats[0][0]))
lr = transf.TransformPoint(float(longs[len(longs)-1][len(longs[0])-1]), float(lats[len(longs)-1][len(longs[0])-1]))
ur = transf.TransformPoint(float(longs[0][len(longs[0])-1]), float(lats[0][len(longs[0])-1]))
ll = transf.TransformPoint(float(longs[len(longs)-1][0]), float(lats[len(longs)-1][0]))
gt0 = ul[0]
gt1 = (ur[0] - gt0) / len(longs[0])
gt2 = (lr[0] - gt0 - gt1len(longs[0])) / len(longs)
gt3 = ul[1]
gt5 = (ll[1] - gt3) / len(longs)
gt4 = (lr[1] - gt3 - gt5
len(longs) ) / len(longs[0])
gt = (gt0,gt1,gt2,gt3,gt4,gt5)
ds_u10 = gdal.Open('NETCDF:”‘+datafile+’":U10’)
num_bands = ds_u10.RasterCount
x_size = ds_u10.RasterXSize
y_size = ds_u10.RasterYSize
data_u10 = numpy.zeros(((num_bands, y_size, x_size)))
data_u10[:,:] = ds_u10.GetRasterBand(1).ReadAsArray()
driver = gdal.GetDriverByName( ‘GTiff’ )
ds_out = driver.Create( ‘u10.tiff’, x_size, y_size, 1, gdal.GDT_Float32 )
ds_out.SetGeoTransform( gt )
ds_out.SetProjection(proj_out.ExportToWkt())
ds_out.GetRasterBand(1).WriteArray( data_u10 )

(attachments)

V10_test.png

···

On Sat, Nov 23, 2013 at 9:14 PM, Lee Eddington <lee.w.eddington@gmail.com> wrote:

Markus,

I can read a raster from the file into GRASS using:

r.in.gdal input=“NETCDF:test.nc:V10” output=“V10_test3”

and I get the following:

GRASS 6.4.3 (bali_d03):~ > r.info V10_test3
±---------------------------------------------------------------------------+
| Layer: V10_test3 Date: Sat Nov 23 20:56:28 2013 |
| Mapset: PERMANENT Login of Creator: Lee |
| Location: bali_d03 |
| DataBase: /Users/Lee/grassdata |
| Title: ( V10_test3 ) |

Timestamp: none
Type of Map: raster Number of Categories: 255
Data Type: FCELL
Rows: 153
Columns: 198
Total Cells: 30294
Projection: x,y
N: 153 S: 0 Res: 1
E: 198 W: 0 Res: 1
Range of data: min = -12.64637 max = 7.255654
Data Description:
generated by r.in.gdal
Comments:
r.in.gdal input=“NETCDF:test.nc:V10” output=“V10_test3”
±---------------------------------------------------------------------------+

gdalinfo on test.nc gives the following (I’ve stripped out a lot of the metadata, but left the info the describes the Mercator projection):

lees-mbp:bali Lee$ gdalinfo test.nc

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Driver: netCDF/Network Common Data Format

Files: test.nc

Size is 512, 512
Coordinate System is `’
Metadata:

.
.
.
NC_GLOBAL#CEN_LAT=-8.4095154
NC_GLOBAL#CEN_LON=115.02
.

.

.
NC_GLOBAL#MAP_PROJ=3
.
.
.
NC_GLOBAL#STAND_LON=115.02
.
.
NC_GLOBAL#TRUELAT1=-8.4095001
NC_GLOBAL#TRUELAT2=0
.
.
.
Subdatasets:
SUBDATASET_1_NAME=NETCDF:“test.nc”:U10
SUBDATASET_1_DESC=[1x153x198] U10 (32-bit floating-point)
SUBDATASET_2_NAME=NETCDF:“test.nc”:V10
SUBDATASET_2_DESC=[1x153x198] V10 (32-bit floating-point)

Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 512.0)
Upper Right ( 512.0, 0.0)
Lower Right ( 512.0, 512.0)
Center ( 256.0, 256.0)

I can display the data in GRASS (see attachment).

I have the latitude and longitude values for every raster point from another file and can read them into collocated rasters. I was able to interactively georectify the raster, but my goal is produce automated scripts and it doesn’t appear that there’s a way to automate the georectify process (please correct me if I’m wrong). I tried using g.setproj to change the projection as I know what it is, but it wouldn’t allow me to because the current projection is x,y.

Thanks for sticking with me on this,

Lee

On Nov 23, 2013, at 7:43 AM, Markus Neteler <neteler@osgeo.org> wrote:

Lee,

I am not much familiar with non-map netCDF files. I do not know how to
deal with this specific file…
Let’s hope that an answer from the community arrives. To me it doesn’t
look like a file containing maps.

Best
Markus

On Sat, Nov 23, 2013 at 9:58 AM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

Markus,

I tried and got the following:

lees-mbp:bali Lee$ gdalwarp test.nc test.tif

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute

Input file test.nc has no raster bands.

I’ve attached the file in case you’d be willing to see what you can do with
it.

Thanks,
Lee

On Sun, Nov 17, 2013 at 1:29 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Nov 13, 2013 at 11:58 PM, Lee Eddington
<lee.w.eddington@gmail.com> wrote:

Markus,

Could you provide me an example of using gdalwarp converting a NetCDF
field
to a GeoTIFF?

I often due multiple runs here. Initially

gdalwarp thefile.nc thefile.tif

then I check if the target resolution is as expected (if not, see the
-tr parameter) and so on.
Here is an older blog page which may be of interest:

http://blog.neteler.org/gdal-raster-data-tips-and-tricks/

Markus