In our previous GMT examples we used a single command to create a simple globe and create an annotated map. In this example we will create a base map and then use the overlay feature of GMT to plot the location of volcanoes throughout the world.
The first step is to create the base map using pscoast:
pscoast -JN0/26 -R-180/180/-90/90 -W -G220/220/220 -S0/192/255 \
-N1 -B60g10 :."World Volcanoes": --PAPER_MEDIA=archA -K > world_volcanoes.eps
Sometimes the “out-of-the-box” GIS applications don’t fulfill your need. While writing your own application isn’t something to enter into lightly, sometimes it is the best solution.
A custom application might be the answer when you need:
- A simplified interface
- Special functions and tools
- Integration with other tools and data
The key to a successful custom application is to leverage the available toolkits and libraries—in other words let someone else do the hard work for you.
Some open source resources for writing your own applications are:
In a subsequent post we’ll take a look at writing a simple application to display some data using Python and the QGIS Python bindings.
Suppose you want to extract features from a vector layer to create a smaller subset. This can be very handy if you have a large dataset and need just a portion of it for your current project. If your data happens to be in one of the formats supported by OGR, you can use ogr2ogr to create a new layer.
For this example, we’ll create a map of Alaska and annotate it. If you looked at the Simple Globe example you’ll recall that the -R switch controls the extent of a GMT map. Alaska ranges from about 172 degrees east longitude to 130 degrees west. Using 360 degrees for the entire globe, this translates to a region extending from 172 degrees to 230 degrees. For the Alaska map we will use the Albers Equal Area Conic projection. Looking at the syntax for pscoast reveals that this requires the use of the -Jb switch. In this case, we use the lowercase “b” to indicate that we will specify the size of the map using a scale. First lets look at the command used to create the map:
pscoast -Jb-154/50/55/65/1:12000000 -R172/230/51/72 -B10g5/5g5 -W1p/0/0/0 \
-I1/2p/0/192/255 -I2/2p/0/192/255 -I3/1p/0/192/255 -I4/1p/0/192/255 \
-G220/220/220 -S0/192/255 -L210/54/54/1000 -P -N1/1p/0/0/0 -Dl >gmt_alaska_coast.eps
This looks like quite a complex command, but it’s really not too bad once you get past all the numbers and slashes.
The Generic Mapping Tools (GMT) can be used to create high quality maps for printing or use in web pages or documents.
You can easily create a simple globe (similar to the one on this website) using GMT. Here is the command:
pscoast -JA0/20/2.5i -Bg30/g15 -Dl -A2000 -G187/142/46 -S109/202/255 \
-R0/360/-90/90 -P -N1 > simple_hemi.eps
Sometimes you need just a portion of a raster for use in your latest mapping project. In this example we will see a simple way to extract a rectangular region of an image and warp it to the desired projection.