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

sf geometry column naming #39

Open
jaseeverett opened this issue Jan 19, 2024 · 2 comments
Open

sf geometry column naming #39

jaseeverett opened this issue Jan 19, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@jaseeverett
Copy link
Collaborator

jaseeverett commented Jan 19, 2024

Hi @echelleburns and @jflowernet,

Great package. Thanks. It's very useful for our work and I love the new name.

One small issue, I notice the sf objects are returned with the geometry column as x. My preference (and I think the standard way to represent it) is to use geometry for the column name. @jflowernet and I were chatting and he mentioned there was inconsistency in some of the output so x was used for consistency.

This inconsistency could possibly be due to the use of sf::st_as_sf() rather than sf::st_sf(). I have had this issue to. The first (with _at_) gives you x but the 2nd will consistently give you geometry (as will reading in local files as sf objects). The reprex below illustrates this.

Hope this helps.

library(magrittr)
cCRS = "EPSG:4326"
# Create tibble with data 
tib = dplyr::tibble(x = seq(-50, 50, by = 1), y = 120) %>%
  dplyr::bind_rows(dplyr::tibble(x = 50, y = seq(120, 180, by = 1))) %>%
  dplyr::bind_rows(dplyr::tibble(x = seq(50, -50, by = -1), y = 180)) %>%
  dplyr::bind_rows(dplyr::tibble(x = -50, y = seq(150, 120, by = -1)))

# Convert to sfc
sfc <- tib %>%
  as.matrix() %>%
  list() %>%
  sf::st_polygon() %>%
  sf::st_sfc(crs = "EPSG:4326") %>%
  sf::st_transform(crs = cCRS) 

# Convert to sf using 2 different methods
sf_x <- sfc %>% sf::st_as_sf()
colnames(sf_x)
#> [1] "x"

sf_geometry <- sfc %>% sf::st_sf()
colnames(sf_geometry)
#> [1] "geometry"

Created on 2024-01-19 with reprex v2.0.2

@jaseeverett
Copy link
Collaborator Author

Thanks for the updates here. Seems to be fixed for oceandatr::get_bathymetry, oceandatr::get_knolls, oceandatr::get_seamounts_buffered, oceandatr::get_coral_habitat.

It's still an issue for oceandatr::get_enviro_regions. Any chance of fix for that as well?

jflowernet added a commit that referenced this issue Apr 2, 2024
@jflowernet
Copy link
Member

Commit should fix this for get_enviro_regions, but leaving this open as I want to double check all functions are returning geometry as the geometry column

@jflowernet jflowernet self-assigned this Apr 2, 2024
@jflowernet jflowernet added the enhancement New feature or request label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants