Skip to main content
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.

Signatures

Parameters

raster
Raster
required
The input raster.
crsString
String
required
The crs string value.

Return type

The resulting raster.

Examples

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

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.
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.