(24) Data selection based on geospatial criteria — GMT 5.1.1 documentation

### Navigation

- index
- next
- previous
- Project Home »
- GMT 5.1.1 documentation »
- The GMT historical collection »
- Search:

# (24) Data selection based on geospatial criteria

Although we are not seismologists, we have yet another example involving seismicity. We use seismicity data for the Australia/New Zealand region to demonstrate how we can extract subsets of data using geospatial criteria. In particular, we wish to plot the epicenters given in the file `oz_quakes.d` as red or green circles. Green circles should only be used for epicenters that satisfy the following three criteria:

1. They are located in the ocean and not on land
2. They are within 3000 km of Hobart
3. They are more than 1000 km away from the International Dateline

All remaining earthquakes should be plotted in red. Rather that doing the selection process twice we simply plot all quakes as red circles and then replot those that pass our criteria. Most of the work here is done by gmtselect; the rest is carried out by the usual pscoast and psxy workhorses. Note for our purposes the Dateline is just a line along the 180 meridian.

The script produces the plot in Figure. Note that the horizontal distance from the dateline seems to increase as we go south; however that is just the projected distance (Mercator distortion) and not the actual distance which remains constant at 1000 km.

    #!/bin/bash
    #		GMT EXAMPLE 24
    #
    # Purpose:	Extract subsets of data based on geospatial criteria
    # GMT progs:	gmtselect, pscoast, psxy, gmtinfo
    # Unix progs:	echo, cat, awk
    #
    # Highlight oceanic earthquakes within 3000 km of Hobart and > 1000 km from dateline
    ps=example_24.ps
    echo "147:13 -42:48 6000 Hobart" > point.d
    cat << END > dateline.d
    > Our proxy for the dateline
    180	0
    180	-90
    END
    R=`gmt info -I10 oz_quakes.d`
    gmt pscoast $R -JM9i -K -Gtan -Sdarkblue -Wthin,white -Dl -A500 -Ba20f10g10 -BWeSn > $ps
    gmt psxy -R -J -O -K oz_quakes.d -Sc0.05i -Gred >> $ps
    gmt gmtselect oz_quakes.d -L1000k/dateline.d -Nk/s -C3000k/point.d -fg -R -Il \
    	| gmt psxy -R -JM -O -K -Sc0.05i -Ggreen >> $ps
    gmt psxy point.d -R -J -O -K -SE- -Wfat,white >> $ps
    $AWK '{print $1, $2, $4}' point.d | gmt pstext -R -J -O -K -F+f14p,Helvetica-Bold,white+jLT \
    	-D0.1i/-0.1i >> $ps
    gmt psxy -R -J -O -K point.d -Wfat,white -S+0.2i >> $ps
    gmt psxy -R -J -O dateline.d -Wfat,white -A >> $ps
    rm -f point.d dateline.d

Data selection based on geospatial criteria.

### Navigation

- index
- next
- previous
- Project Home »
- GMT 5.1.1 documentation »
- The GMT historical collection »
- Search: