--- title: "Check coordinate system" author: "Stijn Van Hoey" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Check coordinate system} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} %\VignetteDepends{htmlwidgets} --- ```{r, echo=FALSE} knitr::opts_chunk$set(error = TRUE) ``` ## Introduction When retrieving a number of data-points, but the kind of coordinate reference system (`CRS`) is not provided/known (for any reason), the `inborutils::guess_crs` function plots the data for different projections on a map to make comparison possible. The main function is `guess_crs` which creates the map with different options. The `transform_coordinates` function can be useful as well, as it supports conversion and transformation of coordinate columns in a `data.frame`. This function only tries a selection of `CRS` commonly used in Belgium. We refer the user to the `crsuggest` package which has a function by the same name `crsuggest::guess_crs`, but is more generally applicable. ## Aim The aim is to quickly check the coordinate system by plotting the coordinates on a leaflet map with a list of given coordinate systems. ## Functionality ### Dependencies In order to run the functionalities, some R packages need to be installed. The set of required libraries is handled by the `inborutils` package itself. Loading the functionality can be done by loading the `inborutils` package: ```{r} library(inborutils) ``` ### Guess `CRS` function The `guess_crs` function requires as minimal inputs: 1. a `data.frame` 2. the x (longitude) column name 3. the y (latitude) column name. For example: ```{r echo = FALSE} library(htmlwidgets) setWidgetIdSeed(20171209) ``` ```{r fig.width=7, message=FALSE} # my_dataframe has the columns "longitude" and "latitude" guess_crs(coordinate_example, "longitude", "latitude") ``` Furthermore, the optional argument `belgium` is a boolean value (TRUE/FALSE) defining if the data is expected to be in Belgium. Finally, the `epsg` codes of the corresponding coordinate systems to check can be customised. By default, the following `CRS`-systems are tested: * `EPSG:4326` * `EPSG:31370` * `EPSG:28992` * `EPSG:32631` * `EPSG:3812` * `EPSG:3035` Which can be overridden by adapting the `projections` argument: ```{r fig.width=7, message=FALSE} guess_crs(coordinate_example, "longitude", "latitude", belgium = TRUE, crs_try = c("EPSG:2000", "EPSG:2805", "EPSG:4326")) ``` Check the [spatial reference](https://spatialreference.org) for the available codes.