Output CRS?
dieghernan opened this issue · comments
Diego H. commented
By email, we got a question: about the CRS and format of the output:
The format is sf
, that is the standard way to handle spatial vector objects with R. This can be written to other spatial formats with
sf::st_write()
, i.e.
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))
#> Reading layer `nc' from data source
#> using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> Geodetic CRS: NAD27
sf::st_write(nc, "nc.gpkg")
#> Writing layer `nc' to data source `nc.gpkg' using driver `GPKG'
#> Writing 100 features with 14 fields and geometry type Multi Polygon.
sf::st_write(nc, "nc.shp")
#> Writing layer `nc' to data source `nc.shp' using driver `ESRI Shapefile'
#> Writing 100 features with 14 fields and geometry type Multi Polygon.
Created on 2024-02-12 with reprex v2.1.0
The CRS is usually the one provided by Catastro: EPSG:25831
library(CatastRo)
library(sf)
# Get all buildings with atom
all_bus <- catr_atom_get_buildings(munic = "OLOT", to = "GIRONA")
# Glimpse
dplyr::glimpse(all_bus)
#> Rows: 8,419
#> Columns: 27
#> $ gml_id <chr> "ES.SDGC.BU.000100100DG57B", "…
#> $ lowerCorner <chr> "455242.1405 4671944.017", "46…
#> $ upperCorner <chr> "455249.8105 4671952.1595", "4…
#> $ beginLifespanVersion <chr> "2015-05-25T00:00:00", "2015-0…
#> $ conditionOfConstruction <chr> "functional", "declined", "fun…
#> $ beginning <chr> "1800-01-01T00:00:00", "1900-0…
#> $ end <chr> "1800-01-01T00:00:00", "1900-0…
#> $ endLifespanVersion <chr> NA, NA, NA, NA, NA, NA, NA, NA…
#> $ informationSystem <chr> "https://www1.sedecatastro.gob…
#> $ reference <chr> "000100100DG57B", "000100100DG…
#> $ localId <chr> "000100100DG57B", "000100100DG…
#> $ namespace <chr> "ES.SDGC.BU", "ES.SDGC.BU", "E…
#> $ horizontalGeometryEstimatedAccuracy <dbl> 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, …
#> $ horizontalGeometryEstimatedAccuracy_uom <chr> "m", "m", "m", "m", "m", "m", …
#> $ horizontalGeometryReference <chr> "footPrint", "footPrint", "foo…
#> $ referenceGeometry <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, …
#> $ currentUse <chr> "1_residential", "1_residentia…
#> $ numberOfBuildingUnits <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, …
#> $ numberOfDwellings <int> 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, …
#> $ numberOfFloorsAboveGround <chr> NA, NA, NA, NA, NA, NA, NA, NA…
#> $ documentLink <chr> "http://ovc.catastro.meh.es/OV…
#> $ format <chr> "jpeg", "jpeg", "jpeg", "jpeg"…
#> $ sourceStatus <chr> "NotOfficial", "NotOfficial", …
#> $ officialAreaReference <chr> "grossFloorArea", "grossFloorA…
#> $ value <int> 92, 456, 441, 208, 260, 9, 9, …
#> $ value_uom <chr> "m2", "m2", "m2", "m2", "m2", …
#> $ geometry <MULTIPOLYGON [m]> MULTIPOLYGON (((4…
# Get the crs
sf::st_crs(all_bus)
#> Coordinate Reference System:
#> User input: ETRS89 / UTM zone 31N
#> wkt:
#> PROJCRS["ETRS89 / UTM zone 31N",
#> BASEGEOGCRS["ETRS89",
#> ENSEMBLE["European Terrestrial Reference System 1989 ensemble",
#> MEMBER["European Terrestrial Reference Frame 1989"],
#> MEMBER["European Terrestrial Reference Frame 1990"],
#> MEMBER["European Terrestrial Reference Frame 1991"],
#> MEMBER["European Terrestrial Reference Frame 1992"],
#> MEMBER["European Terrestrial Reference Frame 1993"],
#> MEMBER["European Terrestrial Reference Frame 1994"],
#> MEMBER["European Terrestrial Reference Frame 1996"],
#> MEMBER["European Terrestrial Reference Frame 1997"],
#> MEMBER["European Terrestrial Reference Frame 2000"],
#> MEMBER["European Terrestrial Reference Frame 2005"],
#> MEMBER["European Terrestrial Reference Frame 2014"],
#> ELLIPSOID["GRS 1980",6378137,298.257222101,
#> LENGTHUNIT["metre",1]],
#> ENSEMBLEACCURACY[0.1]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433]],
#> ID["EPSG",4258]],
#> CONVERSION["UTM zone 31N",
#> METHOD["Transverse Mercator",
#> ID["EPSG",9807]],
#> PARAMETER["Latitude of natural origin",0,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8801]],
#> PARAMETER["Longitude of natural origin",3,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8802]],
#> PARAMETER["Scale factor at natural origin",0.9996,
#> SCALEUNIT["unity",1],
#> ID["EPSG",8805]],
#> PARAMETER["False easting",500000,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8806]],
#> PARAMETER["False northing",0,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8807]]],
#> CS[Cartesian,2],
#> AXIS["(E)",east,
#> ORDER[1],
#> LENGTHUNIT["metre",1]],
#> AXIS["(N)",north,
#> ORDER[2],
#> LENGTHUNIT["metre",1]],
#> USAGE[
#> SCOPE["Engineering survey, topographic mapping."],
#> AREA["Europe between 0°E and 6°E: Andorra; Belgium - onshore and offshore; Denmark - offshore; Germany - offshore; Jan Mayen - offshore; Norway including Svalbard - onshore and offshore; Spain - onshore and offshore."],
#> BBOX[37,0,82.45,6.01]],
#> ID["EPSG",25831]]
# EPSG
sf::st_crs(all_bus)$epsg
#> [1] 25831
# proj4
sf::st_crs(all_bus)$proj4string
#> [1] "+proj=utm +zone=31 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
Created on 2024-02-12 with reprex v2.1.0
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31 ucrt)
#> os Windows 11 x64 (build 22631)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Spanish_Spain.utf8
#> ctype Spanish_Spain.utf8
#> tz Europe/Madrid
#> date 2024-02-12
#> pandoc 3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> CatastRo * 0.3.0 2024-01-18 [1] CRAN (R 4.3.2)
#> class 7.3-22 2023-05-03 [1] CRAN (R 4.3.1)
#> classInt 0.4-10 2023-09-05 [1] CRAN (R 4.3.1)
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.2)
#> DBI 1.2.1 2024-01-12 [1] CRAN (R 4.3.2)
#> digest 0.6.34 2024-01-11 [1] CRAN (R 4.3.2)
#> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.3.2)
#> e1071 1.7-14 2023-12-06 [1] CRAN (R 4.3.2)
#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.2)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.2)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.1)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.2)
#> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.2)
#> KernSmooth 2.23-22 2023-07-10 [1] CRAN (R 4.3.1)
#> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.2)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.2)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0)
#> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.3.0)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.1)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.0)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.2)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.2)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
#> Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.2)
#> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.2)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.2)
#> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.1)
#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.1)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
#> sf * 1.0-15 2023-12-18 [1] CRAN (R 4.3.2)
#> stringi 1.8.3 2023-12-11 [1] CRAN (R 4.3.2)
#> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.1)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0)
#> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0)
#> units 0.8-5 2023-11-28 [1] CRAN (R 4.3.2)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.2)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.2)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.2)
#> xfun 0.42 2024-02-08 [1] CRAN (R 4.3.2)
#> xml2 1.3.6 2023-12-04 [1] CRAN (R 4.3.2)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.2)
#>
#> [1] C:/Users/diego/AppData/Local/R/win-library/4.3
#> [2] C:/Program Files/R/R-4.3.2/library
#>
#> ──────────────────────────────────────────────────────────────────────────────