Making interactive plot of time series rasterbrick using R - r

My goal is to make an interactive plot of rain radar time serie, I want to is display the raster layer I want through a scroll bar in the plot area, or with HTML output like dygraph can do.
For now, I use the raster, levelplot and animate packages to make a gif of the event (with sp to add shapefile), but the result is not very good for my use of it, and not pretty.
Is that possible and how?
I tried to use the htmlwidget and leaflet without success. They do not allow the multiband raster except for RGB purpose. so when I tried, it gaves me the sum of all the layers in one.
I don't know what script I could give to help you. Ask me if you need something.

Related

Can I create a target zone on my time series plots in R?

I've created a time series plot in R using the ggplot package, but I wanted to see if I could further customize it by creating target zones. I originally started with an Excel plot that allows me to move a gray box to different areas of the plot as an easier way to point out a range of temperatures. However, I wanted to see if I could replicate this in R. Here's a screenshot of my Excel plot to better explain my goal: Time Series on Excel. On the time series plot, you can see a gray box that you can drag around and change the size of to better define a range of temperatures (in this case, it covers from 15-25C). Is this possible to do on top of my time series plot in R? I'm only starting to code in R so it's been quite hard for me to navigate, and I appreciate any help I could get. Thanks!

Overlay plot on map background in R

I want to make a windrose plot on a specific location. Windrose can be plot with openair package
library(openair)
windRose(mydata, "ws", "wd")
or with ggplot using this function. What I am looking for, a nice way to overlay this plot on a map. I tried with ggmap (I don't have a google map API key) and leaflet. This example also I tried, the output is below.
Is there a way to overlay ggplot on leaflet map or any other ggmap way to do it nicely.
That is a multi-step process and will take a bit of tweaking to make it work the way you want but it can be done in 3 steps.
Set the background of your chart to transparent
Save a png locally
Use addLogo() from mapview package to post the image to your map and place it
For sure you will need to problem solve some as you implement this process. If you are doing this in Shiny you would want to use directory management to create and destroy the plots as data updates and be sure to make the creation of the graph reactive or observed in some way.
If you are making a nice rMarkdown dashboard, just make sure you keep track of where the png file saves and use the proper addressing.

Overlay Plots : Time Series - Different Frequencies (Lines over Bars) [ggplot2]

My question is about overlaying plots of different x and y scales .The raw data is out of a public weather database in New Zealand called CliFlo, managed by NIWA. I'm not prepared to copy the data for an example because of copyright protections.
I want to reproduce the types of graphs they offer at a fee, shown on this web page. Take the Rainfall graph. There is a cumulative rainfall line graph overlayed on top of a monthly rainfall bar graph. I can generate each graph separately using ggplot2, but I can't find a good way to overlay them like in the example. I've found the gridExtra package to let me print them side-by-side, and I've come across the magick package that might let me do the job, but I'm not sure on how to get the plots lined up properly and how to use the magick package properly. Can anybody help me out on this?
Should I try to scale the month bars to fit the daily line graph but make them spaced out and thicker so they look like months, or would it be easier to use the magick package somehow?
I'd attach an image of what I have so far, but I'm new to this website and it won't let me yet.

Defining polygon coordinates with a predefined image and plotting in R

Here is what I need: I have an image and want to plot on specific rectangle-shaped parts of it (e.g., imagine having a picture of a chessboard and wanting to fill every square with a different color). I would like to be able to easily specify the coordinates for these parts and take these coordinates into R for plotting.
I don't have any experience with making such plots. I've thought of simply inserting an image into a plot with rasterImage (), then plotting with polygon (), but the task of setting up the coordinates for the polygon function seemed too time consuming - hence the question above.
If you have any better ideas than using a set of coordinates for the polygon function, please share. Any leads or packages suggestions would also be helpful.
thank you. Marko.

plotting points on top of image in R

These days I am extensively using R to scatter plots.
Most of the plotting is concerned with image processing,
Recently I was thinking of plotting the scatter plots over an image.
For example, I want something like this,
The background needs to be filled with my image. With a particular scale.
And I should be able to draw points (co-ordinates) on top of this image ...
Is this possible in R?
If not, do you guys know of any other tool that makes this easy ...
I'm not 100% sure what you have in mind, but I think first you want to load and plot an image in R. You can do that with the ReadImages package:
picture <- read.jpeg("avatar.jpg")
plot(picture)
Then you can do a scatter plot on top of it:
points(runif(50,0, 128), runif(50,0,128))
A step-by-step tutorial to this kind of plotting is in the R-wiki

Resources