chron_as_sf() adds a simple features geometry column (see sf::st_sf) to chronological data from XRONOS, using the latitude and longitude columns.

chron_drop_na_coords() excludes rows with missing or invalid coordinates; it is implicitly called by chron_as_sf(), issuing a warning if any rows were removed.

chron_as_sf(x, crs = sf::st_crs(4326))

chron_drop_na_coords(x, .warn = FALSE)

Arguments

x

data.frame retrieved with chron_data().

crs

Desired coordinate reference system in a format understood by sf::st_crs(). Defaults to latitude/longitude on the WGS84 ellipsoid (EPSG:4326).

.warn

If TRUE, issues a warning when rows are removed.

Value

chron_as_sf() returns x converted into an sf object. The original coordinate columns are retained.

chron_drop_na_coords() returns x without rows with missing or invalid coordinates.

Examples

x <- chron_data(country = "Switzerland")
chron_as_sf(x)
#> Warning: 1226 rows with missing or invalid coordinates were removed.
#> Simple feature collection with 3803 features and 21 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 4.0911 ymin: 45.96543 xmax: 10.38184 ymax: 47.753
#> Geodetic CRS:  WGS 84
#> # A tibble: 3,803 × 22
#>       id labnr      bp   std cal_bp cal_std delta…¹ reference    sourc…² mater…³
#>  * <int> <chr>   <int> <int> <lgl>  <lgl>     <dbl> <list>       <chr>   <chr>  
#>  1  5204 ETH-16…  4370    70 NA     NA           NA <named list> AgriCh… charco…
#>  2  5205 ETH-18…  4365    65 NA     NA           NA <named list> AgriCh… charco…
#>  3  5206 ETH-18…  4720    60 NA     NA           NA <named list> AgriCh… charco…
#>  4  5207 ARC-11…  4490    55 NA     NA           NA <named list> AgriCh… charco…
#>  5  5208 B-4703   4430    40 NA     NA           NA <named list> AgriCh… charco…
#>  6  5209 ETH-11…  5140    45 NA     NA           NA <named list> AgriCh… charco…
#>  7  5210 ARC-10…  5070   145 NA     NA           NA <named list> AgriCh… charco…
#>  8  5211 ETH-16…  5990    75 NA     NA           NA <named list> AgriCh… charco…
#>  9  5212 B-4701   5740    50 NA     NA           NA <named list> AgriCh… charco…
#> 10  5213 ETH-11…  5460    45 NA     NA           NA <named list> AgriCh… charco…
#> # … with 3,793 more rows, 12 more variables: species <chr>, feature <chr>,
#> #   periods <list>, typochronological_units <list>,
#> #   ecochronological_units <list>, site <chr>, country <chr>, lat <chr>,
#> #   lng <chr>, site_type <chr>, feature_type <chr>, geometry <POINT [°]>, and
#> #   abbreviated variable names ¹​delta_c13, ²​source_database, ³​material