Skip to Main Content Skip to Search
Product Documentation

gshhs - Read Global Self-Consistent Hierarchical High-Resolution Shoreline

Syntax

S = gshhs(filename)
S = gshhs(filename, latlim, lonlim)
indexfilename = gshhs(filename, 'createindex')

Description

S = gshhs(filename) reads GSHHS vector data for the entire world from filename. GSHHS files must have names of the form gshhs_x.b, wdb_borders_x.b, or wdb_rivers_x.b, where x is one of the letters c, l, i, h or f, corresponding to increasing resolution (and file size). The result returned in S is a polygon or line geographic data structure array (a geostruct, with 'Lat' and 'Lon' coordinate fields).

S = gshhs(filename, latlim, lonlim) reads a subset of the vector data from filename. The limits of the desired data are specified as two-element vectors of latitude, latlim, and longitude, lonlim, in degrees. The elements of latlim and lonlim must be in ascending order. Longitude limits range from [-180 195]. If latlim is empty the latitude limits are [-90 90]. If lonlim is empty, the longitude limits are [-180 195].

indexfilename = gshhs(filename, 'createindex') creates an index file for faster data access when requesting a subset of a larger dataset. The index file has the same name as the GSHHS data file, but with the extension 'i', instead of 'b' and is written in the same folder as filename. The name of the index file is returned, but no coastline data are read. A call using this option should be followed by an additional call to gshhs to import actual data. On that and subsequent calls, gshhs detects the presence of the index file and uses it to access records by location much faster than it would without an index.

Output Structure

The output structure S contains the following fields. All latitude and longitude values are in degrees.

Field Name

Field Contents

'Geometry'

'Line' or 'Polygon'

'BoundingBox'

[minLon minLat; maxLon maxLat]

'Lon'

Coordinate vector

'Lat'

Coordinate vector

'South'

Southern latitude boundary

'North'

Northern latitude boundary

'West'

Western longitude boundary

'East'

Eastern longitude boundary

'Area'

Area of polygon in square kilometers

'Level'

Scalar value ranging from 1 to 4, indicates level in topological hierarchy

'LevelString'

'land', 'lake', 'island_in_lake', 'pond_in_island_in_lake', or ''

'NumPoints'

Number of points in the polygon

'FormatVersion'

Format version of data file. Positive integer for versions 3 and later; empty for versions 1 and 2.

'Source'

Source of data: 'WDBII' or 'WVS'

'CrossGreenwich'

Scalar flag: true if the polygon crosses the prime meridian; false otherwise

'GSHHS_ID'

Unique polygon scalar id number, starting at 0

For releases 2.0 and higher (FormatVersion 7 and higher), the following additional fields are included in the output structure:

Field Name

Field Contents

'RiverLake'

Scalar flag: true if the polygon is the fat part of a major river and the Level value is set to 2; false otherwise.

'AreaFull'

Area of original full-resolution polygon in units .

'Container'

ID of container polygon that encloses this polygon. Set to -1 to indicate none.

'Ancestor'

ID of ancestor polygon in the full resolution set that was the source of this polygon. Set to -1 to indicate none.

Tips

Background

The Global Self-Consistent Hierarchical High-Resolution Shoreline was created by Paul Wessel of the University of Hawaii and Walter H.F. Smith of the NOAA Geosciences Lab. At the full resolution the data requires 85 MB uncompressed, but lower resolution versions are also provided. This database includes coastlines, major rivers, and lakes. The GSHHS data in various resolutions is available over the Internet from the National Oceanic and Atmospheric Administration, National Geophysical Data Center Web site.

Version 3 (Release 1.3) of the gshhs_c.b (coarse) data set ships with the toolbox in the toolbox/map/mapdata folder. For details, type

type gshhs_c.txt

at the MATLAB command prompt. The gshhs function has been qualified on GSHHS releases 1.1 through 2.1 (version 8). It should also be able to read newer versions, if they adhere to the same header format as releases 2.0 and 2.1.

Examples

Example 1

Read the entire coarse data set (located on the MATLAB path in matlabroot/toolbox/map/mapdata):

filename = gunzip('gshhs_c.b.gz', tempdir);
world = gshhs(filename{1});

Display as a coastline:

figure
worldmap world
geoshow([world.Lat], [world.Lon])

Display each level in a different color.

levels = [world.Level]; 
land = (levels == 1); 
lake = (levels == 2); 
island = (levels == 3); 
figure 
worldmap world 
geoshow(world(land),  'FaceColor', [0 1 0]) 
geoshow(world(lake),  'FaceColor', [0 0 1]) 
geoshow(world(island),'FaceColor', [1 1 0]) 

After creating an index file, read and display Africa as a green polygon; note that gshhs detects and uses the index file automatically:

indexname = gshhs(filename{1}, 'createindex');
figure
worldmap Africa
projection = gcm;
latlim = projection.maplatlimit;
lonlim = projection.maplonlimit;
africa = gshhs(filename{1}, latlim, lonlim);
geoshow(africa, 'FaceColor', 'green')
setm(gca, 'FFaceColor', 'cyan')

Delete the temporary files:

delete(filename{1})
delete(indexname)

Example 2

Read the intermediate resolution database for South America:

s = gshhs('gshhs_i.b',[-60 -15],[-90 -30])

Example 3

Read the full-resolution file for East and West Falkland Islands (Islas Malvinas):

s = gshhs('gshhs_f.b',[-55 -50],[-65 -55])

Example 4

Create the index file for the high-resolution database:

gshhs('gshhs_h.b','createindex')

See Also

dcwdata | geoshow | maptrimp | shaperead | vmap0data | worldmap

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS