
# 0. Source data file received from ETC-LUSI

$ ll LandScan_EEA_1km.mdb
-rw-r--r-- 1 peifer mtr 393162752 Nov 23 16:42 LandScan_EEA_1km.mdb

# Originally uploaded to CIRCA, as integrated data (activity 1/3) deliverable
http://eea.eionet.europa.eu/Members/irc/eionet-circle/etcte/library?l=/2010_subvention/dataintegration


# 1. Export of the table LandScan as csv file

$ mdb-export -Q -d "\t" LandScan_EEA_1km.mdb LandScan > LandScan.csv

# The csv file has 4 tab delimited columns and 5942424 rows (incl header)

$ f LandScan.csv

Column headers

     1  CELLCODE
     2  POPCOUNT
     3  AREA_POP
     4  POP_AREA

5942424 records with 4 fields

$ head LandScan.csv | expand -t20,30,40
CELLCODE            POPCOUNT  AREA_POP  POP_AREA
1kmE1547N1032       0         99999     99999
1kmE1547N1033       0         99999     99999
1kmE1547N1034       0         99999     99999
1kmE1548N1031       0         99999     99999
1kmE1548N1032       0         99999     99999
1kmE1548N1033       0         99999     99999
1kmE1548N1034       2         99999     99999
1kmE1548N1035       3         99999     99999
1kmE1548N1036       3         99999     99999


# 2. Convert POPCOUNT values into ASCII Grid format
$ awk -f ascii_grid.awk LandScan.csv LandScan.asc

# Awk script used for data conversion

$ cat ascii_grid.awk
# Convert LAEA CELLCODEs into AAIGrid format
# Hermann, created Wed Nov 24 12:06:05 2010
#
# Rule(s)

# Tab delimited input data
BEGIN { FS = "\t" }

# Remember data values, exclude NODATA areas
$2 != "" {
  a[substr($1, 10), substr($1, 5, 4)] = $2
}

# Print in AAIGrid format, NODATA cells = -99
END {
  for (row = 5499; row >= 900; row--) {
    for (col = 1500; col <= 7499; col++) {
      printf "%s%s", ( ((row,col) in a) ?
        a[row, col] : -99), (col == 7499 ? "\n" : " ")
    }
  }
}

# Add these header lines to LandScan.asc

ncols         6000
nrows         4600
xllcorner     1500000
yllcorner     900000
cellsize      1000
NODATA_value  -99


# 3. Convert to .vrt format, assign CRS EPSG:3035

$ gdal_translate -of vrt -a_srs epsg:3035 LandScan.asc LandScan.vrt
Input file size is 6000, 4600


# 4. Convert to compressed GeoTIFF format

$ gdal_translate -co compress=lzw -co tiled=yes LandScan.vrt LandScan.tif
Input file size is 6000, 4600
0...10...20...30...40...50...60...70...80...90...100 - done.

# Some info on the created GeoTIFF

$ gdalinfo -stats LandScan.tif
Driver: GTiff/GeoTIFF
Files: LandScan.tif
Size is 6000, 4600
Coordinate System is:
PROJCS["ETRS89 / ETRS-LAEA",
    GEOGCS["ETRS89",
        DATUM["European_Terrestrial_Reference_System_1989",
            SPHEROID["GRS 1980",6378137,298.2572221010002,
                AUTHORITY["EPSG","7019"]],
            AUTHORITY["EPSG","6258"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4258"]],
    PROJECTION["Lambert_Azimuthal_Equal_Area"],
    PARAMETER["latitude_of_center",52],
    PARAMETER["longitude_of_center",10],
    PARAMETER["false_easting",4321000],
    PARAMETER["false_northing",3210000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","3035"]]
Origin = (1500000.000000000000000,5500000.000000000000000)
Pixel Size = (1000.000000000000000,-1000.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 1500000.000, 5500000.000) ( 49d54'24.14"W, 60d44'53.50"N)
Lower Left  ( 1500000.000,  900000.000) ( 18d14'13.06"W, 26d24'56.90"N)
Upper Right ( 7500000.000, 5500000.000) ( 73d59'59.40"E, 58d14'27.28"N)
Lower Right ( 7500000.000,  900000.000) ( 41d35'37.81"E, 25d11'18.59"N)
Center      ( 4500000.000, 3200000.000) ( 12d36' 0.52"E, 51d52'53.19"N)
Band 1 Block=256x256 Type=Int32, ColorInterp=Gray
  Minimum=0.000, Maximum=93827.000, Mean=101.635, StdDev=681.574
  NoData Value=-99
  Metadata:
    STATISTICS_MINIMUM=0
    STATISTICS_MAXIMUM=93827
    STATISTICS_MEAN=101.63461770495
    STATISTICS_STDDEV=681.57374946888

*** End ***

Hermann Peifer, EEA, 26/Nov/2010 15:11
