重要
此功能目前以公共预览版提供。
设置输入线字符串 Geography 或 Geometry 中的第 n 个点。
有关相应的 Databricks SQL 函数,请参阅 st_setpoint 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.st_setpoint(col1=<col1>, col2=<col2>, col3=<col3>)
参数
| 参数 | 类型 | Description |
|---|---|---|
col1 |
pyspark.sql.Column 或 str |
表示线字符串的 Geography 或 Geometry 值。 |
col2 |
pyspark.sql.Column 或 int |
应在其中添加新点的线字符串中基于 1 的位置。 |
col3 |
pyspark.sql.Column 或 str |
表示点的 Geography 或 Geometry 值。 |
例子
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('LINESTRING(1 2,3 4)','POINT(7 8)',)], ['wkt1', 'wkt2'])
df.select(dbf.st_astext(dbf.st_setpoint(dbf.st_geomfromtext('wkt1'), 1, dbf.st_geomfromtext('wkt2'))).alias('result')).collect()
[Row(result='LINESTRING(7 8,3 4)')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('LINESTRING ZM (1 2 3 4,5 6 7 8)','POINT M (0 9 99)',)], ['wkt1', 'wkt2'])
df.select(dbf.st_asewkt(dbf.st_setpoint(dbf.st_geogfromtext('wkt1'), -1, dbf.st_geogfromtext('wkt2'))).alias('result')).collect()
[Row(result='SRID=4326;LINESTRING ZM (1 2 3 4,0 9 0 99)')]