[GIS] How to create proper PostGIS points out of GRIB2 file

gdalpostgis

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?

Best Answer

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