[GRASS-SVN] r64775 - in grass-addons/grass7/vector: . v.profile
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 1 12:10:52 PST 2015
Author: neteler
Date: 2015-03-01 12:10:52 -0800 (Sun, 01 Mar 2015)
New Revision: 64775
Added:
grass-addons/grass7/vector/v.profile/
Modified:
grass-addons/grass7/vector/Makefile
grass-addons/grass7/vector/v.profile/Makefile
grass-addons/grass7/vector/v.profile/README
grass-addons/grass7/vector/v.profile/main.c
grass-addons/grass7/vector/v.profile/v.profile.html
Log:
v.profile Addon: ported to GRASS 7
Modified: grass-addons/grass7/vector/Makefile
===================================================================
--- grass-addons/grass7/vector/Makefile 2015-03-01 19:49:38 UTC (rev 64774)
+++ grass-addons/grass7/vector/Makefile 2015-03-01 20:10:52 UTC (rev 64775)
@@ -35,6 +35,7 @@
v.out.ply \
v.out.png \
v.ply.rectify \
+ v.profile \
v.stats \
v.surf.icw \
v.surf.mass \
Modified: grass-addons/grass7/vector/v.profile/Makefile
===================================================================
--- grass-addons/grass6/vector/v.profile/Makefile 2015-03-01 09:34:49 UTC (rev 64773)
+++ grass-addons/grass7/vector/v.profile/Makefile 2015-03-01 20:10:52 UTC (rev 64775)
@@ -5,8 +5,8 @@
PGM = v.profile
-LIBES = $(VECTLIB) $(GISLIB)
-DEPENDENCIES= $(VECTDEP) $(GISDEP)
+LIBES = $(VECTORLIB) $(DBMILIB) $(GISLIB)
+DEPENDENCIES = $(VECTORDEP) $(DBMIDEP) $(GISDEP)
EXTRA_INC = $(VECT_INC)
EXTRA_CFLAGS = $(VECT_CFLAGS)
Modified: grass-addons/grass7/vector/v.profile/README
===================================================================
--- grass-addons/grass6/vector/v.profile/README 2015-03-01 09:34:49 UTC (rev 64773)
+++ grass-addons/grass7/vector/v.profile/README 2015-03-01 20:10:52 UTC (rev 64775)
@@ -1,13 +1,13 @@
Vector point/line profiling tool. See v.profile.html file for full description.
-v.profile requires GRASS 6.4 (r34499) or GRASS 7 (r34592 - not tested).
+v.profile requires GRASS 7
-To install v.profile, one needs to provide MODULE_TOPDIR variable for make command (MODULE_TOPDIR=/path/to/GRASS) or change MODULE_TOPDIR in supplied MAKE file to point to GRASS source base. If GRASS source is located in /home/user/soft/grass-6.4, then set MODULE_TOPDIR to /home/user/soft/grass-6.4. Before compiling this module, it's required to configure GRASS (it must have include/Make/Module.make file).
+To install v.profile, one needs to provide MODULE_TOPDIR variable for make command (MODULE_TOPDIR=/path/to/GRASS) or change MODULE_TOPDIR in supplied MAKE file to point to GRASS source base. If GRASS source is located in /home/user/soft/grass-7.0, then set MODULE_TOPDIR to /home/user/soft/grass-7.0. Before compiling this module, it's required to configure GRASS (it must have include/Make/Module.make file).
Short version:
-svn co https://svn.osgeo.org/grass/grass-addons/vector/v.profile v.profile
+svn co https://svn.osgeo.org/grass/grass-addons/grass7/vector/v.profile v.profile
cd v.profile
-#nano Makefile # altrenative - edit MODULE_TOPDIR setting
+#nano Makefile # alternative - edit MODULE_TOPDIR setting
MODULE_TOPDIR='/path/to/grass-source' make
make install
Modified: grass-addons/grass7/vector/v.profile/main.c
===================================================================
--- grass-addons/grass6/vector/v.profile/main.c 2015-03-01 09:34:49 UTC (rev 64773)
+++ grass-addons/grass7/vector/v.profile/main.c 2015-03-01 20:10:52 UTC (rev 64775)
@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <grass/config.h>
#include <grass/gis.h>
-#include <grass/Vect.h>
+#include <grass/vector.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
@@ -73,7 +73,8 @@
layer, pro_layer, *cats, c, field_index;
size_t rescount;
double xval, yval, bufsize;
- char *mapset, *pro_mapset, sql[200], *fs;
+ const char *mapset, *pro_mapset;
+ char sql[200], *fs;
struct GModule *module;
struct Option *old_map, *new_map, *coords_opt, *buffer_opt, *delim_opt,
@@ -94,7 +95,9 @@
/* initialize module */
module = G_define_module();
- module->keywords = _("vector, profile, transect");
+ G_add_keyword(_("vector"));
+ G_add_keyword(_("profile"));
+ G_add_keyword(_("transect"));
module->description = _("Vector map profiling tool");
old_map = G_define_standard_option(G_OPT_V_INPUT);
@@ -103,7 +106,7 @@
type_opt = G_define_standard_option(G_OPT_V_TYPE);
type_opt->options = "point,line";
type_opt->answer = "point,line";
- type_opt->guisection = _("Input filter");
+ type_opt->guisection = _("Selection");
coords_opt = G_define_option();
coords_opt->key = "east_north";
@@ -122,25 +125,19 @@
buffer_opt->answer = "10";
buffer_opt->label = _("Buffer (tolerance) for points in map units");
buffer_opt->description = _("How far points can be from sampling line");
- buffer_opt->guisection = _("Required");
file_opt = G_define_option();
- file_opt->key = "out_file";
+ file_opt->key = "output";
file_opt->type = TYPE_STRING;
file_opt->required = NO;
file_opt->multiple = NO;
file_opt->gisprompt = "new_file,file,output";
file_opt->answer = "-";
file_opt->description = _("Path to output text file or - for stdout");
- file_opt->guisection = _("Output formating");
+ file_opt->guisection = _("Format");
- delim_opt = G_define_option();
- delim_opt->key = "fs";
- delim_opt->type = TYPE_STRING;
- delim_opt->required = NO;
- delim_opt->answer = "|";
- delim_opt->description = _("Field separator");
- delim_opt->guisection = _("Output formating");
+ delim_opt = G_define_standard_option(G_OPT_F_SEP);
+ delim_opt->guisection = _("Format");
dp_opt = G_define_option();
dp_opt->key = "dp";
@@ -149,15 +146,15 @@
dp_opt->options = "0-32";
dp_opt->answer = "2";
dp_opt->description = _("Number of significant digits");
- dp_opt->guisection = _("Output formating");
+ dp_opt->guisection = _("Format");
- where_opt = G_define_standard_option(G_OPT_WHERE);
- where_opt->guisection = _("Input filter");
+ where_opt = G_define_standard_option(G_OPT_DB_WHERE);
+ where_opt->guisection = _("Selection");
layer_opt = G_define_standard_option(G_OPT_V_FIELD);
layer_opt->answer = "1";
layer_opt->description = _("Use features only from specified layer");
- layer_opt->guisection = _("Input filter");
+ layer_opt->guisection = _("Selection");
new_map = G_define_option();
new_map->key = "map_output";
@@ -169,18 +166,18 @@
new_map->label = _("Name for profile line and buffer output map");
new_map->description =
_("Profile line and buffer around it will be written");
- new_map->guisection = _("Output formating");
+ new_map->guisection = _("Output");
no_column_flag = G_define_flag();
no_column_flag->key = 'c';
no_column_flag->description = _("Do not print column names");
- no_column_flag->guisection = _("Output formating");
+ no_column_flag->guisection = _("Output");
no_z_flag = G_define_flag();
no_z_flag->key = 'z';
no_z_flag->label = _("Do not print 3D vector data (z values)");
no_z_flag->description = _("Only affects 3D vectors");
- no_z_flag->guisection = _("Output formating");
+ no_z_flag->guisection = _("Output");
/* Options that allow to input profiling line from vector map */
inline_map = G_define_option();
@@ -312,13 +309,7 @@
open3d = WITHOUT_Z;
/* the field separator */
- fs = delim_opt->answer;
- if (strcmp(fs, "\\t") == 0)
- fs = "\t";
- if (strcmp(fs, "tab") == 0)
- fs = "\t";
- if (strcmp(fs, "space") == 0)
- fs = " ";
+ fs = G_option_to_separator(delim_opt);
/* Let's get vector layers db connections information */
Fi = Vect_get_field(&In, layer);
Modified: grass-addons/grass7/vector/v.profile/v.profile.html
===================================================================
--- grass-addons/grass6/vector/v.profile/v.profile.html 2015-03-01 09:34:49 UTC (rev 64773)
+++ grass-addons/grass7/vector/v.profile/v.profile.html 2015-03-01 20:10:52 UTC (rev 64775)
@@ -1,52 +1,77 @@
<h2>DESCRIPTION</h2>
-<p>This module will print out distance and attributes to points/lines along profiling
-line. Distance is calculated from first profiling line coordinate pair or from the
-beginning of vector line (use "Line directions" feature in gis.m to see distance calculation
-direction). Output can go to file or stdout. Output file will be overwritten without warning.
-Buffer (tolerance) parameter sets how far point
-can be located from profiling line and still be included in output data set. Output map
-option can be used to visualy check which points are profiled. Buffer (tolerance) setting
-does not affect lines. Lines are sampled at their crossing point with profiling line.
-By default Z values are printed if input vector is a 3D map. It can be disabled with -z
-flag. Profiling line can be provided as N,E coordinate pairs or can come from input vector
-map. As currently profiling line must be single line, one should use profile_where parameter
-to select single line from profile input map if it contains multiple features.</p>
+
+This module will print out distance and attributes to points/lines
+along a profiling line. Distance is calculated from first profiling line
+coordinate pair or from the beginning of vector line
+<!-- TODO: update
+(use "Line directions" feature in gis.m to see distance calculation direction).
+-->
+Output can go to file or stdout.
+Buffer (tolerance) parameter sets how far point can be
+located from profiling line and still be included in output data set.
+Output map option can be used to visually check which points are
+profiled. Buffer (tolerance) setting does not affect lines. Lines are
+sampled at their crossing point with profiling line. By default Z
+values are printed if input vector is a 3D map. It can be disabled with
+-z flag. Profiling line can be provided as N,E coordinate pairs or can
+come from input vector map. As currently profiling line must be single
+line, one should use profile_where parameter to select single line from
+profile input map if it contains multiple features.
+
<h2>NOTE</h2>
-<p>Currently module can profile only points and lines (including 3D ones). Areas and other
-complex features are not supported. If one can provide reasonable examples how area
-sampling should work and why it's important, area (or any other feature type) sampling can
-be added.</p>
+
+Currently module can profile only points and lines (including 3D ones).
+Areas and other complex features are not supported. If one can provide
+reasonable examples how area sampling should work and why it is
+important, area (or any other feature type) sampling can be added.
+
<h2>EXAMPLES</h2>
-<p>
-Get point values and distance from the city and save into file for later usage. Will use
-; as delimiter and three numbers after decimal separator for distance. Output file will contain
-data for all points, that are within 100m range to profiling line.
+
+Get point values and distance from the city and save into file for
+later usage. We will use comma as delimiter and three numbers after decimal
+separator for distance. Output file will contain data for all points,
+that are within 100m range to profiling line (Spearfish dataset).
+
<div class="code"><pre>
-v.profile input=archsites at PERMANENT map_output=profiling_line buffer=100 \
-east_north=591518.55,4925722.38,592110.14,4920989.67 out_file=/home/user/archsites.distance dp=3 fs=';'
-# Now let's see output:
-$cat archsites.distance
-Number;Distance;cat;str1
-1;446.958;24;"Hanson Ranch"
-2;1386.149;11;"No Name"
-3;2754.872;2;"No Name"
-4;4559.578;13;"No Name"
+v.profile input=archsites map_output=profiling_line buffer=100 \
+ east_north=591518.55,4925722.38,592110.14,4920989.67 \
+ output=archsites_distance.csv dp=3 separator=comma
+
+# Now let's see the output:
+$ cat archsites_distance.csv
+Number,Distance,cat,str1
+1,446.958,24,"Hanson Ranch"
+2,1386.149,11,"No Name"
+3,2754.872,2,"No Name"
+4,4559.578,13,"No Name"
</pre></div>
-</p>
-<p>Create river valley crossection and provide river marker
+
+<p>
+Create river valley crossection and provide river marker:
+
<div class="code"><pre>
# Take elevation samples
r.profile input=elevation.dem at PERMANENT output=/home/user/elevation.profile \
-profile=600570.27364,4920613.41838,600348.034348,4920840.38617
+ profile=600570.27364,4920613.41838,600348.034348,4920840.38617
# Now get distance to place where river marker should be set
-v.profile input=streams at PERMANENT out_file=/home/user/river.profile \
-east_north=600570.27364,4920613.41838,600348.034348,4920840.38617
+v.profile input=streams at PERMANENT output=river_profile.csv \
+ east_north=600570.27364,4920613.41838,600348.034348,4920840.38617
</pre></div>
-</p>
+
<h2>BUGS</h2>
-<p>Strings are enclosed in double quotes ", still quotes within string are not escaped.</p>
-<p>Vector CAT values are not outputed. Only way how to get CAT value is from attribute table.</p>
+
+Strings are enclosed in double quotes ", still quotes within string are
+not escaped.
+<p>
+Vector CAT values are not outputed. Only way how to get CAT value is from
+attribute table.
+
<h2>SEE ALSO</h2>
-<p><a href="r.profile.html">r.profile</a></p>
+
+<a href="r.profile.html">r.profile</a>
+
<h2>AUTHOR</h2>
-<p>Maris Nartiss</p>
+
+Maris Nartiss
+
+<p><i>Last changed: $Date$</i>
More information about the grass-commit
mailing list