Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to load NCEP NOAA weather data from GRIB2 format into PostGIS and then visualize it using QGIS etc.

I'm using wgrib2 library to convert the GRIB2 data to csv first.

wgrib2 -match "(:TMP:surface:anl:|:TMP:2 m above ground:anl:)" gfs.t00z.sfluxgrbf00.grib2 -csv fcast.csv

Then I copy CSV to PostGIS and create a geometry column:

COPY tmp (begindate, enddate, name, name2, value, lat, lon) 
FROM
'/Users/nl/Work/ncep/fcast.csv'
WITH DELIMITER ',' CSV;
SELECT addGeometryColumn ('public', 'tmp', 'the_geom', 4326, 'POINT', 2);
UPDATE tmp SET lon = lon-360 WHERE lon > 180;
UPDATE tmp SET the_geom=ST_SetSRID(ST_MakePoint(lat,lon), 4326);

When looking at the data in QGIS, I see a strange result:

enter image description here

When I expect to see the regular grid - something like this:

enter image description here

I see, that someone has done it already here: How to process GRIB2 Data for Visualization?

Can anyone give some details?

share|improve this question
add comment

2 Answers 2

I notice you are specifying ST_MakePoint(Lat, Lon). Shouldn't that be ST_MakePoint(Lon, Lat) since the usual format is ST_MakePoint(x,y)?

share|improve this answer
    
Tried it both ways. Still don't get the grid. –  Nick Apr 10 '12 at 6:36
    
You definitely want "(lon, lat)" assuming thenames didn't get transposed when creating the csv. The next thing I would check is that any text fields in the CSV do NOT contain any commas (except for the delimiters of course). This is a common 'gotcha'! If there are any you could change the 'extra' commas to something harmless. After that, I would double check that the columns labelled 'lat' and 'lon' are really what they claim to be. Also, if your lat and lon fields are formatted as degrees, minutes, seconds then try reformatting to decimal degrees. –  MappaGnosis Apr 10 '12 at 11:43
add comment

It seems your import is not correct:

COPY tmp (begindate, enddate, name, name2, value, lat, lon)

As you can see here the csv's output is

"time0","time1","field","level",longitude,latitude,grid-value

The value is at the end of the csv-file, so you should change your import statement.

My modified and testet version would be:

create table tmp (id SERIAL PRIMARY KEY, t0 varchar, t1 varchar, f varchar, lev varchar, lon double precision, lat double precision, val double precision);
COPY tmp (t0, t1, f, lev, lon, lat, val) 
FROM
'/path/to/csvfile.csv'
WITH DELIMITER ',' CSV;
SELECT addGeometryColumn ('public', 'tmp', 'the_geom', 4326, 'POINT', 2);
UPDATE tmp SET the_geom=ST_SetSRID(ST_MakePoint(lon,lat), 4326);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.