GeoNet Web Feature Service

This application provides basic functionality for a Web Feature Service (WFS) which allows advanced searches on the GeoNet earthquake catalogue. WFS is an Open Geospatial Consortium (OGC) standard to allow web-based access to geographical data.

Below are some sample queries for retrieving earthquake data from the WFS in CSV, JSON, GML and KML formats.

Basic Queries

The Last 50 Quakes

The earthquake catalogue is stored so that the most recent data is returned first. You can easily retrieve the last 50 quakes in the New Zealand region in a variety of formats:

GeoJSON
http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&maxFeatures=50&outputFormat=json

CSV
http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&maxFeatures=50&outputFormat=csv

GML 2
http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&maxFeatures=50&outputFormat=GML2

GML 3.2
http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&maxFeatures=50&outputFormat=text/xml; subtype=gml/3.2

KML
http://wfs.geonet.org.nz/geonet/wms/kml?layers=geonet:quake_search_v1&maxFeatures=50

All Quakes

It is not recommended to get all quakes in one request due to system capacity, please use the cql_filter below to build your request, e.g.:
http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter=origintime>='2020-01-01'+AND+origintime<'2021-01-01'

To download all quakes by separate http requests, see

#!/bin/bash -eu

#
# download all quakes from WFS and save data in a single csv file
#

[ ! -e data ] && mkdir data
cd data/

outPutFile="wfs_all.csv"
outPutTemp="temp.csv"

[ -e $outPutFile ] && rm $outPutFile

wfsURL="https://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter="
start=1980
end=$(date '+%Y')
end=$(($end + 1))
previousYear=$start

echo "### START downloading WFS data..."
#download data year by year
for ((year=$start; year<=$end; year+=1)); do
    if [ $year == $start ]; then
       url="${wfsURL}origintime<'${year}-01-01'"
       curl -s $url
    else
       if  [ $year == $end ]; then
          url="${wfsURL}origintime>='${previousYear}-01-01'"
       else
          url="${wfsURL}origintime>='${previousYear}-01-01'+AND+origintime<'${year}-01-01'"
       fi
       curl -s $url|tail +2
    fi
    previousYear=$year

done>$outPutTemp
#sort by modificationtime
(head -n 1 $outPutTemp && tail -n +2 $outPutTemp | sort -k4,4 -t ',') >$outPutFile

rm $outPutTemp

echo "### DONE data saved to data/$outPutFile"

To download quakes after a specified modificationtime, see

# download quakes from WFS for specified modification time and save data in a single csv file
# the modificationtime can be specified as
# 1. command line argument
# 2. extracted from existing data file (if no argument specified), e.g. earthquakes.csv
# usage: ./wfs_modified.sh 2021-01-01T00:21:59.311Z
#

dataFile="earthquakes.csv"
outPutFile="earthquakes_new.csv"
tempFile="earthquakes_temp.csv"
date=''

[ ! -e data ] && mkdir data
cd data/

#check cmd args
if [ ! $# -eq 0 ]; then
  date=$1
else
    if [  -e $dataFile ]; then
       # extract from dataFile, last line, 4th cell
	   date=$(tail -n 1 ${dataFile} | cut -d ',' -f4)
	fi
fi

if [ "$date" == "" ]; then
   echo Error: please supply a date argument or a base data file data/$dataFile. Usage: ./wfs_modified.sh 2021-01-01T00:21:59.311Z
   exit
fi

wfsURL="https://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter="

url="${wfsURL}modificationtime>'${date}'"
echo "### START downloading from ${url}"

[ -e $outPutFile ] && rm $outPutFile

# query data, remove header, sort by modificationtime and save
curl -s $url |tail -n +2 | (sort -k 4 -t ',')>$tempFile

if [  -e $dataFile ]; then
   # concat and remove duplicate publicid
   sort -t, -k1,1 -k4,4 -r -s $dataFile $tempFile| sort -t, -k1,1 -u -s|sort -t, -k4,4 -k3,3 -s>$outPutFile
   rm $tempFile
else
   mv $tempFile $outPutFile
fi

echo "### DONE data saved to data/$outPutFile"
Depths and magnitudes

Complex Queries and Filtering

You can make more complex queries using Contextual Query Language (CQL) to filter the results. Some examples are show below. The parameters and the output format can be adjusted in the URL. Also, see the CQL specification and the GeoServer CQL tutorial.

Note: when filtering with spatial queries filter on the origin_geom point type. The longitude and latitude columns are extracted from the origin_geom and provided in the output as a convenience for CSV users.


CSV format

All Quakes in a Date range

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter=origintime>='2013-05-01'+AND+origintime<'2013-08-01'

All Quakes in a Date Range, Located with More than 60 Phases

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter=origintime>='2013-06-01'+AND+origintime<'2014-01-01'+AND+usedphasecount>60

All Quakes Above Magnitude 6

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter=magnitude>6

All Quakes Above Magnitude 4 in a 1 Degree Square Box Around Wellington After a Date

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=csv&cql_filter=BBOX(origin_geom,174,-41,175,-42)+AND+origintime>='2009-08-01'+AND+magnitude>4


KML format

All Quakes Above Magnitude 6

http://wfs.geonet.org.nz/geonet/wms/kml?layers=geonet:quake_search_v1&cql_filter=magnitude>6

All Quakes Above Magnitude 6 and Deeper than 200 km

http://wfs.geonet.org.nz/geonet/wms/kml?layers=geonet:quake_search_v1&cql_filter=magnitude>6+AND+depth>200

All Quakes Above Magnitude 3 after 1 January 2013 and Occurring Within a Polygon Around Canterbury (corresponding to the Canterbury Region)

NB. To search a polygon, you need to search a closed shape, i.e. the first longitude/latitude pair is repeated again at the end

http://wfs.geonet.org.nz/geonet/wms/kml?layers=geonet:quake_search_v1&cql_filter=magnitude>3+AND+origintime>='2013-01-01'+AND+WITHIN(origin_geom,POLYGON((172.951+-41.767,+172.001+-42.832,+169.564+-44.341,+172.312+-45.412,+175.748+-42.908,+172.951+-41.767)))

All Quakes Shallower than 50 km and Occurring Within 5 km of a Point (longitude 174, latitude -41)

http://wfs.geonet.org.nz/geonet/wms/kml?layers=geonet:quake_search_v1&cql_filter=depth<50+AND+DWITHIN(origin_geom,Point+(175+-41),5000,meters)


GeoJSON format

All Quakes Above Magnitude 6 with event type "earthquake", sort by magnitude

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=json&cql_filter=magnitude>6+AND+eventtype=earthquake+AND+sortBy=magnitude

All Quakes Above Magnitude 6 and Deeper than 200 km

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=json&cql_filter=magnitude>6+AND+depth>200

All Quakes Above Magnitude 3 after 1 January 2010 and Occurring Within a Polygon Around Canterbury (corresponding to the Canterbury Region)

NB. To search a polygon, you need to search a closed shape, i.e. the first longitude/latitude pair is repeated again at the end

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=json&cql_filter=magnitude>3+AND+origintime>='2010-01-01T00:00:00.000Z'+AND+WITHIN(origin_geom,POLYGON((172.951+-41.767,+172.001+-42.832,+169.564+-44.341,+172.312+-45.412,+175.748+-42.908,+172.951+-41.767)))

All Quakes Shallower than 50 km and Occurring Within 5 km of a Point (longitude 174, latitude -41)

http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=json&cql_filter=depth<50+AND+DWITHIN(origin_geom,Point+(175+-41),5000,meters)

Date time format

The following date time formats are supported: