Skip to content

Commit ae0b48d

Browse files
author
Médéric RIBREUX
committed
Add v.vect.stats algorithm
1 parent 2139d5f commit ae0b48d

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
v.vect.stats
2+
Count points in areas and calculate statistics.
3+
Vector (v.*)
4+
ParameterVector|points|Name of existing vector map with points|0|False
5+
ParameterVector|areas|Name of existing vector map with areas|2|False
6+
ParameterSelection|method|Method for aggregate statistics|sum;average;median;mode;minimum;min_cat;maximum;max_cat;range;stddev;variance;diversity|0
7+
ParameterTableField|points_column|Column name of points map to use for statistics|points|0|False
8+
ParameterString|count_column|Column name to upload points count (integer, created if doesn't exists)|None|False|False
9+
ParameterString|stats_column|Column name to upload statistics (double, created if doesn't exists)|None|False|False
10+
OutputVector|output|Updated
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
v_vect_stats.py
6+
---------------
7+
Date : March 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'March 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
29+
import os
30+
31+
32+
def processCommand(alg):
33+
# exclude output for from_output
34+
output = alg.getOutputFromName('output')
35+
alg.removeOutputFromName('output')
36+
37+
alg.processCommand()
38+
alg.addOutput(output)
39+
40+
41+
def processOutputs(alg):
42+
# We need to add the vector layer to outputs:
43+
out = alg.exportedLayers[alg.getParameterValue('areas')]
44+
from_out = alg.getOutputValue('output')
45+
command = u"v.out.ogr -s -e input={} output=\"{}\" format=ESRI_Shapefile output_layer={}".format(
46+
out, os.path.dirname(from_out),
47+
os.path.splitext(os.path.basename(from_out))[0]
48+
)
49+
alg.commands.append(command)
50+
alg.outputCommands.append(command)

0 commit comments

Comments
 (0)