metno / esd

An R-package designed for climate and weather data analysis, empirical-statistical downscaling, and visualisation.
88 stars 30 forks source link

How to plot values of an object of class 'station' inside a map? #222

Closed MeJitendra closed 7 years ago

MeJitendra commented 7 years ago

In general, we get a map plot with station locations if we use the command map()

map(x) Here x is an object having 22 stations and contains mean rainfall at each stations i.e. x contains 1 value for each station. See the structure of x as below. structure(x) ‘zoo’ series from 1901-01-01 to 1901-01-01 Data: num [1, 1:22] 116 104 118 137 188 ...

  • attr(*, "dimnames")=List of 2 ..$ : chr "1901-01-01" ..$ : chr [1:22] "ALMORA" "BANJAR" "BERINAG" "BIRONKHOL" ...
  • attr(*, "location")= chr [1:22] "ALMORA" "BANJAR" "BERINAG" "BIRONKHOL" ...
  • attr(*, "variable")= chr [1:22] "precip" "precip" "precip" "precip" ...
  • attr(*, "unit")= chr [1:22] "mm/day" "mm/day" "mm/day" "mm/day" ...
  • attr(*, "longitude")= num [1:22] 79.7 77.3 80.1 79.2 76.2 ...
  • attr(*, "latitude")= num [1:22] 29.6 31.6 29.8 30.2 31.9 ...
  • attr(*, "altitude")= num [1:22] 483 463 511 520 133 106 240 214 121 544 ...
  • attr(*, "country")= chr [1:22] "INDIA" "INDIA" "INDIA" "INDIA" ...
  • attr(*, "longname")= chr [1:22] "Monthly Precipitation" "Monthly Precipitation" "Monthly Precipitation" "Monthly Precipitation" ...
  • attr(*, "station_id")= int [1:22] 1 2 3 4 5 6 7 8 9 10 ...
  • attr(*, "calendar")= chr "gregorian"
  • attr(*, "source")= chr [1:22] "IMD" "IMD" "IMD" "IMD" ...
  • attr(*, "URL")= logi NA
  • attr(*, "type")= logi NA
  • attr(*, "aspect")= chr [1:22] "original" "original" "original" "original" ...
  • attr(*, "reference")= logi NA
  • attr(*, "info")= logi NA
  • attr(*, "method")= logi NA
  • attr(*, "history")=List of 3 ..$ call :List of 1 .. ..$ : language station.subset(x, it = it, is = is, verbose = verbose) ..$ timestamp: chr "Fri Jul 28 16:27:43 2017" ..$ session :List of 3 .. ..$ R.version : chr "R version 3.1.3 (2015-03-09)" .. ..$ esd.version: chr "esd_1.5" .. ..$ platform : chr "x86_64-w64-mingw32/x64 (64-bit)" Index: Date[1:1], format: "1901-01-01"

I want to plot an image like the follow. image

map(x) gives the following map image Please help in this regard.

abdelkaderm commented 7 years ago

Hi Jitendra,

sorry for the delay. You need to specify the 'FUN' argument in map function. sth like

map(x,FUN='mean')

than the mean values of x will appear with colors regarding the classed of your values. You may also need to specify few argument in the colorbar (argument colbar) if you have more specific requirements.

Bests,

MeJitendra commented 7 years ago

Thank you Sir. That helped me. :)