Re: [R] from long/lat to UTM

From: Greg Snow <>
Date: Fri 11 Mar 2005 - 04:28:00 EST

>>> Ted Harding <> 03/10/05 09:13AM >>>

>> On 10-Mar-05 Gabor Grothendieck wrote:
>> > <Ted.Harding <at>> writes:
>> >: [...]
>> >: As Sander says, "Not sure where you would derive the time
>> >:


>> The only completely general mechanism I can think of would
>> consist of
>> a) a named list of boundary contours

I found a shapefile of time zones at:

A google search on the keywords timezone & shapefile finds a few other possibilities.

>> b) a function which, for each name in the list, returns
>> the TZ name

The "maptools" package can read in the above shapefile and convert it to a list of polygons and the "sgeostat" has an "in.polygon" function to see if a point is in a given polygon.

The following code worked for me:

tz <- read.shape('c:/maps/WrldTZA')
plot(tz,xlim=c(-150,-50), ylim=c(20,50))

mappoly <- Map2poly(tz)


tmp <- sapply(mappoly, function(x){ x <- na.exclude(x)

        in.polygon( -110, 42, x[,1], x[,2] ) } )


the -110 and 42 come from me plotting the map and using locator to approximate where I am at. I was actually suprized at how quick the sapply was (under a second on my fairly fast pc (windows 2000)).

It shouldn't be too hard to convert this into a more general function.

Greg Snow, Ph.D.
Statistical Data Center
(801) 408-8111 mailing list PLEASE do read the posting guide! Received on Fri Mar 11 04:32:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:42 EST