r - Convert Julian days into radians (or similar) -


i have data frame n rows each of corresponds single event in space , time. data frame has columns containing spatial coordinates , date in julian days several other columns of additional data.

there various things data example want rasterise of columns , output maps. of columns can this:

df.raster <- rasterize(df.sp, base.raster, field = "column", fun=median)  plot(df.raster) 

however, julian days doesn't make sense because cyclical. 365/366 adjacent 1 r doesn't know using median function isn't going provide me meaningful number. i'm looking way convert column of julian days new column reflects , enables me create raster of meaningful values julian day.

my julian days column runs 1-366 reflecting day on event took place within particular year. data covers multiple years julian days column starts 1 again @ start of every year.

i've tried few things including converting radians nothing has worked far. appreciated!

to wanted first had scale "julian days" column degrees, convert degrees radians using as_radians function in aspace package , use circular statistics on radians:

# scale julian days degrees  df$degrees <- (df$jday/366)*360  # convert degrees radians  df$radians <- as_radians(df$degrees)  # convert df spatial object  df.sp <- df coordinates(df.sp) <- ~ x + y proj4string(df.sp) <- proj4string(coordinates)  # rasterise radians  radians.raster <- rasterize(df.sp, base.raster, field = "radians", fun = mean.circular)  # plot rasterised radians  plot(radians.raster) 

currently figures inaccurate (when converting degrees) leap years should divided 366 , non-leap years 365 i'll fix simple loop looks year (also included in df) each row , uses 366/365 appropriately.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -