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:

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:

# my_dataframe has the columns "longitude" and "latitude"
guess_crs(coordinate_example, "longitude", "latitude")
## Warning in transform_coordinates(df, col_x, col_y, st_crs(prj), st_crs(4326)):
## Input CRS equal to output CRS No transform performed.

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"))
## Warning in transform_coordinates(df, col_x, col_y, st_crs(prj), st_crs(4326)):
## Input CRS equal to output CRS No transform performed.

Check the spatial reference for the available codes.