我想获得与特定地区接壤的地区的几何形状。
districts
d0 = districts[0]
gpd.sjoin(d0, districts, op='intersects')
这给出了每行中d0的几何。但我想要每行中右表的几何形状。是否可以同时获得左右表格几何形状?
答案 0 :(得分:0)
您可以使用library(shiny)
library(lubridate)
ui = fluidPage(sidebarPanel(width = 2,
fileInput('files', '', accept = c('text/csv','text/comma-separated-values','text/tab-separated-values','text/plain','.csv','.tsv')),
checkboxInput('header', 'Header', TRUE),
radioButtons('sep', 'Separator', c(Comma=',',Semicolon=';',Tab='\t'), selected=';'),
radioButtons('quote', 'Quote', c(None='','Double Quote'='"','Single Quote'="'"), selected='"'),
uiOutput('apply')),
mainPanel(width = 10, uiOutput('years'),tags$br(),tags$br(),
textOutput('showyrs'),tags$br(),tags$br(),
textOutput('yrz'),tags$br(),tags$br(),
dataTableOutput("tabel4")
)
)
######################################################################
server = function(input, output, session) {
### if a csv is selected (through fileInput()), it is read
vis0 <- reactive({
req(input$files)
vis <- read.csv(input$files$datapath, header = input$header, sep = input$sep, quote = input$quote,
stringsAsFactors =FALSE)
vis$Dte <- as.Date(as.character(vis$Dte), "%d/%m/%Y")
vis$year <- factor(year(vis$Dte))
vis
})
### button appearing only after
output$apply <- renderUI({
if (is.null(input$files)) return()
actionButton("Load", "APPLY DATA")
})
### get checkbox values from data and throw them back to UI
output$years <- renderUI({
req(vis0)
df <- vis0()
df$year <- as.character(df$year)
if (is.null(df)) return(NULL)
items= sort(unique(df$year))
names(items)=items
checkboxGroupInput("years","Check or uncheck years to be included or excluded",
choices=items, selected = items, inline = TRUE)
})
### show input$years
output$showyrs <- renderText({
req(input$files)
if (is.null(input$years)) {
"Nothing..."
} else if (input$years==0) {
"Nothing..."
} else {input$years}
})
### use selected checkbox values to reduce initial dataset
vis1 <- reactive({
req(input$years)
if (is.null(input$Load)) return()
if (input$Load==0) return()
data <- vis0()
data <- subset(data, as.character(year) %in% input$years)
data
})
### using the checkbox-reduced data to create a table
output$tabel4 <- renderDataTable({
vis1()
})
}
shinyApp(ui = ui, server = server, options = list(launch.browser=TRUE))
在sjoin
df1.registerTempTable("temp_table_1")
df2.registerTempTable("temp_table_2")
spark.sql(
"""SELECT id1, id2, count(*) AS count_similarity FROM temp_table_1 AS t1
| JOIN temp_table_2 AS t2 ON (t1.food = t2.food)
| GROUP BY id1, id2
| ORDER BY id1, id2""".stripMargin
).show
gdf将有一个名为join
的列/系列,我们可以利用
gdf = gpd.sjoin(d0, districts, op='intersects')
不确定geopandas将如何处理两个几何。我猜所有操作都将利用d0中的原始操作