knitr::opts_chunk$set(error = TRUE)
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.
The aim is to quickly check the coordinate system by plotting the coordinates on a leaflet map with a list of given coordinate systems.
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:
library(inborutils)
CRS
functionThe guess_crs
function requires as minimal inputs:
data.frame
For example:
library(htmlwidgets) setWidgetIdSeed(20171209)
# 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:
guess_crs(coordinate_example, "longitude", "latitude", belgium = TRUE, crs_try = c("EPSG:2000", "EPSG:2805", "EPSG:4326"))
Check the spatial reference for the available codes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.