st_addpoint
info
Aperçu
La prise en charge des valeurs GEOGRAPHY est en aperçu public. La prise en charge des valeurs GEOMETRY est généralement disponible.
Ajoute un nouveau point à la n-ième position dans la chaîne de lignes d'entrée Géographie ou Géométrie.
Pour la fonction Databricks SQL correspondante, consultez la fonctionst_addpoint.
Syntaxe
Python
from pyspark.databricks.sql import functions as dbf
dbf.st_addpoint(col1=<col1>, col2=<col2>, col3=<col3>)
parameter
parameter | Type | Description |
|---|---|---|
|
| Une valeur Geography ou Geometry représentant une LineString. |
|
| Une valeur Géographie ou Géométrie représentant un point. |
|
| Une position facultative basée sur 1 dans le linestring où le nouveau point doit être ajouté. La valeur par default est -1. |
Exemples
Python
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_addpoint(dbf.st_geogfromtext('wkt1'), dbf.st_geogfromtext('wkt2'), 3)).alias('result')).collect()
Output
[Row(result='LINESTRING(1 2,3 4,7 8)')]
Python
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_asewkt(dbf.st_addpoint(dbf.st_geogfromtext('wkt1'), dbf.st_geogfromtext('wkt2'))).alias('result')).collect()
Output
[Row(result='SRID=4326;LINESTRING(1 2,3 4,7 8)')]
Python
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_addpoint(dbf.st_geogfromtext('wkt1'), dbf.st_geogfromtext('wkt2'), -1)).alias('result')).collect()
Output
[Row(result='SRID=4326;LINESTRING ZM (1 2 3 4,5 6 7 8,0 9 0 99)')]