bcgov / bcgov/bcdata

Filter using string partial matching

未关闭
#227 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
R
星标
87
派生
14
PR 合并指标
30 天内没有已合并 PR

描述

**Problem:** I'd like to filter a query but I only know part of the string I am looking for...

``` r
bcdata::bcdc_query_geodata("bc-parks-ecological-reserves-and-protected-areas") %>%
filter(stringr::str_detect(PROTECTED_LANDS_NAME, "SUGARBOWL.*PARK*"))

#> Error in stri_detect_regex(string, pattern, negate = negate, opts_regex = opts(pattern)): object 'PROTECTED_LANDS_NAME' not found
```

**Potential solution:**
I could download/collect only the column that I want to filter by, detect the sting that I am looking for and then use that string to filter my query.

```
my_var <- bcdc_query_geodata("bc-parks-ecological-reserves-and-protected-areas") %>%
collect() %>%
st_drop_geometry() %>%
select(PROTECTED_LANDS_NAME) %>%
filter(stringr::str_detect(PROTECTED_LANDS_NAME, "SUGARBOWL.*PARK")) %>%
pull()

bcdc_query_geodata("bc-parks-ecological-reserves-and-protected-areas") %>%
filter(PROTECTED_LANDS_NAME == my_var)
```

**Problem with this solution:** I need to download the geometries of the data set to get the column that I am interested in, which is essentially just downloading the entire dataset, so there is no processing speed advantage.

**My question:**
Is there a way to drop the geometry before collecting the data? I suspect that this would be very fast and efficient for filtering large datasets using string detection.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。