Skip to content
Permalink
Browse files

Merge pull request #2904 from medspx/processing_vector_bunch

[Processing] GRASS7 complete v.* algorithms (implements Redmine #5725)
  • Loading branch information
volaya committed Mar 18, 2016
2 parents 839db0a + d318981 commit 2942ce576b28913ded7b1498a7116f3261995fd0
Showing with 922 additions and 0 deletions.
  1. +6 −0 python/plugins/processing/algs/grass7/description/v.build.check.txt
  2. +6 −0 python/plugins/processing/algs/grass7/description/v.build.polylines.txt
  3. +24 −0 python/plugins/processing/algs/grass7/description/v.edit.txt
  4. +14 −0 python/plugins/processing/algs/grass7/description/v.extrude.txt
  5. +17 −0 python/plugins/processing/algs/grass7/description/v.in.ascii.points.txt
  6. +9 −0 python/plugins/processing/algs/grass7/description/v.in.ascii.standard.txt
  7. +5 −0 python/plugins/processing/algs/grass7/description/v.in.geonames.txt
  8. +10 −0 python/plugins/processing/algs/grass7/description/v.in.lidar.txt
  9. +7 −0 python/plugins/processing/algs/grass7/description/v.in.lines.txt
  10. +7 −0 python/plugins/processing/algs/grass7/description/v.in.mapgen.txt
  11. +13 −0 python/plugins/processing/algs/grass7/description/v.kernel.rast.txt
  12. +16 −0 python/plugins/processing/algs/grass7/description/v.kernel.vect.txt
  13. +15 −0 python/plugins/processing/algs/grass7/description/v.lrs.create.txt
  14. +8 −0 python/plugins/processing/algs/grass7/description/v.lrs.segment.txt
  15. +8 −0 python/plugins/processing/algs/grass7/description/v.lrs.where.txt
  16. +9 −0 python/plugins/processing/algs/grass7/description/v.out.vtk.txt
  17. +6 −0 python/plugins/processing/algs/grass7/description/v.pack.txt
  18. +10 −0 python/plugins/processing/algs/grass7/description/v.rast.stats.txt
  19. +13 −0 python/plugins/processing/algs/grass7/description/v.rectify.txt
  20. +8 −0 python/plugins/processing/algs/grass7/description/v.to.3d.txt
  21. +6 −0 python/plugins/processing/algs/grass7/description/v.to.lines.txt
  22. +7 −0 python/plugins/processing/algs/grass7/description/v.type.txt
  23. +10 −0 python/plugins/processing/algs/grass7/description/v.vect.stats.txt
  24. +9 −0 python/plugins/processing/algs/grass7/description/v.what.vect.txt
  25. +40 −0 python/plugins/processing/algs/grass7/ext/v_build_polylines.py
  26. +74 −0 python/plugins/processing/algs/grass7/ext/v_edit.py
  27. +36 −0 python/plugins/processing/algs/grass7/ext/v_extrude.py
  28. +34 −0 python/plugins/processing/algs/grass7/ext/v_in_geonames.py
  29. +39 −0 python/plugins/processing/algs/grass7/ext/v_in_lidar.py
  30. +46 −0 python/plugins/processing/algs/grass7/ext/v_lrs_create.py
  31. +72 −0 python/plugins/processing/algs/grass7/ext/v_lrs_segment.py
  32. +51 −0 python/plugins/processing/algs/grass7/ext/v_lrs_where.py
  33. +34 −0 python/plugins/processing/algs/grass7/ext/v_pack.py
  34. +50 −0 python/plugins/processing/algs/grass7/ext/v_rast_stats.py
  35. +67 −0 python/plugins/processing/algs/grass7/ext/v_rectify.py
  36. +36 −0 python/plugins/processing/algs/grass7/ext/v_to_3d.py
  37. +50 −0 python/plugins/processing/algs/grass7/ext/v_vect_stats.py
  38. +50 −0 python/plugins/processing/algs/grass7/ext/v_what_vect.py
@@ -0,0 +1,6 @@
v.build
v.build.check - Checks for topological errors.
Vector (v.*)
ParameterVector|map|Name of vector map|-1|False
Hardcoded|-e
OutputVector|error|Topological errors
@@ -0,0 +1,6 @@
v.build.polylines
Builds polylines from lines or boundaries.
Vector (v.*)
ParameterVector|input|Name of input vector map|-1|False
ParameterSelection|cats|Category number mode|no;first;multi|0
OutputVector|output|Polylines
@@ -0,0 +1,24 @@
v.edit
Edits a vector map, allows adding, deleting and modifying selected vector features.
Vector (v.*)
ParameterVector|map|Name of vector layer|-1|False
ParameterSelection|tool|Tool|add;delete;copy;move;flip;merge;break;snap;connect;vertexadd;vertexdel;vertexmove;zbulk|0
ParameterString|input_txt|Inline input for add tool|None|True|True
ParameterFile|input|ASCII file for add tool|False|True
ParameterString|move|Difference in x,y,z direction for moving feature or vertex|None|False|True
ParameterString|threshold|Threshold distance (coords,snap,query)|None|False|True
ParameterString|ids|Feature ids|None|False|True
ParameterString|coords|List of point coordinates|None|False|True
ParameterString|bbox|Bounding box for selecting features|None|False|True
ParameterString|polygon|Polygon for selecting features|None|False|True
ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|None|True|True
ParameterString|query|Query tool (in length,dangle)|None|False|True
ParameterVector|bgmap|Name of background vector map|-1|True
ParameterString|snap|Snap added or modified features in the given threshold to the nearest existing feature (Options: no,node,vertex)|None|False|True
ParameterString|zbulk|Starting value and step for z bulk-labeling. Pair: value,step (e.g. 1100,10)|None|False|True
ParameterBoolean|-r|Reverse selection|False
ParameterBoolean|-c|Close added boundaries (using threshold distance)|False
ParameterBoolean|-n|Do not expect header of input data|False
ParameterBoolean|-t|Do not build topology|False
ParameterBoolean|-1|Modify only first found feature in bounding box|False
OutputVector|output|Edited
@@ -0,0 +1,14 @@
v.extrude
Extrudes flat vector object to 3D with defined height.
Vector (v.*)
ParameterVector|input|Name of input 2D vector map|-1|False
ParameterString|where|WHERE conditions of SQL statement without 'where' keyword|None|True|True
ParameterNumber|zshift|Shifting value for z coordinates|0.0|None|0.0|True
ParameterString|height|Fixed height for 3D vector objects (float)|None|False|True
ParameterTableField|height_column|Name of attribute column with object heights|input|0|True
ParameterRaster|elevation|Elevation raster for height extraction|True
ParameterSelection|method|Sampling interpolation method|nearest;bilinear;bicubic|0
ParameterNumber|scale|Scale factor sampled raster values|0.0|None|1.0|True
ParameterString|null_value|Height for sampled raster NULL values|None|False|True
*ParameterBoolean|-t|Trace elevation|False
OutputVector|output|3D Vector
@@ -0,0 +1,17 @@
v.in.ascii
v.in.ascii.points - Creates a vector map from an ASCII points file.
Vector (v.*)
ParameterFile|input|ASCII file to be imported|False|False
Hardcoded|format=point
ParameterString|separator|Field separator|pipe|False|True
ParameterString|text|Text delimiter|None|False|True
ParameterNumber|skip|Number of header lines to skip at top of input file|0|None|0|True
ParameterString|columns|Column definition in SQL style (example: 'x double precision, y double precision, cat int, name varchar(10)')|None|False|True
ParameterNumber|x|Number of column used as x coordinate|0|None|1|True
ParameterNumber|y|Number of column used as y coordinate|0|None|2|True
ParameterNumber|z|Number of column used as z coordinate|0|None|0|True
ParameterNumber|cat|Number of column used as category|0|None|0|True
*ParameterBoolean|-z|Create 3D vector map|False
*ParameterBoolean|-r|Only import points falling within current region (points mode)|False
*ParameterBoolean|-i|Ignore broken line(s) in points mode|False
OutputVector|output|ASCII Points
@@ -0,0 +1,9 @@
v.in.ascii
v.in.ascii.standard - Creates a vector map from an ASCII vector file.
Vector (v.*)
ParameterFile|input|ASCII file to be imported|False|False
Hardcoded|format=standard
ParameterString|separator|Field separator|pipe|False|True
*ParameterBoolean|-z|Create 3D vector map|False
*ParameterBoolean|-n|Do not expect a header when reading in standard format|False
OutputVector|output|ASCII Vector
@@ -0,0 +1,5 @@
v.in.geonames
Imports geonames.org country files into a GRASS vector points map.
Vector (v.*)
ParameterFile|input|Uncompressed geonames file from (with .txt extension)|False|False
OutputVector|output|Geonames
@@ -0,0 +1,10 @@
v.in.lidar
Converts LAS LiDAR point clouds to a GRASS vector map with libLAS.
Vector (v.*)
ParameterFile|input|LiDAR input files in LAS format (*.las or *.laz)|False|False
ParameterExtent|spatial|Import subregion only|None|True
ParameterString|return_filter|Only import points of selected return type (Options: first, last, mid)|None|False|True
ParameterString|class_filter|Only import points of selected class(es) (comma separated integers)|None|False|True
*ParameterBoolean|-t|Do not create attribute table|False
Hardcoded|-o
OutputVector|output|Lidar
@@ -0,0 +1,7 @@
v.in.lines
Import ASCII x,y[,z] coordinates as a series of lines.
Vector (v.*)
ParameterFile|input|ASCII file to be imported|False|False
ParameterString|separator|Field separator|pipe|False|True
*ParameterBoolean|-z|Create 3D vector map|False
OutputVector|output|Lines
@@ -0,0 +1,7 @@
v.in.mapgen
Imports Mapgen or Matlab-ASCII vector maps into GRASS.
Vector (v.*)
ParameterFile|input|Name of input file in Mapgen/Matlab format|False|False
*ParameterBoolean|-z|Create 3D vector map|False
*ParameterBoolean|-f|Input map is in Matlab format|False
OutputVector|output|Mapgen
@@ -0,0 +1,13 @@
v.kernel
v.kernel.rast - Generates a raster density map from vector points map.
Vector (v.*)
ParameterVector|input|Name of input vector map with training points|0|False
ParameterNumber|radius|Kernel radius in map units|0.0|None|10.0|False
ParameterNumber|dsize|Discretization error in map units|0.0|None|0.0|True
ParameterNumber|segmax|Maximum length of segment on network|0.0|None|100.0|True
ParameterNumber|distmax|Maximum distance from point to network|0.0|None|100.0|True
ParameterNumber|multiplier|Multiply the density result by this number|0.0|None|1.0|True
ParameterSelection|node|Node method|none;split|0
ParameterSelection|kernel|Kernel function|cosine;gaussian;epanechnikov;quartic;triangular;triweight;uniform|1
*ParameterBoolean|-o|Try to calculate an optimal radius with given 'radius' taken as maximum (experimental)|False
OutputRaster|output|Kernel
@@ -0,0 +1,16 @@
v.kernel
v.kernel.vector - Generates a vector density map from vector points on a vector network.
Vector (v.*)
ParameterVector|input|Name of input vector map with training points|0|False
ParameterVector|net|Name of input network vector map|1|False
ParameterNumber|radius|Kernel radius in map units|0.0|None|10.0|False
ParameterNumber|dsize|Discretization error in map units|0.0|None|0.0|True
ParameterNumber|segmax|Maximum length of segment on network|0.0|None|100.0|True
ParameterNumber|distmax|Maximum distance from point to network|0.0|None|100.0|True
ParameterNumber|multiplier|Multiply the density result by this number|0.0|None|1.0|True
ParameterSelection|node|Node method|none;split|0
ParameterSelection|kernel|Kernel function|cosine;gaussian;epanechnikov;quartic;triangular;triweight;uniform|1
*ParameterBoolean|-o|Try to calculate an optimal radius with given 'radius' taken as maximum (experimental)|False
*ParameterBoolean|-n|Normalize values by sum of density multiplied by length of each segment.|False
*ParameterBoolean|-m|Multiply the result by number of input points|False
OutputVector|output|Kernel
@@ -0,0 +1,15 @@
v.lrs.create
Creates Linear Reference System
Vector (v.*)
ParameterVector|in_lines|Input vector map containing lines|1|False
ParameterVector|points|Input vector map containing reference points|0|False
ParameterTableField|lidcol|Column containing line identifiers for lines|in_lines|0|False
ParameterTableField|pidcol|Column containing line identifiers for points|points|0|False
ParameterTableField|start_mp|Column containing milepost position for the beginning of next segment|points|0|False
ParameterTableField|start_off|Column containing offset from milepost for the beginning of next segment|points|0|False
ParameterTableField|end_mp|Column containing milepost position for the end of previous segment|points|0|False
ParameterTableField|end_off|Column containing offset from milepost for the end of previous segment|points|0|False
ParameterNumber|thresh|Maximum distance of point to line allowed|0|None|1|True
OutputVector|out_lines|LRS lines
OutputVector|err|LRS Errors
OutputTable|rstable|RS Table
@@ -0,0 +1,8 @@
v.lrs.segment
Creates points/segments from input lines, linear reference system and positions read from stdin or a file.
Vector (v.*)
ParameterVector|input|Input vector map containing lines|1|False
ParameterTable|rstable|Name of the reference system table|False
ParameterString|in_file|Inline rules for segment|None|True|True
ParameterFile|file|Name of file containing segment rules|False|True
OutputVector|output|Segments
@@ -0,0 +1,8 @@
v.lrs.where
Finds line id and real km+offset for given points in vector map using linear reference system.
Vector (v.*)
ParameterVector|lines|Input vector map containing lines|1|False
ParameterVector|points|Input vector map containing reference points|0|False
ParameterTable|rstable|Name of the reference system table|False
ParameterNumber|thresh|Maximum distance of point to line allowed|0|None|1000|True
OutputFile|output|LRS Points
@@ -0,0 +1,9 @@
v.out.vtk
Converts a vector map to VTK ASCII output.
Vector (v.*)
ParameterVector|input|Name of input vector map|-1|False
ParameterString|precision|Number of significant digits (floating point only)|None|False|True
ParameterNumber|zscale|Scale factor for elevation|0.0|None|1.0|True
*ParameterBoolean|-c|Correct the coordinates to fit the VTK-OpenGL precision|False
*ParameterBoolean|-n|Export numeric attribute table fields as VTK scalar variables|False
OutputFile|output|VTK File
@@ -0,0 +1,6 @@
v.pack
Exports a vector map as GRASS GIS specific archive file.
Vector (v.*)
ParameterVector|input|Name of input vector map to pack|-1|False
*ParameterBoolean|-c|Switch the compression off|False
OutputFile|output|Packed archive
@@ -0,0 +1,10 @@
v.rast.stats
Calculates univariate statistics from a raster map based on vector polygons and uploads statistics to new attribute columns.
Vector (v.*)
ParameterVector|map|Name of vector polygon map|-1|False
ParameterRaster|raster|Name of raster map to calculate statistics from|False
ParameterString|column_prefix|Column prefix for new attribute columns|None|False|False
ParameterString|method|The methods to use (comma separated)|number,minimum,maximum,range,average,stddev,variance,coeff_var,sum,first_quartile,median,third_quartile,percentile|False|True
ParameterNumber|percentile|Percentile to calculate|0|100|90|True
Hardcoded|-c
OutputVector|output|Rast stats
@@ -0,0 +1,13 @@
v.rectify
Rectifies a vector by computing a coordinate transformation for each object in the vector based on the control points.
Vector (v.*)
ParameterVector|input|Name of input vector map|-1|False
ParameterString|inline_points|Inline control points|None|True|True
ParameterFile|points|Name of input file with control points|False|True
ParameterNumber|order|Rectification polynomial order|1|3|1|False
ParameterString|separator|Field separator for RMS report|None|False|True
*ParameterBoolean|-3|Perform 3D transformation|False
*ParameterBoolean|-o|Perform orthogonal 3D transformation|False
*ParameterBoolean|-b|Do not build topology|False
OutputVector|output|Rectified
OutputFile|rmsfile|Root Mean Square errors file
@@ -0,0 +1,8 @@
v.to.3d
Performs transformation of 2D vector features to 3D.
Vector (v.*)
ParameterVector|input|Name of input vector map|-1|False
ParameterString|height|Fixed height for 3D vector features (float)|None|False|True
ParameterTableField|column|Name of attribute column used for height|input|0|True
*ParameterBoolean|-r|Reverse transformation; 3D vector features to 2D|False
OutputVector|output|3D
@@ -0,0 +1,6 @@
v.to.lines
Converts vector polygons or points to lines.
Vector (v.*)
ParameterVector|input|Name of input vector map|-1|False
ParameterSelection|method|Method used for point interpolation|delaunay|0
OutputVector|output|Lines
@@ -0,0 +1,7 @@
v.type
Change the type of geometry elements.
Vector (v.*)
ParameterVector|input|Name of existing vector map|-1|False
ParameterSelection|from_type|Feature type to convert from|point;line;boundary;centroid;face;kernel|1
ParameterSelection|to_type|Feature type to convert to|point;line;boundary;centroid;face;kernel|1
OutputVector|output|Typed
@@ -0,0 +1,10 @@
v.vect.stats
Count points in areas and calculate statistics.
Vector (v.*)
ParameterVector|points|Name of existing vector map with points|0|False
ParameterVector|areas|Name of existing vector map with areas|2|False
ParameterSelection|method|Method for aggregate statistics|sum;average;median;mode;minimum;min_cat;maximum;max_cat;range;stddev;variance;diversity|0
ParameterTableField|points_column|Column name of points map to use for statistics|points|0|False
ParameterString|count_column|Column name to upload points count (integer, created if doesn't exists)|None|False|False
ParameterString|stats_column|Column name to upload statistics (double, created if doesn't exists)|None|False|False
OutputVector|output|Updated
@@ -0,0 +1,9 @@
v.what.vect
Uploads vector values at positions of vector points to the table.
Vector (v.*)
ParameterVector|map|Name of vector points map for which to edit attributes|0|False
ParameterTableField|column|Column to be updated with the query result|map|-1|False
ParameterVector|query_map|Vector map to be queried|-1|False
ParameterTableField|query_column|Column to be queried|query_map|-1|False
ParameterNumber|dmax|Maximum query distance in map units|0.0|None|0.0|True
OutputVector|output|Updated
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
v_build_polylines.py
--------------------
Date : March 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Médéric Ribreux'
__date__ = 'March 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'


import os


def processOutputs(alg):
out = alg.getOutputValue('output')
command = u"v.out.ogr -c -s -e input={} output=\"{}\" format=ESRI_Shapefile output_layer={}".format(
alg.exportedLayers[out],
os.path.dirname(out),
os.path.splitext(os.path.basename(out))[0]
)
alg.commands.append(command)
alg.outputCommands.append(command)
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
v_edit.py
---------
Date : March 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Médéric Ribreux'
__date__ = 'March 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'


import os


def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
if alg.getParameterValue('input_txt') and alg.getParameterValue(u'input'):
return alg.tr("You need to set either an input ASCII file or inline data!")

return None


def processCommand(alg):
# handle inline add data
input_txt = alg.getParameterFromName('input_txt')
inputParameter = alg.getParameterFromName('input')
if input_txt.value:
# Creates a temporary txt file
ruleFile = alg.getTempFilename()

# Inject rules into temporary txt file
with open(ruleFile, "w") as tempRules:
tempRules.write(input_txt.value)
inputParameter.value = ruleFile
alg.parameters.remove(input_txt)

# exclude output for from_output
output = alg.getOutputFromName('output')
alg.removeOutputFromName('output')

alg.processCommand()
alg.addOutput(output)
if input_txt.value:
inputParameter.value = None
alg.addParameter(input_txt)


def processOutputs(alg):
# We need to add the from layer to outputs:
out = alg.exportedLayers[alg.getParameterValue('map')]
from_out = alg.getOutputValue('output')
command = u"v.out.ogr -s -e input={} output=\"{}\" format=ESRI_Shapefile output_layer={}".format(
out, os.path.dirname(from_out),
os.path.splitext(os.path.basename(from_out))[0]
)
alg.commands.append(command)
alg.outputCommands.append(command)

0 comments on commit 2942ce5

Please sign in to comment.
You can’t perform that action at this time.