Skip to content

RT_SRText can work as a getter or a setter, depending on the inputs.

Getter: RT_SRText takes a raster column and returns the spatial reference of the column as a string in Well-Known Text (WKT) format. If the spatial reference of the input raster column has not been set, the function returns an empty string.

Setter: RT_SRText takes a raster column and a spatial reference string in Well-Known Text (WKT) format and returns the input raster column with its spatial reference set to the string value. This does not affect the raster data in the column. To transform your raster from one spatial reference to another, use RT_Transform. This also does not affect the extent of the output raster column, to set the extent of your raster column, use RT_SetExtent.

FunctionSyntax
Pythonsr_text(raster_col, wkt=None)
SQLRT_SRText(raster_col, wkt)
ScalasrText(raster, wkt)

For more details, go to the GeoAnalytics Engine API reference for sr_text.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12

from geoanalytics.raster import functions as RT

data = [([1,2,3,4], )]
df = spark.createDataFrame(data, ["pixels"]) \
     .withColumn("raster", RT.create_raster("pixels", 2, 2, "int32"))

wkt_4326 = ('GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",'
            'SPHEROID["WGS_1984",6378137.0,298.257223563]],'
            'PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]')
df.select(RT.sr_text("raster", wkt_4326).alias("raster")) \
  .withColumn("sr_text", RT.sr_text("raster")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|raster                 |sr_text                                                                                                                                          |
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|SqlRaster(1x2x2, Int32)|GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]|
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+

Version table

ReleaseNotes

2.0.0

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.