Introduction

The mapdata R package contains a coastline called worldHires which is contained within a text file with a bit over 2 million lines. Since the coastlineWorldFine dataset in the ocedata package contains about 0.5 million points, I thought I would explore how much better the mapdata coastline might be.

Methods

First, I wrote the following C file to translate the data to something that R can read.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
char *file = "/Users/kelley/mapdata/src/worldHires.line";
int main()
{
char tok1[100], tok2[100]; // needn't be anywhere near that long
FILE *in = fopen(file, "r");
int ok;
int count = 0;
int skip = 1;
while (1) { //count++ < n) {
if (skip) {
fscanf(in, "%s", tok1);
if (feof(in))
return(0);
fscanf(in, "%s", tok2);
printf("NA NA\n");
skip = 0;
} else {
fscanf(in, "%s", tok1);
if (tok1[0] == '
E') {
skip = 1;
} else {
fscanf(in, "%s", tok2);
printf(" %s %s\n", tok1, tok2);
}
}
}
}

Then, I created a datafile for plotting. It turns out that mapdata numbers are in radians, so a conversion was required.

I plotted this “new” dataset and the “old” one (containined in ocedata) and the results are shown below.

Results

center

Conclusions

There are some differences between the two, but nothing dramatic (e.g. no Northwest Arm of Halifax Harbour). Certainly it would be difficult to argue for exapanding the memory footprint of ocedata by a factor of 4.

This website is written in Jekyll, and the source is available on GitHub.