Hosted by "1PLs Agency"

Marine Data Literacy 2.0

Providing instruction for managing, converting, analyzing and displaying oceanographic station data, marine meteorological data, GIS-compatible marine and coastal data or model simulations, and mapped remote sensing imagery

 

 

 

 

Home > 5. Gridded Data > 5.8 Google Legends

5.8 Creating Legends for Grids in Google Earth

1.  Download the zipped grid above to the folder PRODUCTS > SAGA > GEOIMAGES > KML.  Then unzip it in place.
2.  Use FILE > GRID > LOAD GRID to open the SST grid.  It should look similar to this.
3.  Change value range to whole numbers, i.e. 25-33
4.  Use the GRADUATED COLOR > COLOR control to set the color bin COUNT to 8.  Also set the color palette to the PRESETS collection named RAINBOW.  Then hit OK 2 times.

You can try 9 bins or 7 bins to see why 8 was chosen.

5.  After these choices, you grid should look like this, with its legend.

HINT:  The LEGEND tab is in the bottom right corner.

6.  Now change the display name of the grid to JANUARY SST.  Then enter the UNITS that are appropriate for these data, DEG C.  Then click SETTINGS > APPLY.

NOTE:  If you need to use superscripts, as for m3, then use ^3.

7.  Here's what the final legend should look like.
8.  Before you go on to save anything, select MAP > TREE to see the actual name of the map.  In Saga a map is named with the first file plotted on it, as you see here.  If you don't like this long map name, you can change it here (see the settings on the right side).

You will see this map name again (this version or a shorter one) in Panel 22 below, where it shows up in Google Earth.

9.  Now select MAP > THUMBNAILS to see your map again.  Right-click on it and select SAVE AS IMAGE.
10.  Navigate to the folder PRODUCTS > SAGA > GEOIMAGES >KML and save the image with the name sst_jan_liberia_modisa_ocweb_11u_daytime_0.05deg_hdf_saga_descaled and select PNG as the format.
11.  When you click SAVE, then these options appear:
  • For map WIDTH and HEIGHT, you can take the defaults.  Experiment with different choices to see how it affects the final figure in Google
  • For FRAME WIDTH the author recommends 0.  Try other values.
  • Check SAVE GEOREFERENCE; this insures you'll have a PGW world file with the main PNG file.
  • Check SAVE KML FILE
  • Check LEGEND > SAVE
  • For ZOOM you can use 1 in this example.  Later, in Panel 21 you'll see the size of the legend itself.  If it's too small, you can choose a larger value right here.

Click OK.

12.  Now you'll have these 8 files:
  • The original grid:  SDAT, SGRD, MGRD
  • The original ZIP
  • The new KML file
  • The new georeferenced image:  PNG, PGW
  • The legend:  also PNG
13.  If you double-click the KML file, it will open in Google Earth (GE) like this.
14.  Numerous experiments have not shown how to eliminate the white side margins on the PNG images from this Saga module.  If you don't like them, simply trim them away with any graphics editor, such as IrfanView, as you see here.
15.  Now we're going to edit the KML file to tie the legend image to the analysis image.  Completely close Google Earth now.  We don't want this preliminary image to interfere with the next steps.
16.  This is the KML file, cut short on the right side for easy viewing.  Notice that the main image object is completely contained between the <GroundOverlay>....</GroundOverlay> tags. 

Just below the </GroundOverlay> tag is the </Folder> tag.

We are about the insert new text between these two tags.

17.  This is the new text to insert.  You can copy it and paste it carefully between the </GroundOverlay> and </Folder> tags.

<ScreenOverlay id="Legend">
  <name>Legend</name>
  <description>Legend for my overlay</description>
  <Icon>
    <href>xxxxxxxxxxxxxxxxxxxx_legend.png</href>
  </Icon>
  <overlayXY x="0" y="1" xunits="fraction" yunits="fraction"/>
  <screenXY x="0" y="1" xunits="fraction" yunits="fraction"/>
  <size x="0" y="0" xunits="fraction" yunits="fraction"/>
  <rotation>0</rotation>
  <visibility>1</visibility>
  <open>0</open>
  </ScreenOverlay>

18.  Replace xxxxxxxxxxxxxxxxxxxxxxx_legend.png with the real legend image filename, which is sst_jan_liberia_modisa_ocweb_11u_daytime_0.05deg_hdf_saga_descaled_legend.png
19.  Replace Legend for my overlay with a short appropriate text, such as Jan SST [Deg C]
20.  Here's what the new section looks like, cut short on the right for easier viewing.  You can see the new text after <description> and after <href>

Check this insertion and these changes very carefully to make sure you've typed them correctly.

21.  Now save the edited KML file and open it (by double clicking) in GE.

If the legend is too small, then check Panel 11 above where you could make it bigger or smaller. 

Also, you can use the GE command language you inserted above to make changes, but simple magnification often leads to blurry images, so changes at the stage where the legend is originally created are best.

22.  Also, check how GE has listed the new objects.  The data image itself is named exactly the way Saga named the source map (as you saw above in Panel 8).  The legend is named as you named it in the KML text in Panel 20.
23.  Now, to zip up the files (KML, PNG, PGW) as GE prefers, use any appropriate zipping program to combine these files into a single ZIP (with your choice of name):
  • sst_jan_liberia_modisa_ocweb_11u_daytime_0.05deg_hdf_saga_descaled.kml
  • sst_jan_liberia_modisa_ocweb_11u_daytime_0.05deg_hdf_saga_descaled.png
  • sst_jan_liberia_modisa_ocweb_11u_daytime_0.05deg_hdf_saga_descaled_legend.png

Then change the extension of the file from ZIP to KMZ with, for example, Windows Explorer.  This gives you a single file that can be opened directly with GE.

24.  The KML Reference above contains about a dozen varying ways to set up the legend, including size and physical placement options.  This exercise is just to let you know how the basic insertion process takes place, and to show an extremely easy example.  The method also works for shapes (lines, points, polygons) that can be colored in Saga.  Only your imagination limits the possibilities.
25.  ADDENDUM:  If you do not like the white area on land in the final image (Panel 21), then here's how to make it transparent.  You don't have to close any of the above files, just leave them showing.
26.  Open the PNG image in IrfanView.
27.  Select FILE > SAVE (ORIGINAL FOLDER). In the right-side options panel, find and check USE PNGOUT PLUGIN.  Then click OPTIONS beside it.
28.  This additional panel of settings opens below the options panel.  Change BIT DEPTH to 8.

NOTE:  PNG files can have transparent pixels, but this requires the 8-bit setting.

Then click OK to close this options panel.

29.  Now you're back to the SAVE window and its options.

Select the original PNG file to save to (to simply overwrite the original version), and click SAVE.

30.  This message appears to warn you that you are overwriting the original image.  Click YES.
31.  The original image appears in a new window, with the message CLICK TO SET TRANSPARENT COLOR.

Simply click your cursor anywhere in the white area.

 

32.  Now the original image appears, with no apparent change.  The SAVEd version contains the transparent pixels.
33.  All the necessary work in IrfanView is completed now, and you can close it.
34.  In Google Earth reload the same KML file, and you'll get this message.  Click YES.

This loads in the new PNG file with the transparent pixels.

35.  This time the image has transparent pixels over the formerly white area (i.e. land), so you can see everything.
36.  If you like this view better, then make the ZIP and KMZ files again.  In WinZip you can simply refresh the PNG image by itself.