def multi_subbasin(parent_aoi, child_shapes, layer_overrides={}): shapes = [{'id': wkaoi, 'shape': aoi} for (wkaoi, _, aoi) in child_shapes] datasource = get_layer_value('__STREAMS__', layer_overrides) stream_lines = streams(parent_aoi, datasource) return multi.s('mapshed', shapes, stream_lines, layer_overrides=layer_overrides)
def multi_mapshed(aoi, wkaoi, layer_overrides={}): shape = [{'id': wkaoi or NOCACHE, 'shape': aoi}] datasource = get_layer_value('__STREAMS__', layer_overrides) stream_lines = streams(aoi, datasource) return multi.s('mapshed', shape, stream_lines, layer_overrides=layer_overrides)
def geoprocessing_chains(aoi, wkaoi, errback): task_defs = [ ('nlcd_soil', nlcd_soil, {'polygon': [aoi]}), ('soiln', soiln, {'polygon': [aoi]}), ('soilp', soilp, {'polygon': [aoi]}), ('recess_coef', recess_coef, {'polygon': [aoi]}), ('gwn', gwn, {'polygon': [aoi]}), ('avg_awc', avg_awc, {'polygon': [aoi]}), ('nlcd_slope', nlcd_slope, {'polygon': [aoi]}), ('slope', slope, {'polygon': [aoi]}), ('nlcd_kfactor', nlcd_kfactor, {'polygon': [aoi]}), ('nlcd_streams', nlcd_streams, {'polygon': [aoi], 'vector': streams(aoi)}), ] return [ run.s(opname, data, wkaoi) | callback.s().set(link_error=errback) for (opname, callback, data) in task_defs ]
def start_analyze_streams(request, format=None): """ Starts a job to display streams & stream order within a given area of interest. For more information, see the [technical documentation](https://wikiwatershedorg/documentation/ mmw-tech/#additional-data-layers) ## Response You can use the URL provided in the response's `Location` header to poll for the job's results. <summary> **Example of a completed job's `result`** </summary> <details> { "survey": { "displayName": "Streams", "name": "streams", "categories": [ { "lengthkm": 2.598, "total_weighted_slope": 0.05225867338, "order": 1, "ag_stream_pct": 0.003416856492027335, "avgslope": 0.020114962809853736 }, { "lengthkm": 0, "total_weighted_slope": null, "order": 2, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { lengthkm": 0, total_weighted_slope": null, order": 3, ag_stream_pct": 0.003416856492027335, avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 4, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 5, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 21.228, "total_weighted_slope": 0.00577236831, "order": 6, "ag_stream_pct": 0.003416856492027335, "avgslope": 0.0002719223812888637 }, { "lengthkm": 0, "total_weighted_slope": null, "order": 7, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 8, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 9, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 10, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 6.085, "total_weighted_slope": null, "order": 999, "ag_stream_pct": 0.003416856492027335, "avgslope": null } ] } } </details> --- type: job: required: true type: string status: required: true type: string omit_serializer: true parameters: - name: body description: A valid single-ringed Multipolygon GeoJSON representation of the shape to analyze. See the GeoJSON spec https://tools.ietf.org/html/rfc7946#section-3.1.7 paramType: body type: object - name: wkaoi paramType: query description: The table and ID for a well-known area of interest, such as a HUC. Format "table__id", eg. "huc12__55174" will analyze the HUC-12 City of Philadelphia-Schuylkill River. - name: Authorization paramType: header description: Format "Token YOUR_API_TOKEN_HERE". When using Swagger you may wish to set this for all requests via the field at the top right of the page. consumes: - application/json produces: - application/json """ user = request.user if request.user.is_authenticated() else None area_of_interest, wkaoi = _parse_input(request) return start_celery_job([ geoprocessing.run.s('nlcd_streams', { 'polygon': [area_of_interest], 'vector': streams(area_of_interest) }, wkaoi), nlcd_streams.s(), tasks.analyze_streams.s(area_of_interest) ], area_of_interest, user)
def multi_subbasin(parent_aoi, child_shapes): shapes = [{'id': wkaoi, 'shape': aoi} for (wkaoi, _, aoi) in child_shapes] stream_lines = streams(parent_aoi)[0] return multi.s('mapshed', shapes, stream_lines)
def multi_mapshed(aoi, wkaoi): shape = [{'id': wkaoi or NOWKAOI, 'shape': aoi}] stream_lines = streams(aoi)[0] return multi.s('mapshed', shape, stream_lines)
def start_analyze_streams(request, format=None): """ Starts a job to display streams & stream order within a given area of interest. For more information, see the [technical documentation](https://wikiwatershedorg/documentation/ mmw-tech/#additional-data-layers) ## Response You can use the URL provided in the response's `Location` header to poll for the job's results. <summary> **Example of a completed job's `result`** </summary> <details> { "survey": { "displayName": "Streams", "name": "streams", "categories": [ { "lengthkm": 2.598, "total_weighted_slope": 0.05225867338, "order": 1, "ag_stream_pct": 0.003416856492027335, "avgslope": 0.020114962809853736 }, { "lengthkm": 0, "total_weighted_slope": null, "order": 2, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { lengthkm": 0, total_weighted_slope": null, order": 3, ag_stream_pct": 0.003416856492027335, avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 4, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 5, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 21.228, "total_weighted_slope": 0.00577236831, "order": 6, "ag_stream_pct": 0.003416856492027335, "avgslope": 0.0002719223812888637 }, { "lengthkm": 0, "total_weighted_slope": null, "order": 7, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 8, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 9, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 0, "total_weighted_slope": null, "order": 10, "ag_stream_pct": 0.003416856492027335, "avgslope": null }, { "lengthkm": 6.085, "total_weighted_slope": null, "order": 999, "ag_stream_pct": 0.003416856492027335, "avgslope": null } ] } } </details> """ user = request.user if request.user.is_authenticated else None area_of_interest, wkaoi = _parse_input(request) return start_celery_job([ geoprocessing.run.s('nlcd_streams', { 'polygon': [area_of_interest], 'vector': streams(area_of_interest) }, wkaoi), nlcd_streams.s(), tasks.analyze_streams.s(area_of_interest) ], area_of_interest, user)