Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More clear documentation about the use of relative filter patterns on bcdc_promise class #355

Open
paulinamarczak opened this issue Jan 28, 2025 · 6 comments

Comments

@paulinamarczak
Copy link

I was getting an odd "cannot connect to wfs" error when I made a query that included a grepl filter statement.

It seems that bcdata does not accept grepl

vri_test <-  bcdc_query_geodata('2ebb35d8-c82f-4a17-9c96-612ac3532d55') %>% 
		select(
			POLYGON_AREA,
			BCLCS_LEVEL_4,
			REFERENCE_YEAR,
			INVENTORY_REGION,
			LINE_7B_DISTURBANCE_HISTORY,
			ORG_UNIT_CODE,
			REFERENCE_DATE,
			SPECIES_CD_1,
			SPECIES_PCT_1,
			WHOLE_STEM_BIOMASS_PER_HA) %>%
		filter(grepl("B"|"BE"), LINE_7B_DISTURBANCE_HISTORY) # DOES NOT WORK
                filter(LINE_7B_DISTURBANCE_HISTORY %LIKE% "B%") # works
		#collect() #return as sf object

The only cryptic error message that is returned if using the line with grepl is:

"Error: There was an issue sending this WFS request".

When i tried troubleshooting using str_starts(), I finally got an error message that helped me decode what I was doing wrong,

"Only fixed patterns are supported on database backends.".

Could you update the documentation to explain these constraints for filter types accepted for bcdc _promise class?

@paulinamarczak paulinamarczak changed the title More clear documentation about the use of relative filter patterns on bcdc _promise class More clear documentation about the use of relative filter patterns on bcdc_promise class Jan 28, 2025
@ateucher
Copy link
Collaborator

Thanks @paulinamarczak - it would be good to update the documentation around partial string matching. If you're interested in contributing to that documentation, a pull request would be welcome!

For completeness, we have discussed this issue previously here: #227

@paulinamarczak
Copy link
Author

I would contribute but I'm not that fluent in bcdata package (just started using today) and the extent of the issue, and what pages would all need to be updated. Hopefully seeing my solution to this issue helps someone though!

@bevingtona
Copy link
Contributor

bevingtona commented Jan 29, 2025

Would it be sufficient to add the example below to the bcdc_query_geodata {bcdata} description? I'm happy to make a pull request.

# To query based on partial matches, use %LIKE%:
try(
  bcdc_query_geodata("bc-airports") %>%
    filter(PHYSICAL_ADDRESS %LIKE% 'Vict%') 
)

Also, the use of %IN%

try(
  bcdc_query_geodata("bc-airports") %>%
    filter(AIRPORT_NAME %IN% c("Victoria Harbour (Camel Point) Heliport",
                               "Victoria Harbour (Shoal Point) Heliport")) %>% 
    collect()
)

@ateucher
Copy link
Collaborator

Yes please @bevingtona that would be awesome!

@stephhazlitt
Copy link
Member

@paulinamarczak adding some text and an example in the Querying Spatial Data with bcdata vignette would be a great (first) contribution to bcdata, maybe added something about partial matching would work here?

@paulinamarczak
Copy link
Author

hi Stephanie. I will try to add to the vignette during some downtime (put it on my task board). Thank you for your helpful directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants