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.
| Function | Syntax |
|---|---|
| Python | sr |
| SQL | RT |
| Scala | sr |
For more details, go to the GeoAnalytics Engine API reference for sr_text.
Examples
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)+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|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
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |