[R] maptools sunrise sunset function

stephen sefick ssefick at gmail.com
Mon Nov 10 21:27:52 CET 2008

sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
       #this needs to be long lat#
       lat.long <- matrix(c(long, lat), nrow=1)
       day <- as.POSIXct(date, tz=timezone)
       sequence <- seq(from=day, length.out=num.days , by="days")
       sunrise <- sunriset(lat.long, sequence, direction="sunrise",
       sunset <- sunriset(lat.long, sequence, direction="sunset", POSIXct=TRUE)
       ss <- data.frame(sunrise, sunset)
       ss <- ss[,-c(1,3)]
       colnames(ss)<-c("sunrise", "sunset")

I believe that he is refering to the code that I wrote above, which
relies heavily on map tools (to say the least).

On Mon, Nov 10, 2008 at 3:21 PM, Sebastian P. Luque <spluque at gmail.com> wrote:
> On Mon, 10 Nov 2008 11:20:03 -0800,
> "Farley, Robert" <FarleyR at metro.net> wrote:
>> I have a time zone problem.  Running the code provided I get the
>> result in UTC, and a lot of warnings like this: 28: In
>> as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'
>>> sunrise.set(34.11583, -118.18719, "2008-11-14")
>>                    sunrise sunset newlon 2008-11-14 14:25:02
>> 2008-11-15 00:49:09
> That function doesn't exist in maptools, but I guess you're referring to
> sunriset().  Even with that assumption, I get:
> ---<---------------cut here---------------start-------------->---
> R> sunriset(34.11583, -118.18719, "2008-11-14")
> Error in function (classes, fdef, mtable)  :
>  unable to find an inherited method for function "sunriset", for signature "numeric", "numeric"
> ---<---------------cut here---------------end---------------->---
> Doesn't look like a time zone issue at all.  Can you show something we
> can all run on our systems as per the posting guide?  That would save us
> lots of time.
> --
> Seb
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis

More information about the R-help mailing list