Map feeds

Trap.NZ provides a range of map feeds in OGC (Open Geospatial Consortium) formats which can be linked directly into GIS tools such as ArcGIS, Google Earth and Google Maps, QuantumGIS etc. To access the feeds you first need to generate an API key.

Generating an API key

In the My account section of Trap.NZ, you can generate an API key that’s associated with your user account. It can only be used for map feeds (which are read-only), and it can be changed any time by generating a new key, which will disable any previously used keys.

image-1639596511730.png

Accessing map feeds

Map feed addresses are in the format:

https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id
and
https://io.trap.nz/geo/trapnz-projects/wms/apikey/project_id

for WFS and WMS feeds respectively.

The Project ID is the last part of the URL when you select your project in Trap.NZ.
i.e. when you select the project after logging in, the URL will look something like https://trap.nz/node/123456, and in this case, the Project ID will be 123456.

Note: Some of the map feeds apply to all the projects you are a member of. If you are using those feeds, you still need to select a default project. It doesn’t matter which one.

So for a test user and project the WFS feed looks like this:
https://io.trap.nz/geo/trapnz-projects/wfs/35GElj7FEyGB-gpalO5ptgcEjxmNe7QzOiJNbEPZmSU/123456

You can paste these URLs into your GIS system and it will show you the available layers. 

The layers currently available are:
Notes

 

 

Trap records map feed attributes

Fields returned

Field

Description

record_id

the trap record UID

project_id

project number

project

project name

line

line name that the trap is associated with

trap_code

the trap code or name

trap_type

the trap type (e.g. DOC 200, A24, etc.)

trap_status

status of the trap when checked

rebaited

whether the trap was rebaited or not

bait_at_arrival

bait from the previous record (comma delimited if multiple)

bait_details_at_arrival

any bait details from the previous record

bait_at_departure

bait set with the trap record (comma delimited if multiple)

bait_details_at_departure

any bait details set with the trap record

strikes

strike count - for self-resetting traps this would be the number of times it has gone off since the last check. For conventional traps, this would be 1 if sprung.

species_caught

species name

gender

species sex if recorded

maturity

species maturity if recorded (juvenile/mature)

record_date

date of record

recorded_by

name of person who made the record

record_notes

record notes

prev_record_date

date of the previous record

next_record_date

date of the next record

corrected_nights_from_prev_record

RTC calculation (number of trap nights) from the previous record date

corrected_nights_to_next_record

RTC calculation (number of trap nights) to the next record date



Downloading shape files, CSV, linking into Google Earth etc

The map server allows access to WGS 84 and NZTM projections and can also output in many different formats with:

https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id?service=WFS&version=1.0.0&request=GetFeature&typeName=layer&outputFormat=format

Output formats:

GML2

outputFormat=GML2

GML3

outputFormat=GML3

Shapefile

outputFormat=shape-zip

JSON

outputFormat=application/json

JSONP

outputFormat=text/javascript

CSV

outputFormat=csv

e.g. to get a shapefile of trap locations:

https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id?service=WFS&version=2.0.0&request=GetFeature&typeName=trapnz-projects:my-projects-traps&outputFormat=shape-zip

 

https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id?service=WFS&version=2.0.0&request=GetFeature&typeName=trapnz-projects:my-projects-traps&outputFormat=application/vnd.google-earth.kml+xml

 

CSV:

https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id?service=WFS&version=2.0.0&request=GetFeature&typeName=trapnz-projects:my-projects-traps&outputFormat=csv

 

You can also view features directly in OpenLayers:

https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id?service=WMS&version=1.1.0&request=GetMap&layers=trapnz-projects:my-projects&bbox=174.94,-41.5,174.95,-41&width=708&height=768&srs=EPSG:4326&format=application/openlayers

 

Notes:

The WFS server is set to return a maximum of 10k features per request. If you have more that, you will need to use software (e.g. ArcGIS Pro, or QuantumGIS) to page requests, or include count and startindex parameters . See the WFS specification. 

 

 

Accessing the Trap.NZ map feeds with QGIS

Accessing layers

You can add a WFS Layers Layer > Add Layer > Add WFS Layerimage-1639610470879.png

 

Create a new Server Connection and enter the WFS URL in the format described here
https://io.trap.nz/geo/trapnz-projects/wfs/apikey/project_id

The WFS server is set to return a maximum of 10k features per request. If you have more than this number of features you must enable paging and set a page size less than 10,000.  We recommend 5000.

image-1639615373973.png

Save and then click Connect to see the available layers:
image-1639615716385.png

You can then add individual or groups of layers to the map.

Filtering records

You can add a CQL filter to a WFS connection to filter features from the WSF server. This can greatly reduce the amount of data retrieved (speeding up the transfer and improving performance).

For example - if you are only interested in this year’s records, you could add a CQL filter to build the query as a filter before loading the layer from the server.

1. Connect to the server as above to see the list of available layers.

2. Select the layer you want to query (e.g. default-project-trap-records) and click the Build query button

3. In the dialog that appears, enter the following SELECT * FROM "default-project-trap-records" WHERE record_date > '2021-01-01'  (or whatever date you wish to use)