WikiWatershed / mmw-geoprocessing

A Spark Job Server job for Model My Watershed geoprocessing.
Apache License 2.0
6 stars 6 forks source link

Allow pixels to be treated as areas on demand #74

Closed rajadain closed 6 years ago

rajadain commented 6 years ago

Overview

Previously, we would always treat raster pixels as points, so if a pixel's centroid was covered in an area of interest it would be included, otherwise not. For certain rasters, where the pixel sizes are very large, for small areas of interest, no pixels are included since the areas do not cover their centroids.

By allowing the calling JSON to specify whether to treat pixels as points or areas, we allow treating certain rasters (as determined by the caller) as having pixels as areas, which will make small areas of interests run again.

Connects https://github.com/WikiWatershed/model-my-watershed/issues/2253

Demo

image

$ http --print HhBb :8090/run < SquareKmPpt.json

POST /run HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 498
Content-Type: application/json
Host: localhost:8090
User-Agent: HTTPie/0.9.9

{
    "input": {
        "operationType": "RasterGroupedAverage",
        "pixelIsArea": true,
        "polygon": [
            "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-75.17123123758348,39.94946918388007],[-75.1595030153462,39.94946918388007],[-75.1595030153462,39.95845957765271],[-75.17123123758348,39.95845957765271],[-75.17123123758348,39.94946918388007]]]]}"
        ],
        "polygonCRS": "LatLng",
        "rasterCRS": "ConusAlbers",
        "rasters": [],
        "targetRaster": "climatology-ppt-09-epsg5070",
        "zoom": 0
    }
}

HTTP/1.1 200 OK
Content-Length: 40
Content-Type: application/json
Date: Wed, 13 Sep 2017 21:55:48 GMT
Server: akka-http/10.0.9

{
    "result": {
        "List(0)": 93.80207061767578
    }
}

Testing Instructions

diff --git a/src/mmw/mmw/settings/base.py b/src/mmw/mmw/settings/base.py
index 8349e16..409a032 100644
--- a/src/mmw/mmw/settings/base.py
+++ b/src/mmw/mmw/settings/base.py
@@ -536,6 +536,7 @@ GEOP = {
                 'polygonCRS': 'LatLng',
                 'rasters': [],
                 'targetRaster': 'climatology-ppt-{:02d}-epsg5070',
+                'pixelIsArea': True,
                 'rasterCRS': 'ConusAlbers',
                 'operationType': 'RasterGroupedAverage',
                 'zoom': 0
@@ -547,6 +548,7 @@ GEOP = {
                 'polygonCRS': 'LatLng',
                 'rasters': [],
                 'targetRaster': 'climatology-tmean-{:02d}-epsg5070',
+                'pixelIsArea': True,
                 'rasterCRS': 'ConusAlbers',
                 'operationType': 'RasterGroupedAverage',
                 'zoom': 0
kellyi commented 6 years ago

Here's the current output from develop when posting the above file:

{
    "result": {
        "List(0)": null
    }
}

... and here's the output from this branch:

{
    "result": {
        "List(0)": 93.80207061767578
    }
}
kellyi commented 6 years ago

Tried out the prior operations & the values remain the same as on develop.

kellyi commented 6 years ago

Seeing values for 1 sq km in MMW:

screen shot 2017-09-14 at 1 03 03 pm
kellyi commented 6 years ago

This looks good to me!

I tested it with the jar and in MMW/BigCZ and both worked as described above. The values for the existing operations remained the same post-pixelIsArea, and the value for the new pixel op is now coming back as not null.