Open-EO / openeo-geotrellis-extensions

Java/Scala extensions for Geotrellis, for use with OpenEO GeoPySpark backend.
Apache License 2.0
5 stars 4 forks source link

projection error when working with large set of points #60

Open jdries opened 2 years ago

jdries commented 2 years ago

https://discuss.eodc.eu/t/fit-class-random-forest-413-request-too-large/396/10

Error happened when running dynamic landcover on large set of points:

https://github.com/patrick-griffiths/scratch/blob/main/y_json2.json


File "/opt/venv/lib64/python3.8/site-packages/openeogeotrellis/backend.py", line 1317, in _scheduled_sentinelhub_batch_processes
    actual_area = area()
  File "/opt/venv/lib64/python3.8/site-packages/openeogeotrellis/backend.py", line 1311, in area
    return (self._jvm
  File "/usr/local/spark/python/lib/py4j-0.10.9.2-src.zip/py4j/java_gateway.py", line 1309, in __call__
    return_value = get_return_value(
  File "/usr/local/spark/python/lib/py4j-0.10.9.2-src.zip/py4j/protocol.py", line 326, in get_return_value
    raise Py4JJavaError(
py4j.protocol.Py4JJavaError: An error occurred while calling o1048.areaInSquareMeters.
: org.locationtech.proj4j.ProjectionException: -21
    at org.locationtech.proj4j.proj.AlbersProjection.initialize(AlbersProjection.java:126)
    at org.locationtech.proj4j.parser.Proj4Parser.parseProjection(Proj4Parser.java:180)
    at org.locationtech.proj4j.parser.Proj4Parser.parse(Proj4Parser.java:57)
    at org.locationtech.proj4j.CRSFactory.createFromParameters(CRSFactory.java:127)
    at org.locationtech.proj4j.CRSFactory.createFromParameters(CRSFactory.java:106)
    at org.locationtech.proj4j.util.CRSCache.lambda$createFromParameters$1(CRSCache.java:52)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
    at org.locationtech.proj4j.util.CRSCache.createFromParameters(CRSCache.java:52)
    at geotrellis.proj4.CRS$$anon$1.<init>(CRS.scala:41)
    at geotrellis.proj4.CRS$.fromString(CRS.scala:41)
    at org.openeo.geotrellis.ProjectedPolygons$.org$openeo$geotrellis$ProjectedPolygons$$areaInSquareMeters(ProjectedPolygons.scala:167)
    at org.openeo.geotrellis.ProjectedPolygons.areaInSquareMeters(ProjectedPolygons.scala:16)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jdries commented 2 years ago

The error indeed occurred when doing: ProjectedPolygons.fromVectorFile("https://raw.githubusercontent.com/patrick-griffiths/scratch/main/y_json2.json").areaInSquareMeters because the list of geometries is filtered to MultiPolygon, which is kind of correct because points and lines don't have an area. These will now also return 0.0, but not yet sure if this will result in the right behaviour. (Points will eventually have to be mapped to pixels, that do have an area.)