Opened 12 years ago
Closed 6 years ago
#998 closed enhancement (fixed)
R demo portion fails, add more geo packages
Reported by: | darkblueb | Owned by: | barryrowlingson |
---|---|---|---|
Priority: | normal | Milestone: | OSGeoLive12.0 |
Component: | OSGeoLive | Keywords: | R |
Cc: | live-demo@… |
Description
due to a missing dependency maps
> library(gstat) > demo(wind) demo(wind) ---- ~~~~ Type <Return> to start : > #pdf("wind.pdf") > library(gstat) > library(rgdal) Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.9.1, released 2012/05/15 Path to GDAL shared files: /usr/share/gdal/1.9 Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470] Path to PROJ.4 shared files: (autodetected) > library(maptools) Loading required package: foreign Checking rgeos availability: FALSE Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib, which has a restricted licence. It is disabled by default; to enable gpclib, type gpclibPermit() > # load wind data, run test: > example(wind) wind> data(wind) wind> summary(wind) year month day RPT Min. :61.0 Min. : 1.000 Min. : 1.00 Min. : 0.67 1st Qu.:65.0 1st Qu.: 4.000 1st Qu.: 8.00 1st Qu.: 8.12 Median :69.5 Median : 7.000 Median :16.00 Median :11.71 Mean :69.5 Mean : 6.523 Mean :15.73 Mean :12.36 3rd Qu.:74.0 3rd Qu.:10.000 3rd Qu.:23.00 3rd Qu.:15.92 Max. :78.0 Max. :12.000 Max. :31.00 Max. :35.80 VAL ROS KIL SHA Min. : 0.21 Min. : 1.50 Min. : 0.000 Min. : 0.13 1st Qu.: 6.67 1st Qu.: 8.00 1st Qu.: 3.580 1st Qu.: 6.75 Median :10.17 Median :10.92 Median : 5.750 Median : 9.96 Mean :10.65 Mean :11.66 Mean : 6.306 Mean :10.46 3rd Qu.:14.04 3rd Qu.:14.67 3rd Qu.: 8.420 3rd Qu.:13.54 Max. :33.37 Max. :33.84 Max. :28.460 Max. :37.54 BIR DUB CLA MUL Min. : 0.000 Min. : 0.000 Min. : 0.000 Min. : 0.000 1st Qu.: 4.000 1st Qu.: 6.000 1st Qu.: 5.090 1st Qu.: 5.370 Median : 6.830 Median : 9.210 Median : 8.080 Median : 8.170 Mean : 7.092 Mean : 9.797 Mean : 8.494 Mean : 8.496 3rd Qu.: 9.670 3rd Qu.:12.960 3rd Qu.:11.420 3rd Qu.:11.210 Max. :26.160 Max. :30.370 Max. :31.080 Max. :25.880 CLO BEL MAL Min. : 0.040 Min. : 0.13 Min. : 0.67 1st Qu.: 5.330 1st Qu.: 8.71 1st Qu.:10.71 Median : 8.290 Median :12.50 Median :15.00 Mean : 8.707 Mean :13.12 Mean :15.60 3rd Qu.:11.630 3rd Qu.:16.88 3rd Qu.:19.83 Max. :28.210 Max. :42.38 Max. :42.54 wind> wind.loc Station Code Latitude Longitude MeanWind 1 Valentia VAL 51d56'N 10d15'W 5.48 2 Belmullet BEL 54d14'N 10d00'W 6.75 3 Claremorris CLA 53d43'N 8d59'W 4.32 4 Shannon SHA 52d42'N 8d55'W 5.38 5 Roche's Point RPT 51d48'N 8d15'W 6.36 6 Birr BIR 53d05'N 7d53'W 3.65 7 Mullingar MUL 53d32'N 7d22'W 4.38 8 Malin Head MAL 55d22'N 7d20'W 8.03 9 Kilkenny KIL 52d40'N 7d16'W 3.25 10 Clones CLO 54d11'N 7d14'W 4.48 11 Dublin DUB 53d26'N 6d15'W 5.05 12 Roslare ROS 52d16'56.791"N 6d21'25.056"W 6.00 wind> wind.loc$y = as.numeric(char2dms(as.character(wind.loc[["Latitude"]]))) wind> wind.loc$x = as.numeric(char2dms(as.character(wind.loc[["Longitude"]]))) wind> coordinates(wind.loc) = ~x+y wind> # fig 1: wind> ## No test: wind> if (require(mapdata)) { wind+ map("worldHires", xlim = c(-11,-5.4), ylim = c(51,55.5)) wind+ plot(wind.loc, add=TRUE, pch=16) wind+ text(coordinates(wind.loc), pos=1, label=wind.loc$Station) wind+ } Loading required package: mapdata wind> ## End(No test) wind> wind$time = ISOdate(wind$year+1900, wind$month, wind$day) wind> # time series of e.g. Dublin data: wind> plot(DUB~time, wind, type= 'l', ylab = "windspeed (knots)", main = "Dublin") Hit <Return> to see next plot: wind> # fig 2: wind> #wind = wind[!(wind$month == 2 & wind$day == 29),] wind> wind$jday = as.numeric(format(wind$time, '%j')) wind> windsqrt = sqrt(0.5148 * as.matrix(wind[4:15])) wind> Jday = 1:366 wind> windsqrt = windsqrt - mean(windsqrt) wind> daymeans = sapply(split(windsqrt, wind$jday), mean) wind> plot(daymeans ~ Jday) Hit <Return> to see next plot: wind> lines(lowess(daymeans ~ Jday, f = 0.1)) wind> # subtract the trend: wind> meanwind = lowess(daymeans ~ Jday, f = 0.1)$y[wind$jday] wind> velocity = apply(windsqrt, 2, function(x) { x - meanwind }) wind> # match order of columns in wind to Code in wind.loc: wind> pts = coordinates(wind.loc[match(names(wind[4:15]), wind.loc$Code),]) wind> # fig 3, but not really yet... wind> dists = spDists(pts, longlat=TRUE) wind> corv = cor(velocity) wind> sel = !(as.vector(dists) == 0) wind> plot(as.vector(corv[sel]) ~ as.vector(dists[sel]), wind+ xlim = c(0,500), ylim = c(.4, 1), xlab = "distance (km.)", wind+ ylab = "correlation") Hit <Return> to see next plot: wind> # plots all points twice, ignores zero distance wind> wind> # now really get fig 3: wind> ros = rownames(corv) == "ROS" wind> dists.nr = dists[!ros,!ros] wind> corv.nr = corv[!ros,!ros] wind> sel = !(as.vector(dists.nr) == 0) wind> plot(as.vector(corv.nr[sel]) ~ as.vector(dists.nr[sel]), pch = 3, wind+ xlim = c(0,500), ylim = c(.4, 1), xlab = "distance (km.)", wind+ ylab = "correlation") Hit <Return> to see next plot: wind> # add outlier: wind> points(corv[ros,!ros] ~ dists[ros,!ros], pch=16, cex=.5) wind> xdiscr = 1:500 wind> # add correlation model: wind> lines(xdiscr, .968 * exp(- .00134 * xdiscr)) > m = map2SpatialLines( + map("worldHires", xlim = c(-11,-5.4), ylim = c(51,55.5), plot=F)) Loading required package: maps Error in cbind(map$x, map$y) : could not find function "map" In addition: Warning messages: 1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘mapdata’ 2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘maps’
Change History (23)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Type: | defect → enhancement |
comment:3 by , 12 years ago
Summary: | R demo portion fails → R demo portion fails, add more geo packages |
---|
comment:4 by , 12 years ago
Milestone: | OSGeoLive6.5 → OSGeoLive7.0 |
---|
Barry, +1, this is a wontfix for 6.5.
comment:5 by , 12 years ago
Cc: | added |
---|
please move the ML email addr from the owner field if you take ownership of a ticket so it doesn't get lost
comment:7 by , 11 years ago
Milestone: | OSGeoLive7.9 → OSGeoLive8.0 |
---|
comment:8 by , 10 years ago
Milestone: | OSGeoLive8.0 → OSGeoLive8.5 |
---|
comment:9 by , 10 years ago
Milestone: | OSGeoLive8.5 → OSGeoLive9.0 |
---|
comment:10 by , 9 years ago
This ticket is inactive for a while, but the generic title "add more geo packages" somewhat covers my following question. If I should start a new ticket for this I'll do it!
I would like to add a package to the list of installed R packages , namely sos4R (https://cran.r-project.org/web/packages/sos4R/). It would very nicely connect R with the 52°North SOS that is also on the live DVD. Afaics I would only need to extend the list of installed packages (https://github.com/OSGeo/OSGeoLive/blob/master/app-conf/R/installRpackages.r). Then I would extend the quickstart of the 52°North SOS with a few lines of R to demonstrate the package and add a new demo to the package that more extensively uses the locally available SOS and its data.
Any comments are highly appreciated!
comment:11 by , 9 years ago
Thank you for the proposed improvement. Can you please make a pull request so we can test this?
Thanks, Angelos
comment:12 by , 9 years ago
Milestone: | OSGeoLive9.0 → OSGeoLive9.5 |
---|
Ticket retargeted after milestone closed
comment:13 by , 8 years ago
Milestone: | OSGeoLive9.5 → OSGeoLive10.0 |
---|
Ticket retargeted after milestone closed
comment:14 by , 8 years ago
Milestone: | OSGeoLive10.0 → OSGeoLive10.5 |
---|
Ticket retargeted after milestone closed
comment:15 by , 7 years ago
Milestone: | OSGeoLive10.5 → OSGeoLive11.0 |
---|
Ticket retargeted after milestone closed
comment:16 by , 7 years ago
rOpenSci Community involvement; great progress, however sf
does not build cleanly yet.
comment:17 by , 7 years ago
Milestone: | OSGeoLive11.0 → OSGeoLive12.0 |
---|
comment:18 by , 7 years ago
@kalxas: I think we can close it if we improve the R quickstart with Tina and Etienne
comment:22 by , 6 years ago
12dev beta3
R Quickstart updated to use
sf
andggplot2
minimal R Notebook installed; R sf project info page added
comment:23 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
OSGeoLive PR 238 [1] and OSGeoLive 12.0 release add more spatial capabilities to R. OSGeolive PR 240 [2] add a notebook with mapping with R
OSGeoLive-doc PR 424 [3] fix R quickstart.
Closing this long overdue ticket.
[1] https://github.com/OSGeo/OSGeoLive/pull/238
Actually the demo(wind) doesn't fail, it correctly checks for the presence of the mapdata package and skips the section if its not there. mapdata is only a 'suggested' dependency for gstat, and the 'maps' package is a dependency of that.
The R packaging system allows packages to say another package is not criticial, its just used for demos or documentation. I don't see this as a defect.
However... some of us have been scheming about improving the R component of the live-DVD by including more of the spatial packages so we can do groovy things like drawing cute maps on OSM tiles and so on. The maps package would probably be nice to have too. But it can pull in a large dataset in its own special format in the mapdata package...
Perhaps I should open a new ticket for that enhancement process? I think this one is a 'wontfix'?