[Gdal-dev] matching metadata for different file formats

Matt Fearon matt at guero.sr.unh.edu
Fri Jun 29 09:23:22 EDT 2007


Hi Sjur K,

Thank you for your reply. You make some very interesting comments. 
However, the grib file appears to have enough metadata (including info 
on the polar stere proj) so that GDAL reprojects the data to geographic 
nicely. See all the gdalinfo from the grib file below. It reprojects to 
geographic using the following command;

gdalwarp -t_srs '+proj=latlong +datum=WGS84' gag4.19980201.01 out_geo.tif

Given the above, why doesn't my newly created netcdf file reproject correctly using the same command. I believe because the netcdf file lacks the appropriate metadata. The file format, the metadata, and the data values are the only differences between the 2 files. The coordinate system, datum, projection, bounding corners etc... are all the same - see gdalinfo on netcdf below for both before and after using gdal_translate to add metadata. The grib file must have important metadata that I am loosing when I go to netcdf. I see this in comparing the gdalinfo between the files below. How can I make the metadata consistent between the 2 files using GDAL commands? 

thank you,
Matt



---- gdalinfo on grib file:

Driver: GRIB/GRIdded Binary (.grb)
Files: gag4.19980201.01
Size is 1160, 880
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["Coordinate System imported from GRIB file",
        DATUM["unknown",
            SPHEROID["Sphere",6371200,0]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Polar_Stereographic"],
    PARAMETER["latitude_of_origin",60],
    PARAMETER["central_meridian",255],
    PARAMETER["scale_factor",90],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0]]
Origin = (-2095445.938568701269105,-3433257.108374913223088)
Pixel Size = (4763.000000000000000,-4763.000000000000000)
Corner Coordinates:
Upper Left  (-2095445.939,-3433257.108) (136d23'50.23"W, 52d37'0.31"N)
Lower Left  (-2095445.939,-7624697.108) (120d22'0.66"W, 22d44'35.90"N)
Upper Right ( 3429634.061,-3433257.108) ( 60d 1'48.89"W, 45d35'28.48"N)
Lower Right ( 3429634.061,-7624697.108) ( 80d46'53.41"W, 19d46'5.69"N)
Center      (  667094.061,-5528977.108) ( 98d 7'13.01"W, 39d48'1.57"N)
Band 1 Block=1160x1 Type=Float64, ColorInterp=Undefined
  Description = 0[-] SFC (Ground or water surface)



---- gdalinfo on netcdf before gdal_translate. Note metadata on the coordinate system, datum, projection, and corners have been lost when compared to grib.

Driver: netCDF/Network Common Data Format
Files: 19980201.nc
Size is 1160, 880
Coordinate System is `'
Metadata:
  precip#_FillValue=-9.990000e+02
  precip#description=These daily data are a sum of the original hourly data; the sum used a GMT to UTC time adjustment (15 deg change longitude = 1 hour change in GMT); the adjustment was calculated per individual gridcell determining the linear distance between centroid longitude and the prime meridian
  precip#date=19980201
  precip#longname=Daily Precipitation
  precip#shortname=precip
  precip#center=US National Weather Service - NCEP (WMC)
  precip#long_name=Total precipitation
  precip#units=kg/m^2
  precip#coordinates=gridlat_240 gridlon_240
  precip#level_indicator=1
  precip#gds_grid_type=5
  precip#parameter_table_version=2
  precip#parameter_number=61
  precip#model=WSR-88D Stage II Precipitation Analysis
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  880.0)
Upper Right ( 1160.0,    0.0)
Lower Right ( 1160.0,  880.0)
Center      (  580.0,  440.0)
Band 1 Block=1160x1 Type=Float32, ColorInterp=Undefined
  NoData Value=-999
  Metadata:
    NETCDF_VARNAME=precip


---- gdalinfo on netcdf after the following gdal_translate command. Note how GEOGCS says "unnamed ellipse" and Spheroid says "unnamed". These are different when compared to the grib. Grib has these as "sphere". How can I change these to "sphere" and keep the radii = 6371200 km ?

gdal_translate -sds -a_srs '+proj=stere +lat_ts=60 +lat_0=90 +lon_0=255 +k_0=90 +x_0=0 +y_0=0 +a=6371200 +b=6371200' -a_ullr -2095445.939 -3433257.108 3429634.061 -7624697.108 19980201.nc 19980201.tif


Files: 19980201.tif
Size is 1160, 880
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["unnamed ellipse",
        DATUM["unknown",
            SPHEROID["unnamed",6371200,0]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Polar_Stereographic"],
    PARAMETER["latitude_of_origin",60],
    PARAMETER["central_meridian",255],
    PARAMETER["scale_factor",90],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (-2095445.939000000013039,-3433257.108000000007451)
Pixel Size = (4763.000000000000000,-4763.000000000000000)
Metadata:
  AREA_OR_POINT=Area
  precip#_FillValue=-9.990000e+02
  precip#description=These daily data are a sum of the original hourly data; the sum used a GMT to UTC time adjustment (15 deg change longitude = 1 hour change in GMT); the adjustment was calculated per individual gridcell determining the linear distance between centroid longitude and the prime meridian
  precip#date=19980201
  precip#longname=Daily Precipitation
  precip#shortname=precip
  precip#center=US National Weather Service - NCEP (WMC)
  precip#long_name=Total precipitation
  precip#units=kg/m^2
  precip#coordinates=gridlat_240 gridlon_240
  precip#level_indicator=1
  precip#gds_grid_type=5
  precip#parameter_table_version=2
  precip#parameter_number=61
  precip#model=WSR-88D Stage II Precipitation Analysis
Corner Coordinates:
Upper Left  (-2095445.939,-3433257.108) (136d23'50.23"W, 52d37'0.31"N)
Lower Left  (-2095445.939,-7624697.108) (120d22'0.66"W, 22d44'35.90"N)
Upper Right ( 3429634.061,-3433257.108) ( 60d 1'48.89"W, 45d35'28.48"N)
Lower Right ( 3429634.061,-7624697.108) ( 80d46'53.41"W, 19d46'5.69"N)
Center      (  667094.061,-5528977.108) ( 98d 7'13.01"W, 39d48'1.57"N)
Band 1 Block=1160x1 Type=Float32, ColorInterp=Gray
  NoData Value=-999
  Metadata:
    NETCDF_VARNAME=precip










Kolberg Sjur A wrote:
> Hello, Matt,
>
> It seems that even your GRIB data hasn't got the Polar Stereographic info.
>
> I have just been working with the GRIB driver, and I know that there is a new version coming which may catch some more projection info. The new version is not included in the latest GDAL (1.4.2) or FWtools (1.3.2) releases, but maybe the sources are in place.
>
> Also, there is a hatch with data projected on a spherical Earth. People sometimes forget that the ellipsiod and datum are not only properties of the projection (from a curved to plane surface), but of the latlong coordinate system itself. Meaning; The geographical position 10degE, 60degN is not at the same place as 10degE, 60degN in spherical-earth degrees. The difference at 60 deg N is around 18km in N-S direction. You need to figure out if this is the case for your data. See http://lists.maptools.org/pipermail/proj/2005-March/001520.html
>
> Regards,
>
> Sjur K :-)
>
>
> Sjur Kolberg
> SINTEF Energiforskning A/S
> Sem Sælands vei 11
> 7465 Trondheim
> tlf. 73 59 72 78
> fax  73 59 72 50 
>
>   
>> -----Original Message-----
>> From: gdal-dev-bounces at lists.maptools.org 
>> [mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Matt Fearon
>> Sent: 28 juni 2007 21:48
>> To: gdal-dev at lists.maptools.org
>> Subject: [Gdal-dev] matching metadata for different file formats
>>
>> Dear GDAL users:
>>
>> I am converting grib files to netcdf as a 1st step using ncar 
>> command language. netcdf is an easier format for me in the 
>> long run for data storage. After this 1st step, I would like 
>> to reprojected my data from polar stereographic to 
>> geographic. The datum of the polar stereographic is unique in 
>> that data are mapped to a sphere with radii 6371200 km. 
>> Here is my trouble:
>>
>> If I skip the 1st step and simply reproject the grib data to 
>> geographic using gdalwarp everything works perfectly. 
>> However, if try to reproject the data after the 1st step, I 
>> am unsuccessful. I am also performing some simple 
>> calculations on the data before going from grib to netcdf, 
>> but I am not changing the coordinate system, projection, 
>> datum etc...Some of the metadata is lost going from grib to 
>> netcdf, and therefore, I apply gdal_translate to the netcdf 
>> file adding the lost metadata back in and converting the 
>> format to geotiff. However, after these steps, I still notice 
>> some slight differences in the metadata between the original 
>> grib and the geotiff. I am struggling to make the metadata 
>> consistent for 3 parameters (GEOGCS, DATUM, and SPHEROID), 
>> please see metadata comparison at the base of this email from 
>> gdalinfo.
>>
>> Any suggestions on how I can make these 3 parameters 
>> consistent between files would be much appreciated. Perhaps 
>> some combination of options using gdal_translate? Although, I 
>> have tried many combinations unsuccessfully, and therefore, 
>> the data do not map correctly. gdalinfo may be excluding some 
>> information as well. However, everything is consistent with 
>> the metadata except these 3 parameters. My original data are 
>> hourly NEXRAD precipitation, mosaicked over the CONUS at 4km, 
>> in grib format, polar stereographic projection assuming the 
>> Earth as a sphere with radii of 6371200 km, downloaded from 
>> NCEP. I am converting hourly to daily and storing in netcdf 
>> for various projects.
>>
>> thanks in advance for the help,
>> Matt
>>
>>
>> Driver: GRIB/GRIdded Binary (.grb)
>> Files: gag4.19980201.01
>> Size is 1160, 880
>> Coordinate System is:
>> PROJCS["unnamed",
>>   GEOGCS["Coordinate System imported from GRIB file",
>>       DATUM["unknown",
>>           SPHEROID["Sphere",6371200,0]],
>>
>> Driver: GTiff/GeoTIFF
>> Files: 19980201.tif
>> Size is 1160, 880
>> Coordinate System is:
>> PROJCS["unnamed",
>>   GEOGCS["unnamed ellipse",
>>       DATUM["unknown",
>>           SPHEROID["unnamed",6371200,0]], 
>> _______________________________________________
>> Gdal-dev mailing list
>> Gdal-dev at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/gdal-dev
>>
>>     
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev
>   




More information about the Gdal-dev mailing list