Google Earth

Google Earth external is a virtual globe, map, and geographical information program. It maps the Earth by the superimposition of images obtained from satellite imagery, aerial photography, and GIS 3D globe. It is available under two different licenses: Google Earth, a free version with limited function and Google Earth Pro ($399 per year), which is intended for commercial use.

Although Google Earth cannot access NASA HDF/HDF-EOS data directly, there are other ways to access and visualize NASA HDF/HDF-EOS data through data conversion such as Keyhole Markup Languageexternal (KML), Web Map Service external (WMS), and GeoTIFFexternal. This example will cover all three data access methods.

Installation

Google Earth is supported on many platforms including mobile platforms. Please click one of the following links based on your platform to download the application.

If you want to import GeoTIFF file, you need to download the Google Earth Pro. Google Earth Pro is supported only on desktop environment.

Once you download the setup programs, installation is quite straightforward with minimal user's involvement.

KML (KMZ)

Google Earth is able to show all kinds of images such as (JPEG, PNG, GIF) overlaid on the surface of the earth but Google Earth supports managing three-dimensional Geo-spatial data through Keyhole Markup Language (KML).

There are several ways to create KML from NASA HDF/HDF-EOS data. We'll go over Panoply, IDV, NCL, IDL, and MATLAB.

Panoply

In our Panoply example page, you can learn how to access and visualize HDF data via OPeNDAP service. Once you succeed in visualizing data, you can export it as KMZ as shown in Figure 1. by selecting File > Export KMZ menu in Panoply. A KMZ file is a zipped KML file.

Panoply will show a new dialog box that asks two options, and you can simply press OK button in the dialog box. Now you are ready to open the saved KMZ file with Google Earth. Use File > Open menu in Google Earth to load the saved KMZ file. You can download our sample KMZ file here. Google Earth will visualize the KMZ file as shown in Figure 2.

IDV

In our IDV example page, you can also learn how to access and visualize HDF data via OPeNDAP service. Once you succeed in visualizing data, you can export it as KMZ as shown in Figure 3. by selecting View > Capture > Image menu in the Map View window of IDV.

IDV will show a Save dialog box that asks Files of Type at the bottom. Select Google Earth File (*.kml, *.kmz) and provide your own file name. Press Save button in the dialog box at the end. Now you are ready to open the saved KMZ file with Google Earth. Use File > Open menu in Google Earth to load the saved KMZ file. You can download our sample KMZ file here. Google Earth will visualize the KMZ file as shown in the following figure.

NCL

NCL can access HDF data both locally and remotely. We also provide many product-specific examples of NCL. You can reuse our NCL examples and create KML files out of them easily by following the steps below.

NCL, by default, doesn't support KML. Thus, you need to downloadexternal and installexternal kmlncl package first. The kmlncl relies on the convert program in ImageMagick external package. Therefore, installing ImageMagick is a prerequisite.

The kmlncl uses the image overlay tag in KML, which means that kmlncl will convert NCL plot in PostScript into a PNG file. Since the kmlncl needs to geo-reference the converted PNG file, you need to prepare the PostScript plot in NCL carefully. This requires a few modification from our original sample comprehensive example as highlighted in Figure 5.

; Load kmlncl package.
load "$NCARG_ROOT/lib/ncarg/nclscripts/kml/kml.ncl"

; Turn the followings off for correct KML mapping.
;res@gsnMaximize=True
;res@gsnPaperOrientation = "portrait"
;res@lbOrientation="vertical"
;res@tiMainString = file_name

; This is added for KML.
res@mpLandFillColor="transparent"

; Plot type must be PS for kmlncl.
wks_type = "ps"

; Bigger size means a better resolution on Google Earth.
wks_type@wkPaperSize="A0"
Figure 5. Required modifications for creating KML using NCL

The complete NCL code for converting HDF-EOS5 to KMZ is here. You can visualize the converted KMZ file with Google Earth as shown in Figure 6.

IDL

Like NCL, IDL can also access HDF data both locally and remotely. We also provide many product-specific examples of IDL. You can reuse our IDL examples and create KML files out of them easily by following the steps below.

The most recent IDL, version 8.2.3, by default, supports writing a KML from an image. The IDL's KML will contain an overlay tag with a PNG file. Thus, we need to create a source image file in JPEG that can be geo-referenced easily. This requires a slight modification from our original sample comprehensive example as highlighted in Figure 7.

; Use Z-buffer to eliminate the X-Windows device dependency.
SET_PLOT, 'Z'

; Set the window size big to get a better resolution.
; The aspect ratio should match 2:1 to geo-reference the global map.
DEVICE, SET_RESOLUTION=[1440, 720], SET_PIXEL_DEPTH=24, DECOMPOSED=0

; Use the entire window by setting margins 0 without any border.
; Turn off grid / continents also because Google Earth can provide them.
; MAP_SET, /GRID, /CONTINENTS, ...
MAP_SET, XMARGIN=0, YMARGIN=0, /NOBORDER

; Write a JPG image first.
im = TVRD(0,0,1440,720,TRUE=1)
jpg = file_name + '.jpg'
WRITE_JPEG, jpg, im, QUALITY=100, TRUE=1

; Create an image graphic that can create KML.
arctic = IMAGE(jpg, $
GRID_UNITS=2, $
LIMIT=[90, -180, -90, 180], IMAGE_LOCATION=[-180,-90], $
IMAGE_DIMENSIONS=[360,180], MAP_PROJECTION='Geographic', $
GRID_LATITUDE=0, GRID_LONGITUDE=0, $
/CURRENT, BACKGROUND_color=[0,0,0], NAME=file_name)

; Save the IMAGE graphic as a KML file, which will produce an overlay
; PNG file.
kml = file_name + '.kml'
arctic.SAVE, kml
Figure 7. Required modifications for creating KML using IDL

The complete IDL code for converting HDF-EOS5 to KMZ is here. You can visualize the converted KMZ file with Google Earth as shown in Figure 8.

MATLAB

Like NCL and IDL, MATLAB can also access HDF data both locally and remotely. We also provide many product-specific examples of MATLAB. You can reuse our MATLAB examples and create KML files out of them easily by following the steps below.

MATLAB provides a built-in function called kmlwrite for creating a KML file using points and lines only, so the built-in function cannot overlay a contoured plot JPEG image that our examples generate. Therefore, we will use the KML Toolboxexternal available from MATLAB CENTRAL File Exchange for our example. Please download the toolbox and decompress it first to follow our example.

The following code in Figure 9. highlights the required modification to use the KML Toolbox overlay function on our sample comprehensive example. The code for accessing and plotting data is same. The key difference is to create a transparent image that can be overlaid properly on Google Earth by adjusting the figure size and by removing the title, the colorbar, and the extra border space around the figure.

% We assume that the KML Toolbox is decompressed under /tmp directory.
addpath('/tmp/kmltoolbox v2.71/');

% Create an overlay image in PNG.
f = figure('Name', FILE_NAME, ...
'Renderer', 'zbuffer', ...
'Position', [0,0,1440,720], ...
'Visible', 'on', ...
'PaperPositionMode', 'auto', ...
'Colormap', jet(2048));
set(ax, ...
'PlotBoxAspectRatio', [2 1 1], ...
'Box', 'off', ...
'Position', [0 0 1 1], ...
'Units', 'normalized', ...
'DataAspectRatioMode', 'auto');
tightmap;
saveas(f, [FILE_NAME, '.m.png']);

% Make the white background transparent.
transparent = 255;
A = imread([FILE_NAME, '.m.png']);
alpha = ones(size(A,1), size(A,2));
index = A(:,:,1) == transparent ...
& A(:,:,2) == transparent ...
& A(:,:,3) == transparent;
alpha(index) = 0;
imwrite(A, [FILE_NAME, '.m.png'], 'Alpha', alpha);

% Save it as KMZ.
k = kml([FILE_NAME, '.m.kml']);
k.overlay(180.0, -180.0, -90.0, 90.0, 'file',[FILE_NAME '.m.png']);
k.run;
Figure 9. Required modifications for creating KML using MATLAB

The complete MATLAB code for converting HDF-EOS5 to KMZ is here. You can visualize the converted KMZ file with Google Earth as shown in Figure 10.

WMS

A Web Map Service (WMS) is a standard protocol for serving geo-referenced map images over the Internet. Some NASA data centers already provide WMS for HDF/HDF-EOS products. For example, GES DISC provides WMSexternal for AIRS, TRMM, and OMI data products. LANCE Global Imagery Browse Service (GIBS) provides WMSexternal for MODIS, VIIRS, MLS, OMI, and AIRS products. LANCE also provides WMSexternal for MODIS fire product.

To visualize images provided by WMS, select Add > Image Overlay menu item or click the icon. Google Earth will pop up a new dialog box like Figure 11 below. Click the Refresh tab in the middle and you will see the WMS Parameters button on the right bottom corner as shown in Figure 11.

Press the WMS Parameters button. Google Earth will show a new window for entering WMS parameters as shown in Figure 12.

Press the Add button from the above window and enter the following sample URL that we copied from the link text WMS GetCapabilitiesexternal in the GES DISC WMS service webpageexternal.

http://disc1.sci.gsfc.nasa.gov/daac-bin/wms_trmm?service=wms&version=1.1.1&request=getcapabilities

Then, press OK. Google Earth will contact the WMS server and list the layers available from the server as shown in Figure 13.

Click one or more layers from the Transparent Layers list box on the left and press the Add-> button. In our example, we picked the TRMM_3A12_MONTHLY_surfaceRain layer as shown in Figure 14. The selected layer(s) will appear on the right list box.

Finally, press OK button for the WMS Parameters Window first and for the Add Layer Window next. The main Google Earth window will visualize the TRMM data as shown in Figure 15.

Unlike KML, Google Earth fetches only the WMS image that covers the region of the current view over the Internet. Therefore, if you move around or zoom in/out the globe with your mouse, Google Earth will make a new request to the map server and fetch a new image, which may delay in visualizing data.

If your NASA HDF data products of interest are not available via WMS by NASA data centers, you may want to set up your own WMS using THREDDSexternal or ncWMSexternal by converting HDF/HDF-EOS into NetCDF via OPeNDAP HDF4 handler & HDF5 handler or H4CF conversion toolkit first and editing the converted file with NcML.

GeoTIFF

Google Earth Pro can import GeoTIFF directly. Please read this tutorial for importing and visualizing GeoTIFF data on Google Earth Pro.

There are several ways to create GeoTIFF from NASA HDF/HDF-EOS data. You can use HEG, ArcGIS, and GDAL. However, not all NASA HDF/HDF-EOS data products can be converted to GeoTIFF and each software has its own limitation.


Last modified: 11/11/2020
About Us | Contact Info | Archive Info | Disclaimer
Sponsored by Subcontract number 4400528183 under Raytheon Contract number NNG15HZ39C, funded by NASA / Maintained by The HDF Group