[GRASS-user] Using Tck/tk vector digitizer for training areas

Greetings

I’m using WinGRASS (from OSGEO4W installer) to do some supervised classification. Since I’m using winGRASS i.class function is not available neither wxGUI’s vector digitizer. So I’m using tcl/tk but I’m a bit confused on using it.
About the background images I used a discussion from last week regarding this but now… How can I define a category? I mean, How can atribute a polygon to a certain category?

This indeed is not obvious. What I’ve done is change the category mode from “Next not used” to “Manual entry”. This is set in the lower part of the v.digit window (in tcltk interface). Now each time you digitize a centroid for a training area, set its cat value to some standard value you choose. For example, you might decide:
train_area cat

···
-- 
Micha Silver
Arava Development Co. +972-52-3665918
[http://www.surfaces.co.il](http://www.surfaces.co.il)
 

Hi Micha and GRASS-users/list

Let me see if I get this straight
1- use v.digit (e.g. v.digit -n map=vector00 bgcmd=d.rast map=lsat5_1987_40 )
2- Inside tcltk’s digitizing menu select Digitize new Centroid
3- Leave layer as 1?
4- Change Mode to Manual Entry?
5- And for each Centroid I select a Cat right?
(Is this the proceeding?)

About this, I have two questions:
a- I have to leave “Insert New record into table” checked right?
b- After I left “Insert New record into table” checked, Layer 1 and Cat 1 and Mode: Manual Entry, when I presss in the image a Error Window appeared stating: Database table for this layer is not defined. Where shall i define the database table for a new vectorial that I digitizing?
c- When I press the image a point is created but how can I define the boundaries of the centroid?

Thanks
Jenny

On Wed, Jun 9, 2010 at 7:06 PM, Micha Silver <micha@arava.co.il> wrote:

polygon to a certain category?

This indeed is not obvious. What I’ve done is change the category mode from “Next not used” to “Manual entry”. This is set in the lower part of the v.digit window (in tcltk interface). Now each time you digitize a centroid for a training area, set its cat value to some standard value you choose. For example, you might decide:
train_area cat

forest 1
agriculture 2
urban 9
water 10

Now for each training polygon which is a forest, set the cat value of its centroid to 1, agri areas will get value 2, and so on for all the centroids of all the training polygons. (Note that the cat values for the boundary lines are pretty much irrelevant in GRASS’s vector model).

When you’re done digitizing training areas, you might add another column or two to the attrib table for the training areas -
v.db.addcol train_areas col=“train_label varchar(16), RGBCOLOR varchar(16)”
then give each centroid cat value a suitable label and an RGB color combo, etc. Makes life easier down the line…

This mail was received via Mail-SeCure System.


_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[http://lists.osgeo.org/mailman/listinfo/grass-user](http://lists.osgeo.org/mailman/listinfo/grass-user)

This mail was received via Mail-SeCure System.

-- 
Micha Silver
Arava Development Co. +972-52-3665918
[http://www.surfaces.co.il](http://www.surfaces.co.il)
 

Hi Micha and GRASS-users/list

Let me see if I get this straight
1- use v.digit (e.g. v.digit -n map=vector00 bgcmd=d.rast map=lsat5_1987_40 )
2- Inside tcltk’s digitizing menu select Digitize new Centroid
3- Leave layer as 1?
4- Change Mode to Manual Entry?

All the above looks good.

5- And for each Centroid I select a Cat right?

Yes, always using the same cat for training areas of the same type.

(Is this the proceeding?)

About this, I have two questions:
a- I have to leave “Insert New record into table” checked right?

Yes

b- After I left “Insert New record into table” checked, Layer 1 and Cat 1 and Mode: Manual Entry, when I presss in the image a Error Window appeared stating: Database table for this layer is not defined. Where shall i define the database table for a new vectorial that I digitizing?

Ah, v.db.addtable vector00 col=“train_lbl varchar(16), GRASSRGB varchar(16)”
THis should setup an attrib table with two columns, one for a label and one for an RGB color for the training area.

c- When I press the image a point is created but how can I define the boundaries of the centroid?

First digitize the boundary. Here you need not enter any attributes. The cat values are also not relevant.
NExt digitize a centroid inside each boundary. Give each centroid a cat value that matches the type of training area. So all the forests will be i.e cat=1, and all the urban will be i.e cat=10, etc.

···
-- 
Micha Silver
Arava Development Co. +972-52-3665918
[http://surfaces.co.il](http://surfaces.co.il)

Thanks Micha for your help but I got an error while doing this

1- Create new empty vectorial
2- run v.db.addtable command that you kindly sent me
3- use v.digit as defined previously
4- Inside tcltk’s digitizing menu select Digitize new Centroid
5- Leave layer as 1
6- Change Mode to Manual Entry
7- First digitize boundary (by selecting boundary) by selecting points with left-mouse-button and close polygon with right-mouse-button
8- A panel with “FORM” title appears with a tab saying Attributes saying: “New record was created” saying CAT : 1 (this cat refers to the land cover category right?); train_lbl value and GRASSRGB;
9- I place the values (water,1) for train_lbl and GRASSRGB
10- a box ask me for “ASSUME DATA ENCODING AS” a list appears. I should select which one? ASCII?
11- In trhis case I select ASCII and press SUBMIT. In the bottom of that box “Record successfully updated” appeared.
12- Insert centroid-1 and press submit in “Form” panel
13- Did the same for a few more polygons of cat 1
14- Did the same for a few more polygons of cat 2 and 3
15- Pressed Save and Exit

Then I realized that at my v.digit panel command output I had this warning in there:

Could not set Tcl system encoding to ‘ascii’ (unknown encoding “ascii”)
Unable to read vector map

Questions:
1- Is this the right procedure?
2- What encoding should I use?
3- Regarding GRASSRGB field, what information usually you place in there? Color code or color description?
4- For Supervised classification algorithms in GRASS, Vector type (accessible by using Query raster/vector tool) should be Boundary? Because, for instance, if I press a defined boundary, in some places I get Type: AREA and in others: Boundary (as shown bellow)

(…)
Map: vector06
Mapset: landsat
Type: Boundary
Id: 9
Layer: 1
Category: 3
Driver: dbf
Database: C:\GRASS6\grassdata/North-Carolina/landsat/dbf/
Table: vector06
Key column: cat
cat : 3
train_lbl : urban
GRASSRGB : 3
(Thu Jun 17 10:34:04 2010) Command finished (0 sec)
(Thu Jun 17 10:34:06 2010)
v.what --q -a map=vector06@landsat east_north=639279.744997,227730.071998
(…)
Map: vector06
Mapset: landsat
Type: Area
Sq Meters: 2158429.741
Hectares: 215.843
Acres: 533.360
Sq Miles: 0.8334
Layer: 1
Category: 3
Driver: dbf
Database: C:\GRASS6\grassdata/North-Carolina/landsat/dbf/
Table: vector06
Key column: cat
cat : 3
train_lbl : urban
GRASSRGB : 3

Thanks for your help and support

Jenny

On Wed, Jun 16, 2010 at 7:59 PM, Micha Silver <micha@arava.co.il> wrote:

On 06/16/2010 06:55 PM, Jenny Turner wrote:

Hi Micha and GRASS-users/list

Let me see if I get this straight
1- use v.digit (e.g. v.digit -n map=vector00 bgcmd=d.rast map=lsat5_1987_40 )
2- Inside tcltk’s digitizing menu select Digitize new Centroid
3- Leave layer as 1?
4- Change Mode to Manual Entry?

All the above looks good.

5- And for each Centroid I select a Cat right?

Yes, always using the same cat for training areas of the same type.

(Is this the proceeding?)

About this, I have two questions:
a- I have to leave “Insert New record into table” checked right?

Yes

b- After I left “Insert New record into table” checked, Layer 1 and Cat 1 and Mode: Manual Entry, when I presss in the image a Error Window appeared stating: Database table for this layer is not defined. Where shall i define the database table for a new vectorial that I digitizing?

Ah, v.db.addtable vector00 col=“train_lbl varchar(16), GRASSRGB varchar(16)”
THis should setup an attrib table with two columns, one for a label and one for an RGB color for the training area.

c- When I press the image a point is created but how can I define the boundaries of the centroid?

First digitize the boundary. Here you need not enter any attributes. The cat values are also not relevant.
NExt digitize a centroid inside each boundary. Give each centroid a cat value that matches the type of training area. So all the forests will be i.e cat=1, and all the urban will be i.e cat=10, etc.

Thanks
Jenny

On Wed, Jun 9, 2010 at 7:06 PM, Micha Silver <micha@arava.co.il> wrote:

polygon to a certain category?

This indeed is not obvious. What I’ve done is change the category mode from “Next not used” to “Manual entry”. This is set in the lower part of the v.digit window (in tcltk interface). Now each time you digitize a centroid for a training area, set its cat value to some standard value you choose. For example, you might decide:
train_area cat

forest 1
agriculture 2
urban 9
water 10

Now for each training polygon which is a forest, set the cat value of its centroid to 1, agri areas will get value 2, and so on for all the centroids of all the training polygons. (Note that the cat values for the boundary lines are pretty much irrelevant in GRASS’s vector model).

When you’re done digitizing training areas, you might add another column or two to the attrib table for the training areas -
v.db.addcol train_areas col=“train_label varchar(16), RGBCOLOR varchar(16)”
then give each centroid cat value a suitable label and an RGB color combo, etc. Makes life easier down the line…

This mail was received via Mail-SeCure System.


_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[http://lists.osgeo.org/mailman/listinfo/grass-user](http://lists.osgeo.org/mailman/listinfo/grass-user)

This mail was received via Mail-SeCure System.

-- 
Micha Silver
Arava Development Co. +972-52-3665918
[http://www.surfaces.co.il](http://www.surfaces.co.il)
 

This mail was received via Mail-SeCure System.


-- 
Micha Silver
Arava Development Co. +972-52-3665918

[http://surfaces.co.il](http://surfaces.co.il)

Thanks Micha for your help but I got an error while doing this

1- Create new empty vectorial
2- run v.db.addtable command that you kindly sent me
3- use v.digit as defined previously
4- Inside tcltk’s digitizing menu select Digitize new Centroid
5- Leave layer as 1
6- Change Mode to Manual Entry
7- First digitize boundary (by selecting boundary) by selecting points with left-mouse-button and close polygon with right-mouse-button
8- A panel with “FORM” title appears with a tab saying Attributes saying: “New record was created” saying CAT : 1 (this cat refers to the land cover category right?); train_lbl value and GRASSRGB;
9- I place the values (water,1) for train_lbl and GRASSRGB
10- a box ask me for “ASSUME DATA ENCODING AS” a list appears. I should select which one? ASCII?
11- In trhis case I select ASCII and press SUBMIT. In the bottom of that box “Record successfully updated” appeared.
12- Insert centroid-1 and press submit in “Form” panel
13- Did the same for a few more polygons of cat 1
14- Did the same for a few more polygons of cat 2 and 3
15- Pressed Save and Exit

Then I realized that at my v.digit panel command output I had this warning in there:

Could not set Tcl system encoding to ‘ascii’ (unknown encoding “ascii”)
Unable to read vector map

Questions:
1- Is this the right procedure?

Yes. I’d just add one thing that might make the work easier. You don’t need to enter the label and GRASSRGB for each centroid. Just leave them blank. Then, when you’re all finished digitizing, you can run an update such as:
echo ‘UPDATE vector06 SET train_lbl=“Forest” WHERE cat=1’ | db.execute
echo ‘UPDATE vector06 SET GRASSRGB=“0:255:0” WHERE cat=1’ | db.execute
(The second line will set the GRASSRGB column to green )

2- What encoding should I use?

Perhaps try Latin1

3- Regarding GRASSRGB field, what information usually you place in there? Color code or color description?

The format is a text string containing three numbers <=255 separated by ‘:’. So i.e. “128:128:128” is medium gray.

4- For Supervised classification algorithms in GRASS, Vector type (accessible by using Query raster/vector tool) should be Boundary? Because, for instance, if I press a defined boundary, in some places I get Type: AREA and in others: Boundary (as shown bellow)

AFAIK, each of the classification algorithms needs a raster map of training areas. So your next step, after finishing the vector map of training areas, will be to convert it to raster. So you’ll be doing something like:
v.to.rast vector06 out=train06 use=cat type=area
Now the cat value that will be used for each raster pixels inside a vector area is the cat value of the centroid. Again, the boundary in GRASS’s topological vector structure is not relevant to the enclosed area’s attributes. You can, if you want, give the boundary the same cat value, and same GRASSRGB as the centroid. Then, if you use this column to color the vector when displaying the map, the boundary and the filled area will be in the same color. But for classification, when you convert the vector training areas to raster, what will be used is the centroid cat value.

···
-- 
Micha Silver
Arava Development Co. +972-52-3665918
[http://surfaces.co.il](http://surfaces.co.il)