Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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) 
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

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

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


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) 
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

Your Answer


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.