小编mil*_*now的帖子

从多变量netCDF文件创建栅格砖列表

我一直在使用RCP(代表性浓度路径)空间数据.它是netCDF格式的一个很好的网格化数据集.如何获得砖块列表,其中每个元素代表一个多变量netCDF文件中的一个变量(通过变量我不是指lat,lon,time,depth ......等).这就是我试图做的事情.我无法发布数据示例,但如果您想查看数据,我已将下面的脚本设置为可重现.显然欢迎提出问题......我可能没有顺利地表达与代码相关的语言.干杯.

答:包装要求

    library(sp)
    library(maptools)
    library(raster)
    library(ncdf)
    library(rgdal)
    library(rasterVis)
    library(latticeExtra)
Run Code Online (Sandbox Code Playgroud)

B:收集数据并查看netCDF文件结构

    td <- tempdir()
    tf <- tempfile(pattern = "fileZ")

    download.file("http://tntcat.iiasa.ac.at:8787/RcpDb/download/R85_NOX.zip", tf , mode = 'wb' )
    nc <- unzip( tf , exdir = td )
    list.files(td)

## Take a look at the netCDF file structure, beyond this I don't use the ncdf package directly

    ncFile <- open.ncdf(nc)
    print(ncFile) 
    vars <- names(ncFile$var)[1:12] # I'll try to use these variable names later to make a list of bricks
Run Code Online (Sandbox Code Playgroud)

C:为一个变量创建栅格砖.级别对应于年份

    r85NOXene <- brick(nc, …
Run Code Online (Sandbox Code Playgroud)

r raster netcdf

6
推荐指数
1
解决办法
2004
查看次数

渲染ggvis控件闪亮

我无法在闪亮的应用程序中的ggvis绘图中获取输入滑块.这些图表在没有输入滑块的情况下呈现正常但在添加它之后闪亮会抛出此错误:

Listening on http://xxxxxxxxxxxxxx
Error in eval(expr, envir, enclos) : could not find function "compdat" 
Run Code Online (Sandbox Code Playgroud)

server.R:


    library(shiny)
    library(ggvis)

    data<-data.frame(var1=rnorm(30,5,2.3),var2=rbeta(30,1.5,.8),var3=rnorm(30,10,2.5))

    shinyServer(function(input, output,session) {

    compdat<-reactive({data[, c(input$xInp,input$yInp)]}) 

    vis1 <-reactive({  

      compdat %>% ggvis(x= ~compdat()[,1],y= ~compdat()[,2]) %>% 
       layer_points(fill:="red") %>% layer_smooths(span=input_slider(.1,1,id="scores_ui"))   

    })

    vis1 %>% bind_shiny("scores",controls_id="scores_ui")

    vis2<-reactive({ 

      compdat %>% ggvis(x= ~compdat()[,1],y= ~compdat()[,2]) %>% 
       layer_points(fill:="red") %>% ayer_smooths(span=input_slider(.1,1,id="loadings_ui"))

    })

    vis2 %>% bind_shiny("loadings",controls_id="loadings_ui")

    })
Run Code Online (Sandbox Code Playgroud)

ui.R:



    shinyUI(fluidPage(

     title="PCA Explorer", 
     h2("Principal Component Explorer"),

     fluidRow(
      column(6,ggvisOutput("scores"),
               uiOutput("scores_ui")),
      column(6,ggvisOutput("loadings"),
               uiOutput("loadings_ui"))
     ),

     br(),

     fluidRow(
      column(6,h3("Component Selection"),selectInput('xInp',"X Variable",names(data)), …
Run Code Online (Sandbox Code Playgroud)

r shiny ggvis

4
推荐指数
1
解决办法
3074
查看次数

标签 统计

r ×2

ggvis ×1

netcdf ×1

raster ×1

shiny ×1