Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

ex51.rst 2.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. .. _example_51:
  2. (51) OpenStreetMap coastlines in GMT
  3. ------------------------------------
  4. This example shows how to use coastlines derived from the `OpenStreetMap (OSM)
  5. project <https://www.openstreetmap.org/>`_ in GMT. When working with the high
  6. resolution SRTM :doc:`/datasets` provided by GMT, the GSHHG coastlines might
  7. not be precise enough on small scales. Here comes the OSM project to the rescue
  8. as it provides high resolution coastlines in the WGS84 datum. Not as convenient
  9. and fast as GSHHG but easy enough to give it a try – as long as you have GDAL
  10. installed, space on your hard drive and some processor cycles to spare.
  11. .. note::
  12. This example makes use of data provided by third parties outside the GMT
  13. universe. As the internet is constantly changing, the source of this data
  14. might move or vanish altogether.
  15. First we need to download the appropriate shape file. The `OSM Wiki
  16. <https://wiki.openstreetmap.org/wiki/Shapefiles#Obtaining_shapefiles_from_OSM_data>`_
  17. has some sources, `this <https://osmdata.openstreetmap.de/data/land-polygons.html>`_
  18. is the one we are going to use. The nice people of the `German FOSSGIS society
  19. <https://www.fossgis.de>`_ already did some of the heavylifting and converted
  20. the OSM coastlines to a shape file for us. Make sure to get the *Land Polygon*
  21. in the *Large polygons not split* version with WGS84 datum from their `download
  22. page <https://osmdata.openstreetmap.de/data/land-polygons.html>`_. It’s a
  23. ~630 MB download.
  24. If your GMT installation comes with GDAL support then you are able to make use
  25. of this file right away as GMT converts it under the hood to something more
  26. useful on the fly. Neither very fast nor very efficient if you want to use the
  27. file multiple times and have to deal with large file sizes as we do here. So we
  28. use GDAL's ``ogr2ogr`` and convert the shape file to a native GMT format.
  29. As the resulting raw ASCII file is very large (>1 GB), GMT's :doc:`/gmtconvert`
  30. is used to reduce the file size to a third by converting it to a
  31. single-precision binary file. The resulting file is smaller than the initial
  32. download while still maintaining precision in the range of centimeters.
  33. To speed up the plotting process even more, we extract the region of interest
  34. with :doc:`/gmtselect`. Finally we are all set to use the coastlines with
  35. :doc:`/plot` to get nice, precise coastlines in our illustrations.
  36. .. literalinclude:: /_verbatim/ex51.txt
  37. :language: bash
  38. .. figure:: /_images/ex51.*
  39. :width: 500 px
  40. :align: center
  41. Comparison of GSHHG and OSM coastlines.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...