RS_GeoReference¶
Introduction: Returns the georeference metadata of raster as a string in GDAL or ESRI format. Default is GDAL if not specified.
For more information about ScaleX, ScaleY, SkewX, SkewY, please refer to the Affine Transformations section.
Note
If you are using show() to display the output, it will show special characters as escape sequences. To get the expected behavior use the following code:
println(df.selectExpr("RS_GeoReference(rast)").sample(0.5).collect().mkString("\n"))
System.out.println(String.join("\n", df.selectExpr("RS_GeoReference(rast)").sample(0.5).collect()))
print("\n".join(df.selectExpr("RS_GeoReference(rast)").sample(0.5).collect()))
The sample() function is only there to reduce the data sent to collect(), you may also use filter() if that's appropriate.
Format: RS_GeoReference(raster: Raster, format: String = "GDAL")
Since: v1.5.0
Difference between format representation is as follows:
GDAL
ScaleX
SkewY
SkewX
ScaleY
UpperLeftX
UpperLeftY
ESRI
ScaleX
SkewY
SkewX
ScaleY
UpperLeftX + ScaleX * 0.5
UpperLeftY + ScaleY * 0.5
SQL Example
SELECT RS_GeoReference(ST_MakeEmptyRaster(1, 100, 100, -53, 51, 2, -2, 4, 5, 4326))
Output:
2.000000
5.000000
4.000000
-2.000000
-53.000000
51.000000
SQL Example
SELECT RS_GeoReference(ST_MakeEmptyRaster(1, 3, 4, 100.0, 200.0,2.0, -3.0, 0.1, 0.2, 0), "GDAL")
Output:
2.000000
0.200000
0.100000
-3.000000
100.000000
200.000000
SQL Example
SELECT RS_GeoReference(ST_MakeEmptyRaster(1, 3, 4, 100.0, 200.0,2.0, -3.0, 0.1, 0.2, 0), "ERSI")
2.000000
0.200000
0.100000
-3.000000
101.000000
198.500000