Changeset 67380
- Timestamp:
- Dec 26, 2015, 4:35:21 AM (9 years ago)
- Location:
- grass/trunk/vector/v.what.rast
- Files:
-
- 2 edited
-
main.c (modified) (3 diffs)
-
v.what.rast.html (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/vector/v.what.rast/main.c
r67261 r67380 10 10 * PURPOSE: Query raster map 11 11 * 12 * COPYRIGHT: (C) 2001-201 3by the GRASS Development Team12 * COPYRIGHT: (C) 2001-2015 by the GRASS Development Team 13 13 * 14 14 * This program is free software under the GNU General … … 39 39 int width; 40 40 int row, col; 41 char buf[ 2000];41 char buf[DB_SQL_MAX]; 42 42 struct 43 43 { … … 163 163 164 164 if (!print_flag->answer) { 165 /* Check column type */166 165 col_type = db_column_Ctype(driver, Fi->table, opt.col->answer); 167 166 168 if (col_type == -1) 169 G_fatal_error(_("Column <%s> not found"), opt.col->answer); 170 171 if (col_type != DB_C_TYPE_INT && col_type != DB_C_TYPE_DOUBLE) 172 G_fatal_error(_("Column type not supported")); 173 174 if (out_type == CELL_TYPE && col_type == DB_C_TYPE_DOUBLE) 175 G_warning(_("Raster type is integer and column type is float")); 176 177 if (out_type != CELL_TYPE && col_type == DB_C_TYPE_INT) 178 G_warning(_("Raster type is float and column type is integer, some data lost!!")); 167 if (col_type == -1) { 168 /* column doesn't exist, create it */ 169 G_important_message(_("Column <%s> not found in the table <%s>. Creating..."), 170 opt.col->answer, Fi->table); 171 sprintf(buf, "ALTER TABLE \"%s\" ADD COLUMN \"%s\" %s", 172 Fi->table, opt.col->answer, 173 out_type == CELL_TYPE ? "INTEGER" : "DOUBLE PRECISION"); 174 db_set_string(&stmt, buf); 175 if (db_execute_immediate(driver, &stmt) != DB_OK) 176 G_fatal_error(_("Unable to add column <%s> to table <%s>"), 177 opt.col->answer, Fi->table); 178 } 179 else { 180 /* check column type */ 181 if (col_type != DB_C_TYPE_INT && col_type != DB_C_TYPE_DOUBLE) 182 G_fatal_error(_("Column type not supported")); 183 184 if (out_type == CELL_TYPE && col_type == DB_C_TYPE_DOUBLE) 185 G_warning(_("Raster type is integer and column type is float")); 186 187 if (out_type != CELL_TYPE && col_type == DB_C_TYPE_INT) 188 G_warning(_("Raster type is float and column type is integer, some data lost!!")); 189 } 179 190 } 180 191 -
grass/trunk/vector/v.what.rast/v.what.rast.html
r66157 r67380 3 3 <em>v.what.rast</em> retrieves raster value from a given raster map for each point 4 4 or centroid stored in a given vector map. It can update a <b>column</b> in the linked 5 vector attribute table with the retrieved raster cell value or print it. The column type 6 needs to be numeric (integer, float, double, ...). 5 vector attribute table with the retrieved raster cell value or print it. 6 7 <p>The column type needs to be numeric (integer, float, double, 8 ...). If the column doesn't exist in the vector attribute table than 9 the module will create the new column of type correspoding with the 10 input raster map. 11 7 12 <p> 8 13 If the <b>-p</b> flag is used, then the attribute table is not updated 9 and the results are printed to <tt>stdout</tt>.14 and the results are printed to standard output. 10 15 <p> 11 16 If the <b>-i</b> flag is used, then the value to be uploaded to the database … … 13 18 distance weighting method (IDW). This is useful for cases when the vector 14 19 point density is much higher than the raster cell size. 15 <p>16 Points and centroid with shared category number cannot be processed.17 To solved this, unique categories may be added with <em>v.category</em> in18 a separate layer.19 20 20 21 <h2>NOTES</h2> 21 22 23 <p> 24 Points and centroid with shared category number cannot be processed. 25 To solved this, unique categories may be added 26 with <em><a href="v.category.html">v.category</a></em> in a separate 27 layer. 28 29 <p> 22 30 If multiple points have the same category, the attribute value is set to NULL. 23 31 If the raster value is NULL, then attribute value is set to NULL. 24 32 <p> 25 33 <em>v.what.rast</em> operates on the attribute table. To modify the vector 26 geometry instead, use <em> v.drape</em>.34 geometry instead, use <em><a href="v.drape.html">v.drape</a></em>. 27 35 <p> 28 36 Categories and values are output unsorted with the print flag. To sort them 29 37 pipe the output of this module into the UNIX <tt>sort</tt> tool 30 38 (<tt>sort -n</tt>). If you need coordinates, after sorting use 31 <em> v.out.ascii</em> and the UNIX <tt>paste</tt> tool39 <em><a href="v.out.ascii.html">v.out.ascii</a></em> and the UNIX <tt>paste</tt> tool 32 40 (<tt>paste -d'|'</tt>). In the case of a NULL result, a "<tt>*</tt>" 33 41 will be printed in lieu of the value. … … 58 66 g.region raster=elev_state_500m -p 59 67 60 # add new column to existing table 61 v.db.addcolumn map=mygeodetic_pts column="height double precision" 68 # query raster cells (a new column will be added to existing table) 62 69 v.what.rast map=mygeodetic_pts raster=elev_state_500m column=height 63 70
Note:
See TracChangeset
for help on using the changeset viewer.
