OpenLayers 3There are several supported map libraries available to take advantage of NASA's Global Imagery Browse Services (GIBS) via OGC Web Map Tile Service (WMTS), Tiled Web Map Service (TWMS), and KML files. Listed below is a set of map libraries, code snippets, working examples, and screen captures designed to help in building your own user interface to explore NASA's Earth imagery. Alternatively, these guidelines can also help to integrate that imagery into your existing client or to build scripts to retrieve imagery from GIBS. Geographic Information System (GIS) users: go here for instructions.
Code Available in GitHub
In addition to the snippets below, fully-working code examples are available for OpenLayers and Leaflet in the GIBS GitHub project area.
Web-based Libraries
UI Expand | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
OpenLayers 2 is an open source, web browser-based mapping library written in JavaScript. OpenLayers maps can also be viewed on mobile devices since no plugins are required to use it. Requirements
Sample Clients
Usage (Geographic)The following code snippets provide information for creating a basic OpenLayers-based GIBS client for imagery in the Geographic (EPSG:4326) projection. See the info provided in the GIBS layer configuration information for details on configuring each layer. For this example, we will be using an imagery layer with a 250m resolution. First create a map object with a geographic (i.e., lat-lon) projection. Note that the numZoomLevels attribute has a value of 9, based on the table above.
Next, define service- and product-specific constants related to the map projection, resolution, and service endpoint (see here for more info):
Now create base and overlay layers for two products (more info on available products can be found here). No style value is required for GIBS image accesses. The isBaseLayer element should be set accordingly as to whether this is a base (true) or overlay (false) layer. All base layers have a format of image/jpeg and all overlay layers have a format of image/png. The maxResolution attribute has a value of 0.5625, based on the layer configuration information. The serverResolution element is a listing of resolutions that are provided by the GIBS server (more info here). The resolutions element is a listing of resolutions that should be provided to the end user (more info here). If additional resolutions are included in the resolutions element that are not in the serverResolutions element, then OpenLayers will perform client-side "overzooming."
Finally, add the layers to the map, add a layer switcher, and set the view extent:
Usage (Polar Stereographic)To use GIBS imagery in an Arctic Polar Stereographic (EPSG:3413) or Antarctic Polar Stereographic (EPSG:3031) projection, follow the same instructions as geographic but change the TileMatrixSets, number of zoom levels, and resolution parameters to match the polar projections as listed in the layer configuration info. Please also note that only a subset of layers are available in Arctic and Antarctic compared to geographic. Note that static variables are shown below for both the Arctic and Antarctic projections, but only Arctic layers are created.
|
...
UI Expand | ||
---|---|---|
| ||
Google Earth (Plugin) is a virtual globe that can be embedded on a webpage and manipulated through Javascript. It utilizes the KML interface of TWMS to retrieve data. RequirementsLimitationsGoogle Earth does not have a convenient method of layering maps on top of each other. One can achieve the effect by changing the elevation that the map layers are displayed at, although that sometimes can introduct unwanted artifacts on the display. UsageThe Javascript uses a callback function to load data from a URL. The list of available products can be found here.
ScreenshotsGIBS data displayed in the Google Earth Plugin (As used in PO.DAAC's State of the Ocean when "MODIS True Color" layers are selected) Additional Documentation |
UI Expand | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
The Flash/Flex client library is a native Flash client written in ActionScript. It can be embedded into Flash applications on web pages as well as an embedded application that utilizes the Adobe Air framework. It is built upon ArcGIS's Flex API libraries to load tiles and present images with a custom TWMS data loader. The library comes with a sample HTML page that presents a simple Flash client which can load layers from arbitrary TWMS servers and allow users to select time-values. Requirements
UsageTo use the library, include the pre-compiled Flash library and use the following code snippet in the .mxml file.
Screenshots
Additional DocumentationThe Flex API for ArcGIS can be obtained here. Code SnippetsAdding a map layer (Provided by ArcGIS's API)
|
Desktop Application Libraries
UI Expand | ||||||
---|---|---|---|---|---|---|
| ||||||
World Wind is a multi-platform virtual globe developed by NASA that runs in Java. It can load GIBS data through either the KML interface or the TWMS interface. Requirements
Usage (KML)To run the World Wind client with GIBS KML capabilities, load the "KML Viewer" demo application from either the standalone client or the online demo. To load a specific layer, select File | Open URL... and enter a URL for the layer in this format: http://<url to kmlgen.cgi>?layers=<layername>&time=<time> for example, http://gibs.earthdata.nasa.gov/twms/epsg4326/best/kmlgen.cgi?layers=MODIS_Terra_CorrectedReflectance_TrueColor&time=2012-06-21 To enable time adjustment on a particular layer, use the following URL parameter: time=R10/<date>/P1D for example, http://gibs.earthdata.nasa.gov/twms/epsg4326/best/kmlgen.cgi?layers=MODIS_Terra_CorrectedReflectance_TrueColor&time=R10/2012-05-26/P1D Additional documentation is available here. Limitations: The name of the layer has to be known prior to entering the URL. The list of available layers can be found here. Usage (TWMS)To run the World Wind client with TWMS capabilities, load the WMS Layer Manager demo application from either the standalone client or the online demo. In the layers menu, add the TWMS endpoint. This will load the list of layers available from TWMS and selecting a layer will allow it to be shown on the globe. Limitations: World Wind will continue to zoom and try to load images even if they're beyond the depth of the highest resolution tile. When this happens, the images will go blank. In addition, this interface does not allow the selection of variables such as time. Screenshots
|
UI Expand | ||
---|---|---|
| ||
See the Google Earth section on the GIBS GIS Usage page. |
Mobile App Libraries
UI Expand | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||
The iOS client library is a native library written in Objective-C and can be incorporated into any iOS app for the iPod Touch, iPhone, and iPad. It is built upon ArcGIS's iOS client libraries, which provides a MapView and asynchronous tile loading, coupled with a custom TWMS data loader. The library comes with a sample client to display TWMS maps and includes basic manipulations such as presenting data from arbitrary TWMS server, selecting a time-value, and map layer reordering. Requirements
UsageTo use the library, create an AGSMapView object, either programmatically or linked from Interface Builder, and use the following code snippet as an example.
Screenshots
Additional DocumentationThe ArcGIS iOS documentation can be obtained here. The standard iOS documentation can be viewed here. The iOS library defines 3 classes that are used to load TWMS data: TWMSTiledWebMapService: Instantiated for each TWMS endpoint. TWMSTiledMap: Represents an individual map layer in the TWMS. TWMSTiledMapLayer: A subclass of ArcGIS's map layer to show TWMS data. TWMSTiledWebMapService Properties name: The name of the TWMS as defined in the GetTiledService request. title: The title of the TWMS as defined in the GetTiledService request. abstract: The abstract of the TWMS as defined in the GetTiledService request. tiledMaps: A dictionary where the keys are the name of each map layer and values are the TWMSTiledMap instances. Methods (id)initWithUrl:(NSURL*)url: Loads the TWMS data given by the url to instantiate this class. (NSArray*)listAllTiledMapsByName: Returns a sorted list of map layer names. (void)setTiledMapKeyValue:(NSString*)value forTiledMapKey:(NSString*)key: Assigns variable keys for all TiledMaps in the TWMS server. (NSDictionary*)tiledMapKeyValues: Returns a dictionary of all the keys used in all TiledMaps and the value its currently set to. TWMSTiledMap Properties name: The name of the layer as defined in the GetTiledService request. title: The title of the layer as defined in the GetTiledService request. uuid: A randomly generated unique ID for the layer. Code SnippetsCreate a new TWMSTiledWebMapService using a URL
List all map layers in a TWMS server
Update variables for all TWMS endpoints
Add, reorder, and remove map layers (Provided by ArcGIS's MapView class)
Set map layer transparency (Provided by iOS UIView's transparency settings)
|
Script-level Access
UI Expand | ||
---|---|---|
| ||
See the GIBS API documentation for script-level access to GIBS via GDAL. |