0

`Hi everyone,

I have a really big database (more than 80,000 arrows) with latitud and longitud coordinate which correspond mainly to African Continent, and I was interested in calculate the distance to coast for each coordinate. I wonder if this simulation is possible and in that case what the best form to do it.

In case the time of simulation is very long, is it more appropiate to use other language like fortran or c++?

Thank you!`

Richard
  • 56,349
  • 34
  • 180
  • 251
Isaac
  • 1

1 Answers1

1

The answer depends somewhat on what speed you need, and what accuracy.

The fastest method I know of I describe in my paper "Optimal orientations of discrete global grids and the Poles of Inaccessibility" (free pdf here).

The idea is that you acquire:

  • a coastline database such as GSHHG
  • do WGS84 interpolation between all the coastline points to ensure that there's no more than X metres between any two points
  • Convert the WGS84 coordinates into xyz coordinates
  • Place all the points into a k-d tree so you get logarithmic lookups
  • For each query point, convert that point into xyz, and then retrieve the nearest point from the k-d tree
  • Using the lat-long coordinates of the query point and the point retrieved from the k-d tree, calculate the WGS84 distance between the two. This is the distance to the nearest coastline.

C++ code for performing the above is available here.

Slower, prepackaged methods in R are listed in this answer.

Richard
  • 56,349
  • 34
  • 180
  • 251