简体   繁体   English

如何将 pyspark dataframe 中的几何列从二进制格式转换为字符串格式?

[英]How do I convert a geometry column from binary format to string format in a pyspark dataframe?

Here is my attempt at this:这是我的尝试:

%sql SELECT df1.*,df1.geometry.STAsText() as geom_text FROM df_geo df1.

This obviously fails because it is not a table, but a dataframe. How can one do this using pyspark or geospark?这显然失败了,因为它不是一个表,而是一个 dataframe。如何使用 pyspark 或 geospark 来做到这一点?

If you use GeoSparkSQL,如果你使用 GeoSparkSQL,

SELECT *, ST_AsText(geometry) as geom_text FROM df_geo

In pyspark:在 pyspark:

df_geo.createOrReplaceTempView("df_geo")
df2 = spark.sql("SELECT *, ST_AsText(geometry) as geom_text FROM df_geo")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将长格式 dataframe 转换为宽格式 PySpark - How can I convert a long format dataframe into a wide format in PySpark PySpark 数据帧将异常字符串格式转换为时间戳 - PySpark dataframe convert unusual string format to Timestamp 如何在Pyspark数据框中查询字典格式列 - How to query a dictionary format column in Pyspark dataframe Pyspark 列:将字符串格式的数据转换为时间戳格式 - Pyspark column: Convert data in string format to timestamp format 将 DataFrame 列从字符串转换为日期时间格式“2001 年 1 月 1 日星期一” - Convert DataFrame column from string to datetime for format "January 1, 2001 Monday" 如何将字典格式的数据框中的列转换为单独的列? - How do a convert a column in a dataframe that is in the format of a dictionary into separate columns? 我在 .csv 文件的特定列中有 MongoDB 格式的字符串行 如何将其转换为数据帧? - I have rows of strings in the MongoDB format in a specific column in the .csv file How do I convert it into dataframe? 需要将整个列从字符串格式转换为数据帧中的日期格式 - Need to convert entire column from string format to date format from a Dataframe 如何将 PySpark/Pandas 数据框中的日期/自定义/通用格式的列值转换为日期格式? - How to convert column values present in date/custom/general formats in a PySpark/Pandas dataframe into a Date Format? 如何将带有时间段的 dataframe 转换为特定格式? - How do I convert a dataframe with time-periods into a particular format?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM