Fanning Software Consulting

Coyote Graphics Map Projection Programs

These are programs from the Coyote Library that are specifically identified as being associated with map projections. On-line documentation for these programs is available. A number of program examples using Coyote Map routines can be found in the Coyote Plot Gallery.

Alphabetical List of Programs

***

cgCBAR2KML

The purpose of this program is to create a KML file containing a "ScreenOverlay" element that can be opened in Google Earth to display a color bar. Screen overlays are located at a stationary position on the Google Earth display, which the 3D Earth rotates and zooms beneath it. Screen overlays can be made visible and invisible, as needed.
   kmlFile = Obj_New('cgKML_File', 'avhrr_ndvi_cb.kml')
   cgLoadCT, 11, /Brewer, /Reverse, RGB_Table=palette
   map = cgGeoMap('AF03sep15b.n16-VIg.tif', Image=image)
   scaledImage = BytScl(image > 0)
   cgImage2KML, scaledImage, map, $
          Palette=palette, Missing_Value=0, $
          Description='AVHRR NDVI Data from Africa', $
          PlaceName='AVHRR Africa', $
          AddToFile=kmlFile
   cgCBar2KML, Palette=palette, Range=[0,9400], $
          Title='NDVI Index', $
          Description='AVHRR NDVI Color Bar', $
          PlaceName='NDVI Color Bar', $
          AddToFile=kmlFile
   kmlFile -> Save
   kmlFile -> Destroy
An image overlay on Google Earth
An AVHRR NDVI image with a color bar overlaid on Google Earth.
 

***

cgCHANGEMAPPROJECTION

This is a utility program that warps an image in one map projection to another map projection, using Map_Proj_Image. The input and output map projections are specified using the map coordinate object cgMap. The program is especially useful in converting map projected images into the map projection required to create image overlays in Google Earth.

***

cgCLIPTOMAP

This is a utility program that allows the user to clip or subset a georegistered image (i.e., one with an associated map coordinate object) to a map boundary. It is useful when comparing two images with different map ranges and/or pixel resolutions. This works particularly well with GeoTiff images.

***

cgDRAWSHAPES

The purpose of this program is to draw shapefile polygons and polylines on map projections.
A states shapefile is displayed.
States from a states shapefile are displayed.
 

***

cgEXTRACTSHAPE

This is a utility program that extracts a single shape or polygon from a shapefile.

***

cgFINDMAPBOUNDARY

This utility routine finds the map projection grid boundary from a file, if it is possible to do so. Currently works with GeoTIFF files, CF 1.4 compliant netCDF files, and GPD files created with the GPD_Viewer software from the Catatlyst Library.

***

cgIMAGE2KML

The purpose of this program is to create a KML file containing a "GroundOverlay" element that can be opened in Google Earth to drape an IDL image over the Google Earth terrain. Map coordinates locate the image overlay on the Google Earth map. For example, the following command creates a KML file that overlays an AVHRR NDVI image of Africa when opened in Google Earth.
   cgImage2KML, GeoTiff='AF03sep15b.n16-VIg.tif', Min_Value=0, CTIndex=11, $
      /Brewer, /Reverse, Transparent=50, Filename='avhrr_ndvi.kml', $
       Description='AVHRR NDVI Data from Africa'
An image overlay on Google Earth
An AVHRR NDVI image of Africa overlaid on Google Earth.
 

***

cgKML2KMZ *New!*

This program packages KML files and their associated image files up into a compressed KMZ zip file that can be loaded into Google Earth. The method uses an unofficial unvailing of the zip API in IDL for cross-platform zipping of files. IDL 8.1 or higher is required to use this functionality.

***

cgGEOMAP

The purpose of this function is to translate a GeoTiff structure (as returned by Query_Tiff or Read_Tiff) into a map coordinate object (cgMap) that can be used to georeference images with a map data coordinate system. If desired, the GeoTiff image can be displayed in a georegistered resizeable graphics window directly.

***

cgGOOGLE_METERSPERPIXEL

This is a utility routine that can be used to calculate the number of meters per pixel in a Google Static Image Map with a given zoom level. This value is required to set up a map coordinate system for the static image map. Setting up a coordinate system (via a cgMap object) is what allows the user to draw on top of the static image map.

***

cgGOOGLE_MAPMARKER__DEFINE

This is a structure definition routine for a Goggle map marker structure that is used to create map markers for display on Google Static Maps. Used with the cgGoogleMapWidget compound widget-object.

***

cgGOOGLEMAPWIDGET

This is a compound widget-object for incorporating a Google Static Image Map into a widget application. The program implements a subset of the Google Static Map API. The program works by building a URL for a map image. A connection to the Internet is required to then request a map image (in GIF, JPEG or PNG format) to be returned from Goggle Maps. The returned image is then read and loaded into a draw widget window of the right size for the returned map image. The default is to delete the image file that is created, but user can also set keywords to retain the image that is downloaded from Google Maps. Users are able to control button and motion events in the resulting draw widget with their own event handler module. A cgMap coordinate object is created to establish a map reference coordinate system on top of the returned map image, allowing other map information to be drawn on top of the returned map image.
A Google Static Image Map.
A Google Static Image Map with a lidar track displayed on top of it. Google markers are placed every 5 seconds.
 

***

cgGOOGLEMAPWIDGET__DEFINE

This is the implementation of the cgGoogleMapWidget described above. If called by itself, it will create its own top-level base widget and can be used as a stand-alone application. However, it is more likely that users will want to use their own event handlers to draw on to of the image returned from Google. Provisions for doing that are built into the object.

***

cgMAP_CONTINENTS

The purpose of this object is to provide a simple wrapper to the Map_Continents command that is used to draw continental outlines on maps. It uses the device and color-model independent Coyote Graphics commands internally, and can be added to a cgWindow by setting the AddCmd keyword.

***

cgMAP_GRID

The purpose of this object is to provide a simple wrapper to the Map_Grid command that is used to draw grid line on maps. It uses the device and color-model independent Coyote Graphics commands internally, and can be added to a cgWindow by setting the AddCmd keyword. Many of the problems with Map_Grid, and especially problems caused by using Map_Grid with GCTP map projections, have been corrected in this routine.

***

cgMAP_GSHHS

This program uses files from the Globally Self-consistent Hierarchical High-resolution Shoreline (GSHHS) data base to draw shorelines in the manner of cgMap_Continents. In other words, it is assumed that a map coordinate data space has been established prior to calling this routine. See the example below. The GSHHS data files are available for downloading. An article describing how to use this program is also available.

Note, the authors of the GSHHS software continually change the header structure, which you must know to read the data file. There are are now at least four different structures in common use. Please find the one you need from the commented list in the code itself. The current code uses the structure for the 2.2 version of the GSHHS software.

***

cgMAP_SET

This program provides a modified Map_Set command that can work together with other Coyote Graphics commands and be used in or added to resizeable graphics windows. Any keyword appropriate for Map_Set can be used with this routine.

***

cgMAP

The purpose of this object is to provide an easy and powerful way to set up and use a map coordinate space created by the GCTP map projections accessed by Map_Proj_Init. The program is basically a wrapper for Map_Proj_Init, combined with a cgCoord data coordinate object, to provide a way to set up and maintain a map coordinate space. Overlay objects can be add to cgMap to draw graphics in the map coordinate space as well. Typically, continental outlines and map grid lines are added, and these two overlays can be selected by appropriate keywords. This object can be added to a cgWindow by selecting either the Window or AddCmd keyword.

***

cgMAPCONTINENTS

This program provides an object wrapper to the cgMap_Continents and cgMap_GSHHS commands. It can be used as an overlay object in the cgMap object, or as a stand-alone graphics object for drawing continental and country outlines on maps.

***

cgMAPGRID

This program provides an object wrapper to the cgMap_Grid command. It can be used as an overlay object in the cgMap object, or as a stand-alone graphics object for drawing grid lines on maps.

***

cgMAPPLOTS

This program allows the user to draw lines and symbols on map projections set up with cgMap.

***

cgMAPVECTOR

This program allows the user to draw vectors (arrows) on map projections set up with cgMap.

***

cgNCDFMAP

This program can create a map coordinate object from map projection information stored in netCDF files. Not all netCDF files contain enough information to create a map projection space in IDL, but many do. If it can be done, this program will do it!

***

cgSHAPEINFO

The purpose of this program is to allow the user to browse a very narrow selection of shapefiles. Namely, those containing geographical shapes in latitude and longitude coordinates. In other words, shapefiles containing maps. File attributes are listed in the left-hand list widget. Clicking on a file attribute, will list all the entity attributes for that file attribute in the right-hand list. Clicking an entity attribute with list the type of entity, and the X and Y bounds of that entity (shown as LON and LAT, respectively), in the statusbar at the bottom of the display.

Knowing the attribute and entity names of a shapefile will give you insight into how to read and display the information in the file. For examples, see the Coyote Library programs DrawCounties and DrawStates.

The cgShapeInfo program.

***

cgTERMINATORMAP

This is a program for viewing a map of the Earth in several different projections with a day/night terminator. The program uses routines from the JHUAPL IDL Library, which must also be on your IDL path, along with the Coyote Library.
A map with a day/night terminator.
A map with a day/night terminator.
 

***

cgUTMZONE

This function returns the correct UTM zone for a given longitude and latitude value. Note that the exceptions to the UTM zones in the Svalbard area are not currently supported. The user will be notified of this fact, if needed.

***

cgWARPTOMAP

This function warps data that is in either a 1D or 2D array, with associated latitude and longitude values, into a map projection. It is the Coyote Graphics equivalent of the IDL function Map_Patch. You can learn how to use this function by reading the article Mapping Data Associated with Lat/Lon Arrays.

Version of IDL used to prepare this article: IDL 7.0.1.

Last Updated: 16 November 2011