WikiWatershed / mmw-geoprocessing

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

MapShed: Add Aggregate Endpoint #34

Closed rajadain closed 8 years ago

rajadain commented 8 years ago

Add a RasterAggregateSum operation which works similarly to RasterJoin, but instead of the count for each pairing returns instead the sum of the values in a particular raster for each pairing.

For example, consider three rasters: NLCD with int values, Soil Group with int values, and K-Factor with float32 values. We would like an output of the form:

{
  "result": {
    "List(11, 1)": 0.2345,
    "List(11, 2)": 0.1234,
    "List(21, 3)": 0.3456,
  }
}

Where the numbers in the key correspond to NLCD and Soil Group, and the value corresponds to the sum of K-Factor values.

The input JSON may be of the form:

{
  "input": {
    "polygon": [
      "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-75.1626205444336,39.95580659996906],[-75.25531768798828,39.94514735903112],[-75.22785186767578,39.89446035777916],[-75.1461410522461,39.88761144548104],[-75.09309768676758,39.91078961774283],[-75.09464263916016,39.93817189499188],[-75.12039184570312,39.94435771955196],[-75.1626205444336,39.95580659996906]]]]}"
    ],
    "polygonCRS": "LatLng",
    "rasters": [
      "nlcd-2011-30m-epsg5070-0.10.0",
      "ssurgo-hydro-groups-30m-epsg5070-0.10.0"
    ],
    "rasterCRS": "ConusAlbers",
    "aggregate": "us-ssugro-kfactor-30m-epsg5070",
    "aggregateCRS": "ConusAlbers",
    "operationType": "RasterAggregateSum",
    "zoom": 0
  }
}

The exact naming of the fields is negotiable. If it is considerably difficult to do this for multiple rasters as keys, we could potentially get away with using only one for now, but would really prefer to use multiple as it will be used in the future.