Merge pull request #2904 from medspx/processing_vector_bunch

[Processing] GRASS7 complete v.* algorithms (implements Redmine #5725)
This commit is contained in:
volaya 2016-03-18 14:20:13 +01:00
commit 2942ce576b
38 changed files with 922 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View 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

View File

@ -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

View File

@ -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

View 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_extrude.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$'
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
height = alg.getParameterValue('height')
height_column = alg.getParameterValue('height_column')
if (height and height_column) or (not height and not height_column):
return alg.tr("You need to set either a fixed height value or the height column!")
return None

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_in_geonames.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$'
def processCommand(alg):
# v.in.geonames needs to use WGS84 projection
alg.commands.append('g.proj -c epsg=4326')
# Launch the algorithm
alg.processCommand()

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_in_lidar.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$'
def processCommand(alg):
# Handle the extent
extent = alg.getParameterFromName('spatial')
oldExtent = extent.value
if extent.value:
l = extent.value.split(',')
extent.value = ','.join([l[0], l[2], l[1], l[3]])
alg.processCommand()
if extent.value:
extent.value = oldExtent

View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_lrs_create.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):
# add some export commands
command = 'v.build.all'
alg.commands.append(command)
# export the SQLite table to CSV
rstable = alg.getOutputValue('rstable')
# I don't use db.out.ogr because it doesn't work
command = 'db.select table={} separator=comma output=\"{}\" --overwrite'.format(
alg.exportedLayers[rstable],
rstable
)
alg.commands.append(command)
command = 'echo \"Integer\",\"Integer\",\"Integer\",\"Real\",\"Real\",\"Real\",\"Real\",\"Real\",\"Real\",\"Real\" > \"{}t\"'.format(rstable)
alg.commands.append(command)
alg.processOutputs()

View File

@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_lrs_segment.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$'
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
if alg.getParameterValue('in_file') and alg.getParameterValue(u'file'):
return alg.tr("You need to set either a segment rules file or write directly the rules!")
return None
def processInputs(alg):
# We need to import the rstable
rstable = alg.getParameterValue('rstable')
if rstable in alg.exportedLayers.keys():
return
alg.exportedLayers[rstable] = alg.getTempFilename()
command = 'db.in.ogr input=\"{}\" output={} --overwrite'.format(
rstable,
alg.exportedLayers[rstable]
)
alg.commands.append(command)
alg.processInputs()
def processCommand(alg):
in_file = alg.getParameterValue('in_file')
if in_file:
# Creates a temporary txt file
ruleFile = alg.getTempFilename()
# Inject rules into temporary txt file
with open(ruleFile, "w") as tempRules:
tempRules.write(in_file)
else:
ruleFile = alg.getParameterValue('file')
output = alg.getOutputFromName(u'output')
alg.exportedLayers[output.value] = output.name + alg.uniqueSufix
command = 'v.lrs.segment input={} file={} rstable={} output={} --overwrite'.format(
alg.exportedLayers[alg.getParameterValue('input')],
ruleFile,
alg.exportedLayers[alg.getParameterValue('rstable')],
alg.exportedLayers[output.value]
)
alg.commands.append(command)

View File

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_lrs_where.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$'
def processInputs(alg):
# We need to import the rstable
rstable = alg.getParameterValue('rstable')
if rstable in alg.exportedLayers.keys():
return
alg.exportedLayers[rstable] = alg.getTempFilename()
command = 'db.in.ogr input=\"{}\" output={} --overwrite'.format(
rstable,
alg.exportedLayers[rstable]
)
alg.commands.append(command)
alg.processInputs()
def processCommand(alg):
command = 'v.lrs.where lines={} points={} rstable={} thresh={} > {} --overwrite'.format(
alg.exportedLayers[alg.getParameterValue('lines')],
alg.exportedLayers[alg.getParameterValue('points')],
alg.exportedLayers[alg.getParameterValue('rstable')],
alg.getParameterValue('thresh'),
alg.getOutputValue('output')
)
alg.commands.append(command)

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_pack.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$'
def processCommand(alg):
command = 'v.pack input={} output={} --overwrite'.format(
alg.exportedLayers[alg.getParameterValue('input')],
alg.getOutputValue('output')
)
alg.commands.append(command)

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_rast_stats.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 processCommand(alg):
# exclude output for from_output
output = alg.getOutputFromName('output')
alg.removeOutputFromName('output')
alg.processCommand()
alg.addOutput(output)
def processOutputs(alg):
# We need to add the vector 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)

View File

@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_rectify.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$'
from processing.core.parameters import getParameterFromString
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
if alg.getParameterValue('inline_points') and alg.getParameterValue(u'points'):
return alg.tr("You need to set either an input control point file or inline control points!")
return None
def processCommand(alg):
# handle inline add data
input_txt = alg.getParameterFromName('inline_points')
inputParameter = alg.getParameterFromName('points')
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('rmsfile')
alg.removeOutputFromName('rmsfile')
# Create a false input parameter for rmsfile
param = getParameterFromString(u"ParameterString|rmsfile|the file|None|False|False")
param.value = output.value
alg.addParameter(param)
alg.processCommand()
alg.parameters.remove(param)
alg.addOutput(output)
if input_txt.value:
inputParameter.value = None
alg.addParameter(input_txt)

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_to_3d.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$'
def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
height = alg.getParameterValue('height')
column = alg.getParameterValue('column')
if (height and column) or (not height and not column):
return alg.tr("You need to set either a fixed height value or the height column!")
return None

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_vect_stats.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 processCommand(alg):
# exclude output for from_output
output = alg.getOutputFromName('output')
alg.removeOutputFromName('output')
alg.processCommand()
alg.addOutput(output)
def processOutputs(alg):
# We need to add the vector layer to outputs:
out = alg.exportedLayers[alg.getParameterValue('areas')]
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)

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_what_vect.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 processCommand(alg):
# exclude output for from_output
output = alg.getOutputFromName('output')
alg.removeOutputFromName('output')
alg.processCommand()
alg.addOutput(output)
def processOutputs(alg):
# We need to add the vector 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)