paleolimbot commented on PR #1767:
URL: https://github.com/apache/sedona/pull/1767#issuecomment-2608182839

   For future me:
   
   <details>
   
   import os
   import pyspark
   from sedona.spark import SedonaContext
   if "SPARK_HOME" in os.environ:
       del os.environ["SPARK_HOME"]
   pyspark_version = pyspark.__version__[:pyspark.__version__.rfind(".")]
   
   config = (
       SedonaContext.builder()
       .config(
           "spark.jars.packages",
           f"org.apache.sedona:sedona-spark-{pyspark_version}_2.12:1.7.0,"
           "org.datasyslab:geotools-wrapper:1.7.0-28.5",
       )
       .config(
           "spark.jars.repositories",
           "https://artifacts.unidata.ucar.edu/repository/unidata-all";,
       )
       .getOrCreate()
   )
   sedona = SedonaContext.create(config)
   
   </details>
   
   ```python
   import pyarrow as pa
   from pyspark.sql.types import StringType, StructType
   
   from sedona.utils.geoarrow import dataframe_to_arrow
   
   test_wkt = ["POINT (0 1)", "LINESTRING (0 1, 2 3)"]
   
   schema = StructType().add("wkt", StringType())
   wkt_df = sedona.createDataFrame(zip(test_wkt), schema)
   
   # No geometry
   dataframe_to_arrow(wkt_df)
   #> pyarrow.Table
   #> wkt: string
   #> ----
   #> wkt: [["POINT (0 1)"],["LINESTRING (0 1, 2 3)"]]
   
   # With geometry (not yet implemented)
   geo_df = wkt_df.selectExpr("ST_GeomFromText(wkt) AS geom")
   dataframe_to_arrow(geo_df)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to