Read Global Self-Consistent Hierarchical High-Resolution Geography
S = gshhs(filename)
S = gshhs(filename, latlim, lonlim)
indexfilename = gshhs(filename, 'createindex')
S = gshhs(filename) reads
GSHHG (formerly GSHHS) vector data for the entire world from filename.
GSHHG 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 GSHHG 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.
The output structure S contains the following
fields. All latitude and longitude values are in degrees.
Field Name | Field Contents |
|---|---|
|
|
|
|
| Coordinate vector |
| Coordinate vector |
| Southern latitude boundary |
| Northern latitude boundary |
| Western longitude boundary |
| Eastern longitude boundary |
| Area of polygon in square kilometers |
| Scalar value ranging from 1 to 4, indicates level in topological hierarchy |
|
|
| Number of points in the polygon |
| Format version of data file. Positive integer for versions 3 and later; empty for versions 1 and 2. |
| Source of data: |
| Scalar flag: |
| 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 |
|---|---|
| Scalar flag: |
| Area of original full-resolution polygon in units . |
| ID of container polygon that encloses this polygon. Set to -1 to indicate none. |
| ID of ancestor polygon in the full resolution set that was the source of this polygon. Set to -1 to indicate none. |
For Release 2.2 and higher (FormatVersion 9
and higher) the following additional field is included in the output
structure:
Field Name | Field Contents |
|---|---|
| Scalar flag: |
The Global Self-Consistent Hierarchical High-Resolution Geography (formerly 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 GSHHG data in various resolutions is available over the Internet from the National Oceanic and Atmospheric Administration, National Geophysical Data Center website.
Version 3 (Release 1.3) of the gshhs_c.b (coarse) data set ships with the
toolbox in the
folder. For details, typematlabroot/examples/map/data
type gshhs_c.txt
gshhs function has
been qualified on GSHHG releases 1.1 through 2.3.6 (version 15). It should
also be able to read newer versions, if they adhere to the same header
format as releases 2.0 and 2.1.If you are extracting data within specified geographic
limits and using data other than coarse resolution, consider creating
an index file first. Also, to speed rendering when mapping very large
amounts of data, you might want to plot the data as NaN-clipped
lines rather than as patches.
When you specify latitude-longitude limits, polygons
that completely fall outside those limits are excluded, but no trimming
of features that partially traverse the region is performed. If you
want to eliminate data outside of a rectangular region of interest,
you can use maptrimp with the Lat and Lon fields
of the geostruct returned by gshhs to clip the
data to your region and still maintain polygon topology.
You can read the WDB rivers and borders datasets but
the LevelString field will be empty. The Level values
vary from feature to feature but the interpretations of these values
are not documented as part of the GSHHG distribution and are therefore
not converted to character vectors.