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?