Exercise 1

Read the dataset 3_2a.txt in, and try to create the showed time series plot

library(readr)
library(ggplot2)
datat=data.frame(read_csv("3_2a.txt"))
## Parsed with column specification:
## cols(
##   Lat = col_double(),
##   Long = col_double(),
##   Time = col_time(format = ""),
##   Date = col_date(format = ""),
##   pm10 = col_double(),
##   TimeTotal = col_double()
## )
plot(type="l",main="Time Series Plotting", xlab="Time",ylab="pm10",strptime(datat$Time, format="%H:%M"), datat$pm10)

ggplot(datat, aes(datat$Time,datat$pm10)) + geom_line() +labs(x = "Time",y="pm10", title="Time Series Plotting")

Exercise 2

For the following plot use the same dataset; you may want to use segments to color line segments according to their pm10 value (where pm10 is linearly mapped into sf::sf.colors(10))

(colores=rev(sf::sf.colors(10)))
##  [1] "#FFF50AFF" "#FFCC33FF" "#FFA35CFF" "#FF7A85FF" "#FF50AFFF"
##  [6] "#C527D8FF" "#8500FFFF" "#4500FFFF" "#0400FFFF" "#0000B3FF"
(rangeCol=100*seq(0,max(datat$pm10),length.out=10))
##  [1]  0.000000  1.222222  2.444444  3.666667  4.888889  6.111111  7.333333
##  [8]  8.555556  9.777778 11.000000
plot(datat$Long,datat$Lat, col=colores,main="Segments Plot", xlab="Lon",ylab="Lat")

s <- seq(length(datat$pm10)-1)
s <- s[-length(s)]

segments(datat$Long[s], datat$Lat[s], datat$Long[s+2], datat$Lat[s+2],rep(colores, rangeCol), lwd = 5)

Exercise 3

Try to reproduce the following plot, where pixel values were mapped into grey((9:0)/10) for the first band of L7_ETMs.tif

library(stars)
## Loading required package: abind
## Loading required package: sf
## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(sf)

tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)
colorsGrey=(grey((9:0)/10))
colorsGrey
##  [1] "#E6E6E6" "#CCCCCC" "#B3B3B3" "#999999" "#808080" "#666666" "#4D4D4D"
##  [8] "#333333" "#1A1A1A" "#000000"
plot(x[,,,1], col=colorsGrey, breaks=c(seq(47,255,length.out = 11)))