Skip to content
🌵SedonaDB (Rust) 0.3.0 is out now, featuring larger-than-memory spatial joins, and row-level CRS!

RS_SetCRS

Introduction: Sets the coordinate reference system (CRS) of a raster using a CRS definition string. Unlike RS_SetSRID which only accepts integer EPSG codes, RS_SetCRS accepts CRS definitions in multiple formats including EPSG codes, WKT1, WKT2, PROJ strings, and PROJJSON. This function does not reproject/transform the raster data — it only sets the CRS metadata.

Format: RS_SetCRS (raster: Raster, crsString: String)

Return type: Raster

Since: v1.9.0

Supported CRS formats

Format Example
EPSG code 'EPSG:4326'
WKT1 'GEOGCS["WGS 84", DATUM["WGS_1984", ...], ...]'
WKT2 'GEOGCRS["WGS 84", DATUM["World Geodetic System 1984", ...], ...]'
PROJ string '+proj=longlat +datum=WGS84 +no_defs'
PROJJSON '{"type": "GeographicCRS", "name": "WGS 84", ...}'

SQL Examples

Setting CRS with an EPSG code:

SELECT RS_SetCRS(raster, 'EPSG:4326') FROM raster_table

Setting CRS with a PROJ string (useful for custom projections):

SELECT RS_SetCRS(raster, '+proj=lcc +lat_1=25 +lat_2=60 +lat_0=42.5 +lon_0=-100 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs')
FROM raster_table

Setting CRS with a WKT1 string:

SELECT RS_SetCRS(raster, 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]')
FROM raster_table

Limitations

Internally, Sedona stores raster CRS in WKT1 format (via GeoTools). When you provide a CRS in WKT2, PROJ, or PROJJSON format, it is converted to WKT1 using proj4sedona. This conversion may cause the following limitations:

  • SRID not preserved for projected CRS: When importing PROJ or PROJJSON strings, the EPSG SRID is often lost for projected coordinate systems. Only geographic CRS (e.g., EPSG:4326), Web Mercator (EPSG:3857), and UTM zones reliably preserve their SRID. Use RS_SetSRID after RS_SetCRS if you need to set a specific SRID.
  • Unsupported projection types: Some projection types (e.g., Krovak, Hotine Oblique Mercator) are not supported by proj4sedona and will fail for WKT2, PROJ, and PROJJSON formats. Use 'EPSG:xxxx' or WKT1 for these.

Note

For the most reliable results, use 'EPSG:xxxx' format when your CRS has a known EPSG code. WKT1 input is also lossless since it is stored natively. WKT2, PROJ, and PROJJSON inputs undergo conversion and may experience the limitations above.