[R] looking for a basic spatial diff function

McClatchie, Sam (PIRSA-SARDI) mcclatchie.sam at saugov.sa.gov.au
Wed Jan 19 02:52:41 CET 2005


Background:
OS: Linux Mandrake 10.1
release: R 2.0.0
editor: GNU Emacs 21.3.2
front-end: ESS 5.2.3
---------------------------------

Colleagues

Is there a function to calculate distances between adjacent latitude/
longitude pairs in a matrix? It is basically a spatial diff() function that
I have in mind.

Data:

long1, lat1
long2, lat2
long3, lat3

looking for: diff(data$long, data$lat)

function Result

long1, lat1
long2, lat2, distance = long/lat2 - long/lat1
long3, lat3, distance = long/lat3 - long/lat2

I've probably missed it but a search of the maillist archives and quick scan
of the packages (map*) did not solve my query. For this simple task I don't
really want to get into GRASS.

Best fishes

Sam
----
Sam McClatchie,
Sub-program leader, Pelagic Fisheries
South Australian Aquatic Sciences Centre
PO Box 120, Henley Beach 5022
Adelaide, South Australia
email <mcclatchie.sam at saugov.sa.gov.au>
Telephone: (61-8) 8207 5448
FAX: (61-8) 8200 2481
Research home page <http://www.members.iinet.net.au/~s.mcclatchie/>
  
                   /\
      ...>><xX(°> 
                //// \\\\
                   <°)Xx><<
              /////  \\\\\\
                        ><(((°> 
  >><(((°>   ...>><xX(°>O<°)Xx><<




More information about the R-help mailing list