0

I am currently working on a project that involves calculating the area of a circumference with a radius of 0.001 degrees -created via buffer-, centered at latitude -4 and longitude -63. The resulting geometry is on geographical coordinates (EPSG:4326). To obtain precise measurements in squared meters times 0.0001, I try to convert the data into two coordinate systems: UTM 20S (EPSG:31980) and WGS 84 (EPSG:3857).

To perform these calculations, I utilized GeoPandas and Apache Sedona, but I encountered a significant discrepancy in the results obtained from the two libraries. Here is the original Schema:

root
 |-- Zona_UTM: long (nullable = true)
 |-- Hemisferio: string (nullable = true)
 |-- EPSG: string (nullable = true)
 |-- Latitude: double (nullable = true)
 |-- Longitude: double (nullable = true)
 |-- geometry: geometry (nullable = true)

And here is the code I used for the calculations:

sample_df['area_3857_gpd'] = sample_df.to_crs(3857).geometry.area*0.0001
sample_df['area_utm_gpd'] = sample_df.to_crs(31980).geometry.area*0.0001

spark.createDataFrame(sample_df).createOrReplaceTempView('sample_df')

query = """SELECT *
    , ST_Area(ST_Transform(geometry, 'epsg:4326', CONCAT('epsg:',EPSG), false))*0.0001 as area_utm_sedona
    , ST_Area(ST_Transform(geometry, 'epsg:4326', 'epsg:3857', false))*0.0001 as area_3857_sedona
FROM sample_df
"""

sample_df = spark.sql(query)
sample_df = sample_df.toPandas()
sample_df['area_unit_of_measure'] = 'ha'

The area calculations conducted with GeoPandas yielded the following results:

area_3857_gpd: 3.9019353 ha

area_utm_gpd: 3.85412083 ha

However, when I employed Apache Sedona to perform the same calculations, the results differed significantly:

area_utm_sedona: 2.07367218 ha

area_3857_sedona: 8.573814622 ha

Additionally, I have cross-validated the results obtained with GeoPandas by performing the same area calculations using QGIS. The results obtained with GeoPandas match those obtained from QGIS. Hence, the issue seems to lie specifically with the Apache Sedona library.

Do you have any insights or suggestions so I can understand the cause of this discrepancy between GeoPandas and Apache Sedona? Are there any known differences or considerations when using these libraries for area calculations?

2
  • 1
    Can't help with your question, just noting that EPS3857 is a poor choice for calculating area as it distorts shape and area. It's designed for web mapping, not for analysis.
    – user2856
    Commented May 29, 2023 at 20:29
  • Thanks for the heads up! Commented May 30, 2023 at 16:58

1 Answer 1

0

The main distinction between Apache Sedona and GeoPandas lies in the standard format of geographical coordinates. In Sedona, the ST_Transform function follows the lat/lon order, whereas GeoPandas adopts the lon/lat order. However, by applying the ST_FlipCoordinates function prior to transforming the projection system, we were able to achieve consistent results between the two libraries. This simple adjustment helped ensure convergence in our outcomes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.