Definition of a coordinate system in R

It is common that no coordinate system is associated with the loaded raster or vector data. The lack of a defined system can lead to errors when using spatial analysis tools. Therefore, it is shown here how to assign a layout to a layer in a simple way.

Let’s load a previously used railroad layer without a defined coordinate system (just delete the PRJ file):

Let’s display the information about the railroad layer:

You can see that the coord. ref. attribute has the value NA, which means that the reference coordinate system is unknown. To assign it, we will use the projection tool from the raster library:

We know that the geometry data in this layer is defined in the PUWG 1992 layout. First we need to define this coordinate system using the crs function from the raster library. Argument of this function can be coordinate system parameters written in PROJ4 format:

or we can use EPSG codes:

We assign the coordinate system to the layer with an expression:

The presented way of assigning a coordinate system also works for rasters.

Leave a Reply

Your email address will not be published.

Translate using Google Translate»
Social media & sharing icons powered by UltimatelySocial

Podoba Ci się nasza strona? Odwiedź nasz profil