Introduction: Returns the coordinate reference system (CRS) of a raster as a string in the specified format. If no format is specified, the CRS is returned in PROJJSON format. Returns null if the raster has no CRS defined.
Format:
RS_CRS (raster: Raster)
RS_CRS (raster: Raster, format: String)
Since: v1.9.0
| Format | Description |
|---|---|
'projjson' | PROJJSON format (default). Modern, machine-readable JSON representation. |
'wkt2' | Well-Known Text 2 (ISO 19162). Modern standard CRS representation. |
'wkt1' | Well-Known Text 1 (OGC 01-009). Legacy format, widely supported. |
'proj' | PROJ string format. Compact, human-readable representation. |
Getting CRS in default PROJJSON format:
SELECT RS_CRS(raster) FROM raster_table
Output:
{ "$schema": "https://proj.org/schemas/v0.7/projjson.schema.json", "type": "GeographicCRS", "name": "WGS 84", ... }
Getting CRS in WKT1 format:
SELECT RS_CRS(raster, 'wkt1') FROM raster_table
Output:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]
Getting CRS in PROJ string format:
SELECT RS_CRS(raster, 'proj') FROM raster_table
Output:
+proj=longlat +datum=WGS84 +no_defs +type=crs
Getting CRS in WKT2 format:
SELECT RS_CRS(raster, 'wkt2') FROM raster_table
The wkt2, proj, and projjson output formats are generated by proj4sedona from the raster's internal WKT1 CRS. This conversion may cause the following limitations:
wkt2, proj, or projjson formats and will throw an error. Use 'wkt1' format for these.!!!note RS_CRS returns null only when the raster has no CRS defined. Note that RS_SRID may return 0 either when no CRS is defined or when a custom (non-EPSG) CRS has been set via RS_SetCRS, so RS_SRID = 0 does not always mean “no CRS”. To test for a missing CRS, use RS_CRS(raster) IS NULL. The wkt1 format always produces a lossless representation of the internally stored CRS.