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

Adding embedded interactive maps to UK transport regions vingette #54

Closed
1 task done
hulsiejames opened this issue May 11, 2022 · 5 comments
Closed
1 task done

Comments

@hulsiejames
Copy link
Collaborator

hulsiejames commented May 11, 2022

  • Embed interactive maps into transport regions of UK vignette
@hulsiejames
Copy link
Collaborator Author

Map style similar to Greta's vignette

@hulsiejames
Copy link
Collaborator Author

hulsiejames commented May 11, 2022

Run into issue:

Error in select(., geometry) : could not find function select

Whilst running:

{r}
# Set our tmap package mode to _interactive_ to create interactive plots
tmap::tmap_mode('view') # After this call all qtm plots will be interactive 


{r}
# Here we create the  interactive plots
regions_lad %>% select(geometry) %>% tmap::qtm()

Which is fixed in this stack overflow thread:

I had the same issue and it was caused by name clash with another package. Use: dplyr::select to specify the package.


I had forgotten to import library(dplyr) so this is no surprise - the both this and the above approach fix this error.

@hulsiejames
Copy link
Collaborator Author

But, now have error:

Error: Shape contains invalid polygons. Please fix it or set tmap_options(check.and.fix = TRUE) and return the plot

Which appears to be a common issue (571, 577 ) which seems to be due to Simple Features (sf) changes and is fixable with the following:

sf::sf_use_s2(FALSE)

which fixes all errors and allows the .Rmd to knit

@hulsiejames
Copy link
Collaborator Author

However - I'm not too sure this shoulf have fixed the issue?

It seem from @Robinlovelace expereince this issue was occuring when geometries were all valid according to sf::st_is_valid() which (In Robin's instance) returned

summary(sf::st_is_valid(z))
#>    Mode    TRUE 
#> logical      74

However for the joined Loacal Authority Disticts file it seems there is an incorrect geometry:

> summary(sf::st_is_valid(regions_lad))
#>   Mode   FALSE    TRUE 
#>   logical       1     373 

Going to see if I can identify the broken geometry and remove it from the plot and see if it works without the sf::sf_use_s2(use_s2 = FLASE)
I don't understand why it would be plotting even with a broken geometry as I have not called for tmap to automatically fix geometries (i.e. tmap_options(check.and.fix = TRUE))

@Robinlovelace
Copy link
Contributor

Going to see if I can identify the broken geometry and remove it from the plot and see if it works without the sf::sf_use_s2(use_s2 = FLASE)
I don't understand why it would be plotting even with a broken geometry as I have not called for tmap to automatically fix geometries (i.e. tmap_options(check.and.fix = TRUE))

Not sure what is going on but sf::sf_use_s2(FALSE) is a reasonable fix.

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

2 participants