Opened 6 years ago
Last modified 5 years ago
#3679 new enhancement
Convert numeric raster category labels to numeric column in the output vector map's attribute table
Reported by: | Nikos Alexandris | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 7.8.3 |
Component: | Raster | Version: | svn-trunk |
Keywords: | r.to.vect | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
Converting a raster which holds category labels to vector using r.to.vect
, i.e.
r.to.vect in=raster_map out=vector_map type=area
will add the columns value
and label
.
v.info -c vector_map Displaying column types/names for database connection of layer <1>: INTEGER|cat INTEGER|value CHARACTER|label
Since r.mapcalc
supports for some math using numbers stored as category labels (via the @ operator) and, as well, r.stats.zonal
writes numeric results as category labels via its -r
flag, it would make sense to support for the addition of a numeric (int or double) column type in the output vector map's attribute table. Perhaps this could be done via a flag.
I understand that this might bring a series of tests to perform before attempting adding such a column in the output attribute table. Such as "are all labels numeric?" and "should the output be 'int' or 'double'?". Yet, it would help to streamline processes that involve such conversions.
Change History (6)
comment:1 by , 6 years ago
Component: | Default → Raster |
---|---|
Milestone: | → 7.8.0 |
Version: | unspecified → svn-trunk |
comment:2 by , 5 years ago
comment:6 by , 5 years ago
Milestone: | → 7.8.3 |
---|
An virtual example using maps from the nc_basic_spm_grass7.tar.gz Location:
An integer version of the
elevation
mapand the
geology
mapCompute the average elevation value for each geology "type", and store it as a category label in the output raster map
elevation_of_geologies
Report the new map's categories and labels, in which case, these are the geology "type" and the average elevation
Convert the raster map
elevation_of_geologies
into a vector map namedelevation_of_geologies_vector
, viaThe new vector map has the following attributes:
It would be a convenience to actually have
r.to.vect
create a column of typeINTEGER
orDOUBLE PRECISION
for the "average elevation values", according to the type of numbers that are stored as raster category labels.Something like an
-n
flag (-n
Write raster category labels as numeric values), i.e.could produce a vector map for which
v.info -c elevation_of_geologies_vector
will show something like:or