You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "pszhuchkov (via GitHub)" <gi...@apache.org> on 2024/02/16 07:46:07 UTC
[I] Map RDD and GeometryType (not an instance of type GeometryType()) [sedona]
pszhuchkov opened a new issue, #1237:
URL: https://github.com/apache/sedona/issues/1237
## Expected behavior
I want to define a schema that includes `GeometryType` for a dataframe after using RDD map function.
## Actual behavior
`ValueError: field geom: <shapely.geometry.point.Point object at 0x7fa204b85750> is not an instance of type GeometryType()`
## Steps to reproduce the problem
Adjusted test case from tutorials
```Python
from pyspark.sql.types import IntegerType, StructField, StructType
from sedona.sql.types import GeometryType
schema = StructType(
[
StructField("id", IntegerType(), False),
StructField("geom", GeometryType(), False)
]
)
from shapely.geometry import Point
data = [
[1, Point(21.0, 52.0)],
[1, Point(23.0, 42.0)],
[1, Point(26.0, 32.0)]
]
gdf = spark.createDataFrame(
data,
schema
)
gdf.show()
def dummy_map(row):
# some logic here
return row
test_df = gdf.rdd.map(dummy_map).toDF(gdf.schema)
# or test_df = gdf.rdd.map(dummy_map).toDF(schema)
```
## Settings
Sedona version = 1.5.1
Apache Spark version = Spark 3.3.0
API type = Python
Environment = EMR 6.9.0
--
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: dev-unsubscribe@sedona.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Map RDD and GeometryType (not an instance of type GeometryType()) [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on issue #1237:
URL: https://github.com/apache/sedona/issues/1237#issuecomment-1953568922
@pszhuchkov This can be done by explicitly disabling the schema verification.
```
test_rdd = gdf.rdd.map(dummy_map)
sedona.createDataFrame(test_rdd, schema, verifySchema=False).show()
```
Example:
https://github.com/apache/sedona/blob/master/binder/ApacheSedonaCore.ipynb
--
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: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Map RDD and GeometryType (not an instance of type GeometryType()) [sedona]
Posted by "pszhuchkov (via GitHub)" <gi...@apache.org>.
pszhuchkov commented on issue #1237:
URL: https://github.com/apache/sedona/issues/1237#issuecomment-1953880000
@jiayuasu gotcha, it works. Thanks a lot!
--
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: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Map RDD and GeometryType (not an instance of type GeometryType()) [sedona]
Posted by "pszhuchkov (via GitHub)" <gi...@apache.org>.
pszhuchkov closed issue #1237: Map RDD and GeometryType (not an instance of type GeometryType())
URL: https://github.com/apache/sedona/issues/1237
--
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: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org