Coordinate Reference Systems (CRS)

Overview

This page describes about how to manage coordinate reference system (CRS) information within OPALS and description of python script to help some tasks.

How CRS is managed within OPALS

CRS in ODM files is stored as WKT (Well-known text) String. While OPALS deals with other data format, each file stores (maybe partial) CRS information by themselves. In case of grid datasets which are usually handled using GDAL, CRS information is stored separately in the metadata in addition to the driver supported CRS storage mechanism which are either format-supported or GDAL auxillary file. This is because some GDAL drivers (e.g. GeoTIFF) might be lossy as unrecognized items (e.g. EXTENSION) might not be stored. CRS in GDAL raster files are stored using SOURCE_CRS key in the metadata. If this CRS metadata available then this information will be used as CRS instead of CRS from GDAL.

Displaying CRS

Module Info can be used to show information from an ODM file. Additionally, displaying CRS information from ODM and grid data files (supported by GDAL) is available through Python helper script (see here ).

CRS from input files

using Module Import, CRS information is obtained using the following order :

  • stored within the file or in external .prj file
  • coord_ref_sys parameter

CRS in the output files

Output files generated from OPALS modules carries CRS information from its input file(s). If there are some input file that do not have CRS information stored then it is assumed that the CRS is the same as other file(s) has CRS information stored. In case where all the input files have no CRS information stored, CRS information can be manually set during modules executions via coord_ref_sys parameter. Moreover, CRS information can also be set globally in the installation-wise configuration file.

Comparing CRS

The following definitions are used when comparing CRS information.

Empty CRS

A CRS is considered empty if it is an empty string.

Equal CRS
Two CRSs are considered equal if these conditions are satisfied:
  • Both CRS are of the same type (the root node are COMPD_CS and COMPD_CS, GEOG_CS and GEOG_CS, etc.)
  • Both share the same parameters (for GEOG_CS: DATUM, PRIMEM, UNIT)

Validating CRS

Python helper scripts

a python script (_setCRS.py) is provided in the $OPALS_ROOT/opals/workflows directory to show or modify existing files. Another python script (_validateCRS.py) is also provided for validating CRS information given from text file containing CRS in WKT, from ODM file, or from GDAL-supported rasters.

Parameters

-infile name of ODM or raster file in GDAL supported format
Type : Path
Remark : mandatory
-crs CRS definition string (eg. EPSG:xxx, WKT string, or path to file with such value)
Type : String
Remark : optional
-copySource filename (ODM or raster) containing CRS spec in WKT format
Type : Path
Remark : optional
-reset reset clears CRS contents from ODM/raster file
Type : Boolean
Remark : optional, default: False
possible inputevaluates to
1, true, yes, Boolean(True), TrueBoolean(True)
0, false, no, Boolean(False), FalseBoolean(False)
Logging Options
Settings concerning the verbosity level of logging.
-fileLogLevel Log level in the logfile
Type : LogLevel
Remark : optional, default: info
-screenLogLevel Log level on screen
Type : LogLevel
Remark : optional, default: info
-logger Logger
Type : Logger
Remark : optional
Description: Logger is usually provided by the opals framework.The user may provide their own logger object, but it has to function in the same way as the opals Logger.

Printing CRS information from a file

_setCRS.py script can be use to print out available CRS information from a ODM or raster file.

opals _setCRS.py -i albis.tif

Above command will result in the following output

CRS Location CRS Content
Metadata LOCAL_CS["X-Y-Z",UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]]
GDAL Driver LOCAL_CS["X-Y-Z",UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]]

Adding CRS information to a file

To add CRS information from EPSG code, use the crs parameter.

The crs accepts a wide range of CRS definition formats:

  • PROJ string
  • WKT string
  • object code like "EPSG:21781", "urn:ogc:def:crs:EPSG::21781", "urn:ogc:def:coordinateOperation:EPSG::1671"
  • compound CRS like "urn:ogc:def:crs,crs:EPSG::21781,crs:EPSG::5729" or abbreviated "EPSG:21781+5729"
  • well known name, such as NAD27, NAD83, WGS84 or WGS72
  • definitions from the PROJ database like "IGNF:nnnn", "ESRI:nnnn"
  • PROJJSON
  • path to a file with WKT, XML or PROJ definition
  • http or https URL to file with one of above definitions

Examples:

Add CRS information from EPSG code:

opals _setCRS.py -i albis.tif -crs epsg:21781

Add CRS information with compound CRS made of horizontal and vertical EPSG:

opals _setCRS.py -i albis.tif -crs epsg:21781+5729

Add CRS information from PROJ string:

opals _setCRS.py -i albis.tif -crs "+proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs +type=crs"

Import CRS information from .prj file containing WKT string:

opals _setCRS.py -i albis.tif -crs CH1903_LV03.prj

Import CRS information from remote file containing PROJJSON:

opals _setCRS.py -i albis.tif -crs https://epsg.io/21781.json

To add CRS information from a source file (ODM or GDAL Rasters) containing WKT string, Use copySource parameter

opalsImport -inFile albis.laz
opals _setCRS.py -i albis.tif -copy albis.odm

Validating CRS information from a file

To add CRS information from file containing WKT string, use wkt parameter

opals _validateCRS.py -w CH1903_LV03.prj

To add CRS information from a source file (ODM or GDAL Rasters) containing WKT string, use infile parameter

opalsImport -infile albis.laz
opals _validateCRS.py -infile albis.odm

References

  • Geographic information - Well-known text (WKT) representation of coordinate reference systems OGC 12-063r5

Author
paryan, gm
Date
29.05.2020
opalsImport is the executable file of Module Import
Definition: ModuleExecutables.hpp:128
Contains the public interface of OPALS.
Definition: AbsValueOrQuantile.hpp:8