Blue Marble

Ian Turton

This is a reworked copy of a page that I first wrote while I worked at Pennsylvania State University. It used to live at http://ian01.geog.psu.edu/geoserver_docs/data/bluemarble/bluemarble.html. However that machine died long ago. I have also updated the text and script with a better set of GDAL options.

Preparing the Blue Marble NG for GeoServer

Blue Marble Next Generation (BMNG) is a new satellite data set available at 500m resolution. You can download high resolution images of the data at http://mirrors.arsc.edu/nasa/world_500m/.

blue marble

Processing

The imagery I found comes as 8 png images with a layout as shown below.

BM Tile Layout

The Blue Marble Tile Layout

The first step was to convert the images into geospatial rasters. I choose to use GDAL for this and since I'm lazy I wrote a shell script to work through the 8 files and set up the bounding box correctly for each one:
I'm grateful to Etienne Tourigny for still having a copy of my script.

#! /bin/bash

years="2004"
#months="01 07"
months="01 02 03 04 05 06 07 08 09 10 11 12"
#gdal_string='gdal_translate -of GTiff -co COMPRESS=DEFLATE -a_srs "+proj=latlong +datum=WGS84"'
gdal_string='gdal_translate -of GTiff -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TILED=yes -a_srs EPSG:4326'
ifile_prefix="world.topo.bathy"



#http://ian01.geog.psu.edu/geoserver_docs/data/bluemarble/bluemarble.html
function process_it2()
{
for year in $years ; do
for month in $months ; do

left=-180

for i in A B C D
do 
	right=`expr $left + 90`	
	top=90
	for k in 1 2
	do
		bot=`expr $top - 90`
#		ifile=$ifile_prefix.$year$month.3x21600x21600.${i}${k}.png 
		ifile=$ifile_prefix.$year$month.3x21600x21600.${i}${k}.jpg 
		ofile=$ifile_prefix.$year$month.3x21600x21600.${i}${k}.tif 
		if [ ! -e $ifile ] ; then
			echo $ifile does not exists
			continue
		fi
		if [ -e $ofile ] ; then
			echo $ofile exists
		else
		    $gdal_string -a_ullr $left $top $right $bot $ifile $ofile
		fi
		top=0
	done
	left=`expr $left + 90`
done

ffile=bluemarble$year$month.tif
if [ -e $ffile ] ; then
  echo $ffile exists
else
  gdal_merge.py -o $ffile -of GTiff -co "TILED=YES" \
      -co COMPRESS=JPEG \
      -co PHOTOMETRIC=YCBCR \
      world.topo.bathy.$year$month.3x21600x21600.*.tif
  gdaladdo \
    --config COMPRESS_OVERVIEW JPEG \
    --config PHOTOMETRIC_OVERVIEW YCBCR \
    --config INTERLEAVE_OVERVIEW PIXEL \
    -r average \
    $ffile  \
    2 4 8 16
fi

dir=bluemarble$year$month
if [ -d $dir ] ; then
  echo $dir exists
else
  mkdir -p $dir
  gdal_retile.py -v -r bilinear -levels 8 -ps 2048 2048 \
    -co TILED=YES \
    -co COMPRESS=JPEG \
    -co PHOTOMETRIC=YCBCR \
    -targetDir $dir \
    $ffile
fi
done
done
}

process_it2

This converts each jpg file to a GeoTiff which I can then join together using gdal_merge. It then creates internal overviews to speed up access to the whole image. By applying the JPEG Compression and using the YCBCR colourspace the resulting images are much smaller than you would expect. I also applied an internal tiling so that as you zoom in GeoServer doesn't need to unpack the whole file each time. The final section builds the image pyramid if you find that the whole image file is too slow (but it tends to be fine these days).