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

missing conditional in checkCoord for some cases of orig.coord #146

Open
ggrittz opened this issue Mar 4, 2025 · 0 comments
Open

missing conditional in checkCoord for some cases of orig.coord #146

ggrittz opened this issue Mar 4, 2025 · 0 comments

Comments

@ggrittz
Copy link

ggrittz commented Mar 4, 2025

In checkCoord, lines 31-35:

ids.no.coord <- x[, orig.coord] %in% "no_coord"
  if (any(ids.no.coord)) 
    geo.check[ids.no.coord] <- "no_cannot_check"
  tmp <- x[is.na(geo.check), ]
  tmp <- sf::st_as_sf(tmp, coords = c(lon, lat))

There will be cases where orig.coord %in% coord_original and also have no lat/lon coordinates (i.e., the gazetteer did not return any coordinates for the register). This type of register should also be considered "no_cannot_check", otherwise sf::st_as_sf(tmp, coords = c(lon, lat)) will return an error:

Error in st_as_sf.data.frame(tmp, coords = c(lon, lat)) : 
  missing values in coordinates not allowed

Maybe this can be solved using the argument na.fail = FALSE inside sf::st_as_sf but it doesn't seem right in my mind. It is better to add these cases as no_cannot_check too.

This can be done adding this condition to x[, orig.coord] %in% "no_coord"

    # Adding the OR condition for cases where origin.coord is coord_original
    # but the lon OR lat are still NA even after using the gazetteer. 
    # These ones need to be no_cannot_check too
    ids.no.coord <- x[, orig.coord] %in% "no_coord" |
      (x[, orig.coord] %in% "coord_original" & (is.na(x[lon]) | is.na(x[lat])))
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

1 participant