Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug on pull_crs() #74

Closed
dieghernan opened this issue Feb 1, 2023 · 0 comments · Fixed by #75
Closed

Bug on pull_crs() #74

dieghernan opened this issue Feb 1, 2023 · 0 comments · Fixed by #75
Labels
bug Something isn't working

Comments

@dieghernan
Copy link
Owner

Due to this check, if data has any NA then return NA

tidyterra/R/pull_crs.R

Lines 86 to 90 in 83dff5b

if (any(
is.na(.data), is.null(.data)
)) {
return(NA)
}

library(tidyterra)
#> 
#> Attaching package: 'tidyterra'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.1.3
#> Warning: package 'tibble' was built under R version 4.1.3
#> Warning: package 'tidyr' was built under R version 4.1.3
#> Warning: package 'readr' was built under R version 4.1.3
#> Warning: package 'purrr' was built under R version 4.1.3
#> Warning: package 'dplyr' was built under R version 4.1.3
#> Warning: package 'stringr' was built under R version 4.1.3
#> Warning: package 'forcats' was built under R version 4.1.3


t <- mapSpain::esp_get_ccaa(c("Madrid", "Andalucia")) %>%
  select(1)

t
#> Simple feature collection with 2 features and 1 field
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -7.522943 ymin: 35.93634 xmax: -1.630033 ymax: 41.1658
#> Geodetic CRS:  ETRS89
#>   codauto                       geometry
#> 2      01 MULTIPOLYGON (((-4.268895 3...
#> 1      13 MULTIPOLYGON (((-3.067689 4...
pull_crs(t)
#> [1] "GEOGCRS[\"ETRS89\",\n    DATUM[\"European Terrestrial Reference System 1989\",\n        ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n            LENGTHUNIT[\"metre\",1]]],\n    PRIMEM[\"Greenwich\",0,\n        ANGLEUNIT[\"degree\",0.0174532925199433]],\n    CS[ellipsoidal,2],\n        AXIS[\"geodetic latitude (Lat)\",north,\n            ORDER[1],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n        AXIS[\"geodetic longitude (Lon)\",east,\n            ORDER[2],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n    USAGE[\n        SCOPE[\"Spatial referencing.\"],\n        AREA[\"Europe - onshore and offshore: Albania; Andorra; Austria; Belgium; Bosnia and Herzegovina; Bulgaria; Croatia; Cyprus; Czechia; Denmark; Estonia; Faroe Islands; Finland; France; Germany; Gibraltar; Greece; Hungary; Ireland; Italy; Kosovo; Latvia; Liechtenstein; Lithuania; Luxembourg; Malta; Moldova; Monaco; Montenegro; Netherlands; North Macedonia; Norway including Svalbard and Jan Mayen; Poland; Portugal; Romania; San Marino; Serbia; Slovakia; Slovenia; Spain; Sweden; Switzerland; United Kingdom (UK) including Channel Islands and Isle of Man; Vatican City State.\"],\n        BBOX[32.88,-16.1,84.17,40.18]],\n    ID[\"EPSG\",4258]]"

# If the data has NAs
t$test1 <- NA

t
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -7.522943 ymin: 35.93634 xmax: -1.630033 ymax: 41.1658
#> Geodetic CRS:  ETRS89
#>   codauto                       geometry test1
#> 2      01 MULTIPOLYGON (((-4.268895 3...    NA
#> 1      13 MULTIPOLYGON (((-3.067689 4...    NA

pull_crs(t)
#> [1] NA

Created on 2023-02-01 with reprex v2.0.2

@dieghernan dieghernan added the bug Something isn't working label Feb 1, 2023
@dieghernan dieghernan mentioned this issue Feb 5, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant