On potential errors in the GSHHG coastline, and how one can "fix" them

I’ve been plotting maps of small regions, and noticed the DEM data I am using do not match up exactly with the built in coastlines (e.g. gmt coast -Df ...). Here’s an example:

Notice the dark green areas around the coast. Now these could be genuine very low elevation locations (near to 0 m above mean sea level). But I know for a fact that there are quite precipitous cliffs along parts of the south coast of Tongatapu where there is a band of dark green (marked by the red ellipse). Here is a photograph of the area:

Initially I thought it was probably an error in the DEM. But just for interest, I decided to compare the built in GSHHG coastline with the coastline from OpenStreetMaps. Once one has downloaded the OpenStreetMap coastline (in shapefile format) and unzipped it, it can be read by GMT (provided GDAL support has been compiled in). The OpenStreetMap coastline is a huge file, and takes a long time to plot. It is easily cut down to a manageable size with GMT:

gmt gmtspatial land-polygons-complete-4326/land_polygons.shp -C -R178:30W/23S/171W/14S+r > tonga.ll

Adjust the region for your purposes.

Now we can easily compare the OpenStreetMap coastline with the GSHHG coastline built into GMT:

#!/usr/bin/env bash
#
# Compare OpenStreetMap coastline with GSHHG built into GMT.

proj="T177W/0S"
tongatapu_region="175:25W/21:33S/174:50W/20:56S"

gmt begin coast PNG,pdf
	gmt plot tonga.ll -J${proj}/25c -R${tongatapu_region}+r \
		-BWSen -Bpxfa1 -Bpyf1a1 -Wthinnest,black
	gmt coast -Df -Wthinnest,red
gmt end

And here is the map (OpenStreetMap is black, GSHHG is red).

One can see that there are some quite large differences in the two coastlines. At least along the south coast of Tongatapu the OpenStreetMap coastline more closely matches the DEM, and what I would expect to see from actually being there.

Hello @timhume,

unfortunately that’s a known problem with the GSHHG coastline. In short: What you see is mostly inaccurate data from pre WGS72 times. Additionally some coastline data in GSHHG has a different datum that’s unknown or being ignored leading to position shifts.

Please see this thread for background. The current workaround is what you already did: use OpenStreetMap coastlines if you need high precision. Example 51 in the gallery deals with this as well.

1 Like

Thanks @KristofKoch It’s good to know I’m not seeing things!

Yes, as I mentioned in that thread from 5 years ago, the GSHHG coastlines are not accurate for plotting detailed maps. It was originally from data digitized 4-5 decades ago from coarse-resolution maps. I am glad you figured out the way to use OpenStreetMap, which is far more accurate.

1 Like

Example 51 in the gallery has some extra useful tips that I was unaware of, such as rounding the vertices of the OpenStreetMap polygons. And the binary format instead of text for the coastline data to save space - though for the region I’m interested in, the file size is not too large.