Monday 11 June 2012

An R function for finding coordinates of NZ localities

Over the course of my PhD, I will be doing a fair amount of georeferencing. This involves obtaining geographic coordinates for localities where weevil specimens have been collected. When I'm the one who has collected them, this is fairly straightforward—Google Maps has made obtaining coordinates a breeze. When it's a museum specimen, however, things get a little tricky. Maps and atlases are extremely useful, but hard to search through. The university has access to MapToaster which contains the topographic maps of New Zealand, and which allows one to search for place names. However, it's only available from university computers, and the search feature requires a degree of mouse work to drive it. LINZ has made the New Zealand Geographic Place Names Database freely available online, which is also fairly fiddly to use in a high throughput situation. However, it is based on a fairly well-structured database, which allowed me to write an R function to search and retrieve information (including coordinates) for place names of interest.

The result is gazNZ(). This function allows a name to be searched for from the R console, making the process of finding coordinates a lot quicker, and means that I only need to use my keyboard when searching for things—a much more satisfying state of affairs.

> gazNZ("Cook Strait")
Read 201 items
Read 211 items
$`Cook Strait`
[1] -41.2493 174.4736

1 comment:

JDK said...

I trust you'll always select the lesser of two weevils...