Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geomesa-users] problem with Geomesa SparkSQL function st_area

Hello,

In GeoTools (which is the API GeoMesa implements), area is calculated in the native units of the CRS for your geometry. GeoMesa stores everything in EPSG:4326, so by default you will get areas in degrees, as you found. However, you can can project results to a different CRS when you query it, so if you project to a CRS with native units of meters, you will get area in meters squared.

Unfortunately, projection on query has not been implemented in Spark yet. However, once you have a data frame, you can map your geometry and use GeoTools to project it by hand. In order to project, you can use the following code snippet:

    import org.geotools.geometry.jts.JTS
    import org.geotools.referencing.CRS
   
    val transform = CRS.findMathTransform(CRS.decode("EPSG:4326"), CRS.decode(epsg), lenient))
    JTS.transform(geom, transform)

Hope that helps,

Emilio

On 3/21/19 2:15 AM, 邓鹏 wrote:

Hello,

    I am new to geomesa and recently I am researching on geo-bigdata, I have some problems with geomesa-spark. The problem is, when I use SparkSQL function st_area (https://www.geomesa.org/documentation/user/spark/sparksql_functions.html?highlight=st_area#st-area) to calculate the area of a geometry(for example a lake), the result I get is so small like 1.23e-7, I find that the unit seems to be degree^2 but not meter^2

    I ingested the data into geomesa accumulo with EPSG:4326, actually it has no projection, so I tried to find a way to project the data to a specific Projection Coordinate System like EPSG:4326 before calculating area, but I dont't find one.

    I also found a projectFrom function in geomesa convert transformation on geomesa documentation web page(https://www.geomesa.org/documentation/user/convert/function_usage.html?highlight=epsg#projectfrom), it says GeoMesa only supports EPSG:4326, so geometries must be transformed when ingesting from another CRS, so projection before ingesting may not work.

    Is the a way to project data so that I can get the area with the correct unit meter^2. Any help will be so appreciated.

    Thank you!




Victor

School of Resource and Environmental Sciences, Wuhan University



_______________________________________________
geomesa-users mailing list
geomesa-users@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geomesa-users


Back to the top