GISRRS and PhotogrammetryUAV

In search of EPSG

It often happens to us that we need to find, for example, the EPSG code of a certain coordinate system to give it to our spatial data. Of course, we can use the epsg.io website, but there is an easier way and it is in one of the R libraries – rgdal. Let’s upload it:

library(rgdal)

Using the make_EPSG() function, we will write all the coordinate system data to the proj variable:

proj = make_EPSG()

Variable proj is of class data.frame and contains 3 columns: EPSG code, coordinate system name, parameters in format proj4

> head(proj)
  code                                               note                                                                                          prj4
1 3819                                           # HD1909 +proj=longlat +ellps=bessel +towgs84=595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408 +no_defs
2 3821                                            # TWD67                                                         +proj=longlat +ellps=aust_SA +no_defs
3 3824                                            # TWD97                                    +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
4 3889                                             # IGRS                                    +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
5 3906                                         # MGI 1901                            +proj=longlat +ellps=bessel +towgs84=682,-203,480,0,0,0,0 +no_defs
6 4001 # Unknown datum based upon the Airy 1830 ellipsoid                                                            +proj=longlat +ellps=airy +no_defs

We can search for an interesting coordinate system using the grepl function. This function is used to find strings. For example, let’s find all coordinate systems with “Poland” in their name:

proj[grepl(pattern = "Poland",x =  proj$note),1:2]
> proj[grepl(pattern = "Poland",x =  proj$note),1:2]
     code                                            note
670  2171 # Pulkovo 1942(58) / Poland zone I (deprecated)
671  2172             # Pulkovo 1942(58) / Poland zone II
672  2173            # Pulkovo 1942(58) / Poland zone III
673  2174             # Pulkovo 1942(58) / Poland zone IV
674  2175              # Pulkovo 1942(58) / Poland zone V
675  2176                 # ETRS89 / Poland CS2000 zone 5
676  2177                 # ETRS89 / Poland CS2000 zone 6
677  2178                 # ETRS89 / Poland CS2000 zone 7
678  2179                 # ETRS89 / Poland CS2000 zone 8
679  2180                          # ETRS89 / Poland CS92
1610 3120              # Pulkovo 1942(58) / Poland zone I

Once we find the EPSG or proj4, we assign it to our spatial data.

Leave a Reply

Your email address will not be published. Required fields are marked *