wiki:Temperature download and load

Version 3 (modified by celine, 15 years ago) (diff)

--

back to first page ..
back to CookBook Eda
back to Temperature

EXTRACT the data from CRU with TETYN

Download Tetyn at : http://sourceforge.net/projects/tetyn/
Download the data at http://www.cru.uea.ac.uk/cru/data/hrg/cru_ts_2.10/data_all/
cru_ts_2_10.1901-2002.pre.Z (137MB)
cru_ts_2_10.1901-2002.tmn.Z (118MB)
cru_ts_2_10.1901-2002.tmp.Z (118MB)
cru_ts_2_10.1901-2002.tmx.Z (119MB)

Unzippe the data

Open TETYN > Climate dataset > CRU TS 2.10

In-out > Data folder choose the folder where you have extracted the data and the output folder
Query : select the year, the month, parameters : temperature, temperature minimum, temperature maximum, precipitation
Space : select the country

Create the table in Postgre to import to

  • Import the temperature tmp (temperature moyenne)
    DROP TABLE IF EXISTS temperature.tmp;
    
    Create table tmp
    COPY temperature.tmp FROM 'D:/Celine Jouanin/Temperature/tmp.txt' USING DELIMITERS ';' CSV HEADER;
    
  • Import the temperature tmx (temperature maximum)
    DROP TABLE IF EXISTS temperature.tmx;
    
    Create table tmx
    COPY temperature.tmx FROM 'D:/Celine Jouanin/Temperature/tmx.txt' USING DELIMITERS ';' CSV HEADER;
    
  • Import the temperature tmn (temperature minimum)
    DROP TABLE IF EXISTS temperature.tmn;
    
    Create table tmn
    COPY temperature.tmn FROM 'D:/Celine Jouanin/Temperature/tmn.txt' USING DELIMITERS ';' CSV HEADER;
    

Create and Populate the geometry field

The geometry field is populated using the Longitude and Latitude fields
Problem : I haven't yet found the spatial reference (maybe the srid is : 4326 or 4269 or 3785 or 3395...)

  • Geometry for the temperature tmp
    select AddGeometryColumn('temperature','tmp','the_geom',4269,'POINT',2);
    UPDATE temperature.tmp
            SET the_geom = ST_SetSRID(ST_Point( longitude, latitude),4269);
    
  • Geometry for the temperature tmx
    select AddGeometryColumn('temperature','tmx','the_geom',4269,'POINT',2);
    UPDATE temperature.tmx
            SET the_geom = ST_SetSRID(ST_Point( longitude, latitude),4269);
    
  • Geometry for the temperature tmn
    select AddGeometryColumn('temperature','tmn','the_geom',4269,'POINT',2);
    UPDATE temperature.tmn
            SET the_geom = ST_SetSRID(ST_Point( longitude, latitude),4269);