Sandbox: Difference between revisions
Juha Villman (talk | contribs) No edit summary |
|||
(51 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
<math> | |||
\alpha + 444444 + \beta + \omega | |||
</math> | |||
jepjepjepjep | |||
[[:File:aditro.PNG]] | |||
[[Image:kuvatiedostonmitähäan.jpg]] | |||
<display_map type="terrain"> | |||
62.904602, 27.647781 | |||
62.891918, 27.680013 | |||
</display_map> | |||
{{mfiles}} | |||
<t2b index="Make" unit="kg" desc="Description"> | |||
Lata|100| | |||
Toyota|88|Toijota | |||
</t2b> | |||
{{variable|moderator=Ehac}} | {{variable|moderator=Ehac}} | ||
mitä tapahtuu! | |||
<math>\alpha + 8884444</math> | |||
<math> | <math> | ||
\textstyle | |||
L_{Aeq} = 10 \log \int_{t_0}^{t_1} \frac{p_A^2(t)}{p_0^2} dt | L_{Aeq} = 10 \log \int_{t_0}^{t_1} \frac{p_A^2(t)}{p_0^2} dt | ||
Line 10: | Line 37: | ||
</math> | </math> | ||
== Live Code Test == | |||
<rcode live=1 graphics=1 name='live_test' variables='name:breaks|description:Breaks|options:10;10;20;20;35;35;50;50|type:selection|default:10'> | |||
hist(faithful$eruptions, | |||
probability = TRUE, | |||
breaks = as.numeric(breaks), | |||
xlab = "Duration (minutes)", | |||
main = "Geyser eruption duration") | |||
</rcode> | |||
== Sotkanet == | |||
<rcode name='sotkanet_test'> | |||
library(OpasnetUtils) | |||
library(OpasnetUtilsExt) | |||
# collect makes a data.frame out of the list object from Sotkanet | |||
# x is the input data | |||
# name is the name for the column | |||
# single is a logical whether there is only a single entry in the x data. | |||
collect <- function(x, name, single = FALSE) { | |||
out <- data.frame() | |||
if(single) {out <- data.frame(temp1 = x$id, temp2 = x$title$fi) | |||
} else { | |||
for(i in 1:length(x)) { | |||
out <- rbind(out, data.frame(temp1 = x[[i]]$id, temp2 = x[[i]]$title$fi)) | |||
} | |||
} | |||
colnames(out) <- c(name, paste(name, "Result", sep="")) | |||
return(out) | |||
} | |||
a <- sotkanet.indicators() | |||
# print(a) | |||
b <- sotkanet.indicators(127) | |||
b <- collect(b, "indicator", TRUE) | |||
# print(xtable(b), type = 'html') | |||
d <- sotkanet.regions() | |||
d <- collect(d, "region") | |||
# print(xtable(d), type = 'html') | |||
e <- sotkanet.data(indicator=127,years=c(2011,2010),genders='female') | |||
e <- merge(b, e) | |||
e <- merge(d, e) | |||
oprint(e) | |||
</rcode> | |||
== Objects save test == | |||
<rcode name='objs_save_test'> | |||
library(OpasnetUtils) | |||
x <- stats::runif(20) | |||
y <- list(a = 1, b = TRUE, c = "Jeah baby jeah!") | |||
objects.store(x, y, verbose=TRUE) | |||
</rcode> | |||
==Giving tables via user interface== | |||
<rcode embed="1" variables="name:test|type:table"> | |||
library(OpasnetUtils) | |||
oprint(test) | |||
</rcode> | |||
== ovariable merge testing == | |||
<rcode> | |||
library(OpasnetUtils) | |||
aa <- new("ovariable", output = data.frame(dummy=NA)) | |||
bb <- new("ovariable", output = data.frame(a=1:4)) | |||
#cc <- new("ovariable", output = data.frame(a=1:4)) | |||
cc <- '' | |||
test <- Ovariable( | |||
name='test', | |||
dependencies = data.frame( | |||
Name = c("aa", "bb", "cc"), | |||
Ident = c(NA, NA, NA) | |||
), | |||
formula = function(dependencies, ...) { | |||
ComputeDependencies(dependencies, ...) | |||
out <- merge(aa, bb) | |||
return(out) | |||
} | |||
) | |||
oprint(test) | |||
</rcode> | |||
== Static GoogleMaps test == | |||
<rcode name='staticmapstest' graphics='1'> | |||
#code goes here | |||
library(RgoogleMaps) | |||
library(rgdal) | |||
library(maptools) | |||
library(RColorBrewer) | |||
library(classInt) | |||
library(OpasnetUtils) | |||
library(OpasnetUtilsExt) | |||
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house') | |||
plotvar<-shp@data$ika | |||
nclr<-8 | |||
plotclr<-brewer.pal(nclr,"Spectral") | |||
class<-classIntervals(plotvar,nclr,style="quantile") | |||
colcode<-findColours(class,plotclr) | |||
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") | |||
proj4string(shp)<-("+init=epsg:3067") | |||
shp2<-spTransform(shp,epsg4326String) | |||
#get marker information first 10 points | |||
mymarkers<-cbind.data.frame(lat=c(shp2@coords[,2]),lon=c(shp2@coords[,1]),color=colcode); | |||
< | #get the bounding box: | ||
\ | bb <- qbbox(lat = mymarkers[,"lat"], lon = mymarkers[,"lon"]) | ||
#MyMap function without the "file destination" parameter | |||
MyRmap<-function (lonR, latR, center, size = c(640, 640), | |||
MINIMUMSIZE = FALSE, RETURNIMAGE = TRUE, GRAYSCALE = FALSE, | |||
NEWMAP = TRUE, zoom, verbose = 1, ...) | |||
{ | |||
if (missing(zoom)) | |||
zoom <- min(MaxZoom(latR, lonR, size)) | |||
if (missing(center)) { | |||
lat.center <- mean(latR) | |||
lon.center <- mean(lonR) | |||
} | |||
else { | |||
lat.center <- center[1] | |||
lon.center <- center[2] | |||
} | |||
if (MINIMUMSIZE) { | |||
ll <- LatLon2XY(latR[1], lonR[1], zoom) | |||
ur <- LatLon2XY(latR[2], lonR[2], zoom) | |||
cr <- LatLon2XY(lat.center, lon.center, zoom) | |||
ll.Rcoords <- Tile2R(ll, cr) | |||
ur.Rcoords <- Tile2R(ur, cr) | |||
if (verbose > 1) { | |||
cat("ll:") | |||
print(ll) | |||
print(ll.Rcoords) | |||
cat("ur:") | |||
print(ur) | |||
print(ur.Rcoords) | |||
cat("cr:") | |||
print(cr) | |||
} | |||
size[1] <- 2 * max(c(ceiling(abs(ll.Rcoords$X)), ceiling(abs(ur.Rcoords$X)))) + | |||
1 | |||
size[2] <- 2 * max(c(ceiling(abs(ll.Rcoords$Y)), ceiling(abs(ur.Rcoords$Y)))) + | |||
1 | |||
if (verbose) | |||
cat("new size: ", size, "\n") | |||
} | |||
return(GetMap(center = c(lat.center, lon.center), zoom = zoom, | |||
size = size, RETURNIMAGE = RETURNIMAGE, | |||
GRAYSCALE = GRAYSCALE, verbose = verbose, ...)) | |||
} | |||
MyMap<-MyRmap(bb$lonR,bb$latR,maptype="mobile") | |||
PlotOnStaticMap(MyMap) | |||
PlotOnStaticMap(MyMap,lat=mymarkers[,"lat"],lon=mymarkers[,"lon"],pch=19,cex=0.3,col=colcode,add=T) | |||
</ | legend("topleft", legend=names(attr(colcode, "table")),title="Ika", fill=attr(colcode, "palette"), cex=1.0, bty="y",bg="white") | ||
</rcode> | |||
== Kuopio buildings on Google maps test == | == Kuopio buildings on Google maps test == | ||
<rcode name='kuorakonmaps'> | <rcode name='kuorakonmaps' variables="name:age|description:Building minimum age|default:100"> | ||
library(rgdal) | library(rgdal) | ||
Line 26: | Line 231: | ||
library(RColorBrewer) | library(RColorBrewer) | ||
library(classInt) | library(classInt) | ||
library( | library(OpasnetUtils) | ||
library(OpasnetUtilsExt) | |||
library(RODBC) | |||
shp <- spatial_db_query(paste('SELECT * FROM kuopio_house WHERE ika >= ',age,';',sep='')) | |||
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house') | coordinates(shp)=c("y_koord","x_koord") | ||
#shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house') | |||
plotvar<-shp@data$ika | plotvar<-shp@data$ika | ||
nclr<-8 | nclr<-8 | ||
Line 43: | Line 254: | ||
kmldescription<-"Random stuff about here" | kmldescription<-"Random stuff about here" | ||
icon<-"http://maps.google.com/mapfiles/kml/pal2/icon18.png" | icon<-"http://maps.google.com/mapfiles/kml/pal2/icon18.png" | ||
name<-paste(" | name<-paste("Value: ",shp2$ika) | ||
description <- paste("<b> | description <- paste("<b>Ikä:</b>",shp2$ika,"<br><b>Rakennustunnus:</b>",shp2$rakennustunnus) | ||
MyPointKML<-function(obj = NULL, kmlname = "", kmldescription = "", name = NULL, description = "", icon = "http://maps.google.com/mapfiles/kml/pal4/icon24.png",col=NULL) | MyPointKML<-function(obj = NULL, kmlname = "", kmldescription = "", name = NULL, description = "", icon = "http://maps.google.com/mapfiles/kml/pal4/icon24.png",col=NULL) | ||
Line 63: | Line 273: | ||
i)) | i)) | ||
} | } | ||
col2kmlcolor <- function(col) paste(rev(sapply(col2rgb(col, TRUE), function(x) sprintf("%02x", x))), collapse = "") | col2kmlcolor <- function(col) paste(rev(sapply(col2rgb(col, TRUE), function(x) sprintf("%02x", x))), collapse = "") | ||
kml <- kmlStyle <- "" | kml <- kmlStyle <- "" | ||
kmlHeader <- c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","<kml xmlns=\"http://earth.google.com/kml/2.2\">", "<Document>") | kmlHeader <- c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","<kml xmlns=\"http://earth.google.com/kml/2.2\">", "<Document>") | ||
kmlFooter <- c("</Document>", "</kml>") | kmlFooter <- c("</Document>", "</kml>") | ||
for (i in 1:nrow(obj)) { | |||
point <- obj[i, ] | point <- obj[i, ] | ||
pt_name = name[i] | pt_name = name[i] | ||
Line 114: | Line 309: | ||
</rcode> | </rcode> | ||
== GoogleMaps Sorvi MML TEST == | |||
<rcode name='gmapspsqltest3'> | <rcode name='gmapspsqltest3'> | ||
library( | library(OpasnetUtils) | ||
library(OpasnetUtilsExt) | |||
library(sorvi) | library(sorvi) | ||
library(rgdal) | library(rgdal) | ||
Line 146: | Line 341: | ||
</rcode> | </rcode> | ||
== GoogleMaps PostgreSQL test 2 == | |||
<rcode name='gmapspsqltest2'> | <rcode name='gmapspsqltest2'> | ||
Line 154: | Line 349: | ||
library(RColorBrewer) | library(RColorBrewer) | ||
library(classInt) | library(classInt) | ||
library( | library(OpasnetUtils) | ||
library(OpasnetUtilsExt) | |||
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','watson_wkt') | shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','watson_wkt') | ||
Line 181: | Line 377: | ||
</rcode> | </rcode> | ||
== GoogleMaps PostgreSQL test == | |||
<rcode name='gmapspsqltest'> | <rcode name='gmapspsqltest'> | ||
library( | library(OpasnetUtils) | ||
cat(" | library(OpasnetUtilsExt) | ||
cat("PostgreSQL Test\n") | |||
google.show_data_on_maps() | google.show_data_on_maps() | ||
google.show_data_on_maps(table='kuopio_house',database='spatial_db',fields=c('ika','ika','the_geom')) | |||
</rcode> | </rcode> | ||
== Opasnet.csv test == | |||
<rcode name='opcsvtest'> | <rcode name='opcsvtest'> | ||
library( | library(OpasnetUtils) | ||
csv <- opasnet.csv("2/25/Russian_elections_2011_results.csv") | csv <- opasnet.csv("2/25/Russian_elections_2011_results.csv") | ||
Line 200: | Line 401: | ||
</rcode> | </rcode> | ||
== Opasnet.data and BUGS test == | |||
<rcode name='odabugstest' graphics=1> | <rcode name='odabugstest' graphics=1> | ||
library( | library(OpasnetUtils) | ||
pumps.model <- opasnet.data('c/cc/Test_bugs_model.txt') | pumps.model <- opasnet.data('c/cc/Test_bugs_model.txt') | ||
Line 254: | Line 455: | ||
<br> {{greenbox| | <br> {{greenbox| | ||
==Hello== | |||
* this works | * this works | ||
}} | }} | ||
{{bluebox| | {{bluebox| | ||
==Bluebox== | |||
* works | * works | ||
* ok | * ok | ||
Line 278: | Line 479: | ||
name:divisions2|description:Minkä yhden tekijän halua eritellä kuvaajassa?|type:selection|options:'Katalyytin määrä';Katalyytin määrä;'Ikä';Ikä;'Kastelu';Kastelu;'Käytetty puristin';Käytetty puristin|default:'Kastelu' | name:divisions2|description:Minkä yhden tekijän halua eritellä kuvaajassa?|type:selection|options:'Katalyytin määrä';Katalyytin määrä;'Ikä';Ikä;'Kastelu';Kastelu;'Käytetty puristin';Käytetty puristin|default:'Kastelu' | ||
"> | "> | ||
library( | library(OpasnetUtils) | ||
library(ggplot2) | library(ggplot2) | ||
library(xtable) | library(xtable) | ||
Line 366: | Line 567: | ||
</rcode> | </rcode> | ||
<!-- __OBI_TS: | === MassHEIS test === | ||
:''Moved to [[MassHEIS]]. | |||
=== MassHEIS test multilayer NOT WORKING YET === | |||
<rcode name='MassHEISTestML' graphics='1'> | |||
library(OpasnetUtils) | |||
library(OpasnetUtilsExt) | |||
library(ggplot2) | |||
library(rgdal) | |||
library(maptools) | |||
library(RColorBrewer) | |||
library(classInt) | |||
library(raster) | |||
data <- MassHEIS.data() | |||
# Plot the data | |||
coordinates(data)=c("longitude","latitude") | |||
proj4string(data)<-("+init=epsg:4326") | |||
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") | |||
shp<-spTransform(data,epsg4326String) | |||
start <- min(shp$anmean) | |||
end <- max(shp$anmean) | |||
rasters = list() | |||
years = c(2000,2001,2002) | |||
for(y in 1:length(years)) | |||
{ | |||
#Create blank raster | |||
rast<-raster() | |||
s <- shp[(shp$Year == years[y]),] | |||
#Set raster extent to that of point data | |||
extent(rast)<-extent(s) | |||
#Choose number of columns and rows | |||
ncol(rast) <- 64 | |||
nrow(rast) <- 64 | |||
#Rasterize point data | |||
rasters[[y]] <- rasterize(s, rast, s$anmean, fun=mean) | |||
} | |||
steps <- approx(c(start,end),n=6)$y | |||
colors <- rev(rainbow(length(steps), start=0, end=0.50)) | |||
par(mfrow=c(6,1), mar=c(3,1,0,1), cex=1.5) | |||
colorstrip <- function(colors, labels) | |||
{ | |||
count <- length(colors) | |||
m <- matrix(1:count, count, 1) | |||
image(m, col=colors, ylab="", axes=FALSE) | |||
axis(1,approx(c(0, 1), n=length(labels))$y, labels) | |||
} | |||
cat("<span style='font-size: 1.2em;font-weight:bold;'>Massachusetts annual mean PM 2.5 microns</span>\n") | |||
colorstrip(colors, steps) | |||
#Plot data | |||
s <- stack(rasters) | |||
names(s) <- c('z2000','z2001','z2002') | |||
print(s) | |||
google.show_raster_on_maps(s, col=colors, style="height:500px;") | |||
</rcode> | |||
<!-- __OBI_TS:1353932360 --> |
Latest revision as of 19:33, 17 May 2014
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha + 444444 + \beta + \omega }
jepjepjepjep
File:Kuvatiedostonmitähäan.jpg
<display_map type="terrain"> 62.904602, 27.647781 62.891918, 27.680013 </display_map>
<mfanonymousfilelist></mfanonymousfilelist>
Obs | Make | Result | Description |
---|---|---|---|
1 | Lata | 100 | |
2 | Toyota | 88 | Toijota |
Moderator:Ehac (see all) |
|
Upload data
|
mitä tapahtuu!
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha + 8884444}
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \textstyle L_{Aeq} = 10 \log \int_{t_0}^{t_1} \frac{p_A^2(t)}{p_0^2} dt }
Live Code Test
Sotkanet
Objects save test
Giving tables via user interface
ovariable merge testing
Static GoogleMaps test
Kuopio buildings on Google maps test
GoogleMaps Sorvi MML TEST
GoogleMaps PostgreSQL test 2
GoogleMaps PostgreSQL test
Opasnet.csv test
Opasnet.data and BUGS test
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha 444 + 9999 / 123}
Hello
- this works
Bluebox
- works
- ok
R-tools code include example
Rectangle area test
MassHEIS test
- Moved to MassHEIS.
MassHEIS test multilayer NOT WORKING YET