<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FCaitifty</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FCaitifty"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FCaitifty"/>
	<updated>2026-04-18T07:39:47Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Shell&amp;diff=12646</id>
		<title>GRASS and Shell</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Shell&amp;diff=12646"/>
		<updated>2011-02-14T23:07:06Z</updated>

		<summary type="html">&lt;p&gt;⚠️Caitifty: /* Setting the variables */ add variables if script will be called from php&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is fairly easy to write a GRASS job as Shell script which launches GRASS, does the operation and cleans up the temporary files.&lt;br /&gt;
&lt;br /&gt;
=== What's this? ===&lt;br /&gt;
&lt;br /&gt;
Often it is convenient to automate repeated jobs. GRASS can be controlled via user scripts to facilitate daily work.&lt;br /&gt;
How to start? Using command line is a kind of writing scripts without saving them - so, you may start to write&lt;br /&gt;
'''your first script''' by saving the executed commands in a text file (use your preferred editor to do so, ideally&lt;br /&gt;
save the script file in ASCII format).&lt;br /&gt;
&lt;br /&gt;
=== A first script ===&lt;br /&gt;
&lt;br /&gt;
Comments should be started with a '#' character. The first line indicates the shell interpreter to be used, here &amp;quot;sh&amp;quot; which is always in the /bin/ directory.&lt;br /&gt;
&lt;br /&gt;
Silly example:&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  # my first script&lt;br /&gt;
  &lt;br /&gt;
  # plot current region settings&lt;br /&gt;
  g.region -p&lt;br /&gt;
   &lt;br /&gt;
  # leave with exit status 0 which means &amp;quot;ok&amp;quot;:&lt;br /&gt;
  exit 0&lt;br /&gt;
&lt;br /&gt;
Save this in a file &amp;quot;myscript.sh&amp;quot; and run it within GRASS GIS from the command line:&lt;br /&gt;
&lt;br /&gt;
  sh myscript.sh&lt;br /&gt;
&lt;br /&gt;
It should print the current region settings and finish.&lt;br /&gt;
&lt;br /&gt;
=== Setting the variables ===&lt;br /&gt;
&lt;br /&gt;
You have to set a couple of variables to enable GRASS command to run (see ''''GRASS Batch jobs'''' below for easier solution!).&lt;br /&gt;
&lt;br /&gt;
''[http://article.gmane.org/gmane.comp.gis.grass.user/17980 See this post] to the mailing list. Proabably need to update this wiki page with that information.''&lt;br /&gt;
&lt;br /&gt;
   # Example in bash shell syntax:&lt;br /&gt;
 &lt;br /&gt;
   # path to GRASS binaries and libraries:&lt;br /&gt;
   export GISBASE=/usr/local/grass64&lt;br /&gt;
 &lt;br /&gt;
   export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts&lt;br /&gt;
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib&lt;br /&gt;
 &lt;br /&gt;
   # use process ID (PID) as lock file number:&lt;br /&gt;
   export GIS_LOCK=$$&lt;br /&gt;
 &lt;br /&gt;
   # settings for graphical output to PNG file (optional)&lt;br /&gt;
   export GRASS_PNGFILE=/tmp/grass6output.png&lt;br /&gt;
   export GRASS_TRUECOLOR=TRUE&lt;br /&gt;
   export GRASS_WIDTH=900&lt;br /&gt;
   export GRASS_HEIGHT=1200&lt;br /&gt;
   export GRASS_PNG_COMPRESSION=1&lt;br /&gt;
&lt;br /&gt;
   # settings if you will be calling the script from another program - eg a php web page using system() or exec()&lt;br /&gt;
   export HOME=/var/www&lt;br /&gt;
   export USER=www-data&lt;br /&gt;
   export GROUP=www-data&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following variable defines where the GRASS settings file is stored. This can be anywhere on the system. You could also generate the '.grassrc6' on the fly in your script, even with different name. Just indicate it correctly:&lt;br /&gt;
&lt;br /&gt;
   # path to GRASS settings file&lt;br /&gt;
   export GISRC=$HOME/.grassrc6&lt;br /&gt;
&lt;br /&gt;
Now you can test:&lt;br /&gt;
&lt;br /&gt;
   # this should print the GRASS version used:&lt;br /&gt;
   g.version&lt;br /&gt;
   # other calculations go here ...&lt;br /&gt;
&lt;br /&gt;
You should cleanup internal tmp files like this:&lt;br /&gt;
&lt;br /&gt;
   # run GRASS' cleanup routine&lt;br /&gt;
   $GISBASE/etc/clean_temp&lt;br /&gt;
 &lt;br /&gt;
   # remove session tmp directory:&lt;br /&gt;
   rm -rf /tmp/grass6-$USER-$GIS_LOCK&lt;br /&gt;
&lt;br /&gt;
If this works, you can launch other GRASS commands. The approach works within Shell scripts and also in the command line terminal.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
* GRASS shell script job to generate a [http://grass.osgeo.org/spearfish/php_grass_earthquakes.php Recent Earthquakes Map]&lt;br /&gt;
: ({{website|spearfish/grass_earthquakes.sh|grass_earthquakes.sh shell script}})&lt;br /&gt;
&lt;br /&gt;
=== Parallel GRASS jobs ===&lt;br /&gt;
&lt;br /&gt;
See [[Parallel GRASS jobs]] for openMosix, PBS etc.&lt;br /&gt;
&lt;br /&gt;
=== GRASS Batch jobs ===&lt;br /&gt;
&lt;br /&gt;
There is (now) an alternative method to easily run jobs in GRASS from a collection of commands in a shell script file. Just define the environmental variable GRASS_BATCH_JOB with the shell script file containing GRASS (or whatever) commands, preferably with full path. Then launch GRASS and it will be executed. It is best to launch GRASS in -text mode and to provide GISDBASE/location/mapset as parameters. The job script needs executable file permissions (chmod).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
       chmod u+x $HOME/my_grassjob.sh&lt;br /&gt;
       export GRASS_BATCH_JOB=$HOME/my_grassjob.sh&lt;br /&gt;
       grass64 ~/grassdata/spearfish60/neteler/&lt;br /&gt;
&lt;br /&gt;
The grass64 command starts GRASS in the given mapset, executes the contents of the job file and leaves GRASS. Since the normal startup/closure is used, all tmp files are properly removed.&lt;br /&gt;
&lt;br /&gt;
Note: The $HOME variable (or the ~ shortcut) cannot be used in the batch job since the variables are not available here.&lt;br /&gt;
&lt;br /&gt;
To deactivate the batch job mode, run (bash example):&lt;br /&gt;
&lt;br /&gt;
        unset GRASS_BATCH_JOB&lt;br /&gt;
&lt;br /&gt;
=== Unattended execution ===&lt;br /&gt;
&lt;br /&gt;
* {{wikipedia|GNU_Screen}} is another ''extremely'' valuable tool if you need to detatch and leave long-running processes unattended. It is well worth your time to learn how to use it if you run scripts on remote systems. There are many good tutorials on the web.&lt;br /&gt;
: Usage:&lt;br /&gt;
:: Run &amp;quot;screen&amp;quot; in the terminal. You will reach again the command line but now in screen mode. Now start GRASS. &lt;br /&gt;
::: - To disconnect from the session press Control-A, Control-D.&lt;br /&gt;
::: - To list your screens type &amp;quot;screen -ls&amp;quot; (to find it back)&lt;br /&gt;
::: - To reconnect with a disconnected screen run &amp;quot;screen -r [identifier]&amp;quot; (the &amp;quot;identifier&amp;quot; you need only if you have several screens running)&lt;br /&gt;
:: Enjoy.&lt;br /&gt;
&lt;br /&gt;
* Along with the &amp;quot;{{wikipedia|nohup}}&amp;quot; (no hang-up) command you can login to your machine, launch the job and leave the machine again. &lt;br /&gt;
The process will continue after you logged off when you start it with nohup:&lt;br /&gt;
        nohup grass64 ~/grassdata/spearfish60/neteler/ &amp;amp;&lt;br /&gt;
&lt;br /&gt;
=== Receive a notification when finished ===&lt;br /&gt;
&lt;br /&gt;
Maybe put email notification at the end of 'my_grassjob.sh' using the &amp;quot;mail&amp;quot; or the &amp;quot;mutt&amp;quot; program, for example like this:&lt;br /&gt;
&lt;br /&gt;
        echo &amp;quot;Finished at `date`&amp;quot; &amp;gt; /tmp/done.txt &amp;amp;&amp;amp; \&lt;br /&gt;
        EDITOR=touch mutt -s &amp;quot;Job done&amp;quot; \&lt;br /&gt;
        me@mydomain.org &amp;lt; /tmp/done.txt &amp;amp;&amp;amp; rm -f /tmp/done.txt&lt;br /&gt;
&lt;br /&gt;
or like this:&lt;br /&gt;
        mail -s &amp;quot;GRASS job $0 finished&amp;quot; me@mydomain.org &amp;lt;&amp;lt;EOF&lt;br /&gt;
          GRASS GIS has finished the batch job $0&lt;br /&gt;
        EOF&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
&lt;br /&gt;
* Other GRASS environment {{cmd|variables}}&lt;br /&gt;
* [[GRASS_and_Python#Python-SWIG-GRASS_interface|SWIG bindings]] (Python/Perl/etc)&lt;br /&gt;
* Advance bash-scripting guide [http://tldp.org/LDP/abs/abs-guide.pdf]&lt;br /&gt;
* [[Working with GRASS without starting it explicitly]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Caitifty</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Digitizing_Area_Features&amp;diff=10763</id>
		<title>Digitizing Area Features</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Digitizing_Area_Features&amp;diff=10763"/>
		<updated>2010-04-18T19:59:08Z</updated>

		<summary type="html">&lt;p&gt;⚠️Caitifty: /* Specific instructions for digitizing areas */ change code snippet to use &amp;lt;source&amp;gt; tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Digitizing area features with attributes=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
GIS users with experience creating and editing non-topological shapefiles sometimes encounter problems when adding attributes to area features in the GRASS digitizer &amp;lt;tt&amp;gt; v.digit &amp;lt;/tt&amp;gt;. This section will attempt to offer a few tips and clear up this issue. Much has already been written explaining the strict topological vector model which GRASS uses. Please read first:&amp;lt;br&amp;gt;&lt;br /&gt;
:from the wiki- [http://grass.osgeo.org/wiki/Vector_FAQ_GRASS6] [http://grass.osgeo.org/wiki/Vectordata]&amp;lt;br&amp;gt;&lt;br /&gt;
:and from the manual pages- [http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html]&lt;br /&gt;
&lt;br /&gt;
==Problem Description==&lt;br /&gt;
When creating a polygon shapefile, after the user finishes clicking around the perimeter of the polygon, GIS software applications will often pop up a window with all the attribute columns available and the user enters values for that polygon. In the non-topological shapefile format, the area boundary and the enclosed polygon are one and the same. Thus the boundary attributes also refer to the enclosed area. In the shapefile diagram below the labels A-1, A-2, A-3 are taken from the polygon attribute table.  This fact might seem so obvious to shapefile users that they would wonder why it needs mentioning. &lt;br /&gt;
&lt;br /&gt;
In the strict topological model used in GRASS, this is not the case. In a GRASS vector the surrounding boundary, and its enclosed area are two separate entities, which have two separate rows in the accompanying attribute table. The boundary is made up of line segments, and the area is represented by its ''centroid'' – a point within the closed boundary. (Centroids should be placed only within closed boundaries.) A line segment which is part of the boundary enclosing an area does not “belong” to that area, rather it often is common to two adjacent areas.  In the GRASS vector diagram below, boundary B-1 separates areas A-1 and A-2. Boundaries B-3 and B-8 separate between areas A-1 and A-3. Furthermore, the boundary of area A-2 is composed of B-1, B-2 and B-5.  Obviously it would not make sense to attach '''area''' attributes to any boundary, so instead the area ''centroids'' serve to connect to the attribute table rows holding the area attributes. Thus, the labels B-1, B-2, etc. come from the vector attribute table (line features) and the A-1, A-2 labels, also from the attribute table, are ''centroid'' features.  Using the GRASS digitizer, &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt;, care needs to be taken to attach attributes to the correct features.&lt;br /&gt;
&lt;br /&gt;
[[Image:Shape.png|left|400px]] [[Image:Grass_vectors.png|center|400px]]&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
First, it's worth pointing out that when using &amp;lt;tt&amp;gt;v.in.ogr&amp;lt;/TT&amp;gt; to import a polygon shapefile into GRASS, steps are automatically taken to insure that the resulting vector gets the attributes as expected. (This behind-the-scenes procedure might actually fool naive users into believing that GRASS vectors are just like polygon shapefiles).&lt;br /&gt;
*Polygons are imported as boundary lines&lt;br /&gt;
*These lines are split at intersections, and all overlapping boundaries are removed (topologically cleaned)&lt;br /&gt;
*Centroids are placed in each closed boundary&lt;br /&gt;
*The centroids are given a cat value, and attributes from the original shapefile are inserted into the attached database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following are suggestions for adding attributes when using the GRASS digitizer, which more or less duplicate the above process. Detailed explanations of the &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; interface can be found both in the GRASS ([http://www.grassbook.org/ Book]) and the GDF Hannover ([http://www.gdf-hannover.de/lit_html/grass60_v1.2_en/node56.html tutorial]). The new wxGUI digitizer has a good manual page at: [http://grass.osgeo.org/grass64/manuals/html64_user/wxGUI.Vector_Digitizing_Tool.html]&lt;br /&gt;
&lt;br /&gt;
===General case===&lt;br /&gt;
The process that users should follow when manually creating area vectors with &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; will produce boundaries with no attributes, and a centroid connected thru its cat value to the area attributes. First, in the &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; interface, use the settings dialog to set up the attribute table as required by the data, and choose an appropriate snapping tolerance. Also in the settings dialog, under the Attributes tab, there is a drop down list to choose Category Mode (how the cat values will be chosen). For digitizing boundaries, it is possible to &amp;lt;u&amp;gt;choose “No category”&amp;lt;/u&amp;gt; since, as explained above, the boundary lines themselves might not require any attributes. Next digitize boundaries, being careful to &lt;br /&gt;
*close boundaries which delineate areas. &lt;br /&gt;
*never digitize the boundary between adjacent areas twice&lt;br /&gt;
*be sure to enter a node at every intersection of two boundary lines (no crossing boundaries without an intersection node)&lt;br /&gt;
Now, back in the Settings-&amp;gt;Attributes window, reset the Category Mode to &amp;lt;u&amp;gt;“Next not used”&amp;lt;/u&amp;gt;, and begin to digitize centroids for each area. After marking the location for a centroid, enter all attribute data into the table relevant to that area. And that's it.&lt;br /&gt;
&lt;br /&gt;
===A Special Case===&lt;br /&gt;
There are situations where attributes need to be attached also to the boundary lines. For example: in a project mapping out species distribution, the boundaries might have an attribute value indicating the rate of spread of a species across a border. In this case, the boundaries will get a cat value (optionally defined as a separate GRASS “layer”, with a separate database connection). While digitizing, the user will enter values into the attribute table relevant to each boundary. But still, centroids need to be digitized, and attributes entered for each centroid which are relevant to the areas. &lt;br /&gt;
&lt;br /&gt;
===Another Special Case=== &lt;br /&gt;
In some situations a single boundary line exactly encompasses an area, with no adjacent areas. (In other words, each area is an “isle” in GRASS terminology.) An example might be a vector map of water bodies. Obviously no water body touches any other. And the perimeter is one continuous line. Users might want the attribute table to be attached to both the area and the boundary – perhaps to display the length of the perimeter along the perimeter rather than at the centroid. In order to achieve this, boundaries will be digitized with a cat value, and the centroids will be forced to use that same cat value as the boundary. This is done as follows.&amp;lt;br&amp;gt; While working on the boundary, the user should take note of its category value. Next, before marking the centroid, the user will switch the Category Mode to “Manual entry”. Now she digitizes the centroid for that closed boundary and manually types in the &amp;lt;u&amp;gt;same cat value&amp;lt;/u&amp;gt; as the surrounding boundary. This creates two vector features: a boundary line and a centroid, with identical category values, and thus a single row in the database. So all attributes are common to both the boundary and the centroid (area).  &lt;br /&gt;
&lt;br /&gt;
===Note: v.centroids===&lt;br /&gt;
The GRASS tool for adding missing centroids to closed boundaries is &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt;. It is important to realize that the centroids will be created with category values that have no connection to the enclosing boundaries. If you run &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt; on a vector that already has closed boundary lines with attribute values, these attribute values will '''not be attached to the area enclosed''', since the new centroids will be assigned some new category value.  This point is explained in the &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt; [[http://grass.osgeo.org/grass63/manuals/html63_user/v.centroids.html manual]] page.&lt;br /&gt;
   &lt;br /&gt;
--[[User:Micha|Micha]] 22:12, 14 February 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Specific instructions for digitizing areas===&lt;br /&gt;
&lt;br /&gt;
I found this issue to be not that well documented, so here's a specific method for digitizing areas:&lt;br /&gt;
&lt;br /&gt;
An area comprises two primitives - a boundary and a centroid.  The boundary has no attributes; the centroid holds the attributes (if any).&lt;br /&gt;
&lt;br /&gt;
To create an area, a two step process is needed.  First, a boundary is defined, then a centroid added.  You can batch them - define all the boundaries then add the centroids.  I don't know the rules for overlapping areas though - might be better to do those separately.&lt;br /&gt;
&lt;br /&gt;
In this example, you have some existing map layers (for example a layer showing some parks as areas and a layer showing roads) and you want to create a new area by manually digitizing an area based on the existing map layers (eg you want to digitize an area bounded by some specific streets near a park).&lt;br /&gt;
&lt;br /&gt;
These steps create a new map, give it an attribute table, link the attribute table to the map, and open the new map in v.digit displaying the existing layer/s:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.in.ascii -e output=newmapname&lt;br /&gt;
echo 'create table newmapname (cat integer, DAY date)' | db.execute&lt;br /&gt;
v.db.connect -o map=newmapname table=newmapname&lt;br /&gt;
v.digit map=newmapname bgcmd=&amp;quot;d.vect map=existingmap1 type=area fcolor=green; d.vect map=existingmap2&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create as many attribute fields as you want within the () area, using whatever field types are allowable for the database type you're using.  If you're using an 'external' database type like mysql, you can also just create a cat field in this step and use regular mysql commands or tools to add additional fields to the table if that's easier.&lt;br /&gt;
&lt;br /&gt;
In the window that opens, zoom the the relevant area, then click the 'Digitize new boundary' button.  IMPORTANT: Before doing anything else, CHANGE MODE TO 'No Category'.  Use the tool to define the boundary of the area, and right-click to close the boundary.  If the boundary is successfully closed, the boundary line will turn bright green. If not, it'll remain grey.  Easiest fix is to click the 'move vertex' button, move one of the vertices back a bit, then using the 'create new boundary' tool, join the two red crosses.  This almost always works, for some reason I can never get the original boundary to join properly.  The 'settings' tool also lets you change snapping distance, but altering that hasn't helped me much yet.  If the boundary isn't bright green after all this, it isn't closed and the next step won't work.&lt;br /&gt;
&lt;br /&gt;
Select the 'Digitize new centroid' tool.  IMPORTANT:  Before continuing, CHANGE MODE BACK TO 'Next not used'.  Use the tool to select somewhere inside the boundary.  The attributes window will open, and you can fill in any area attributes you've created columns for.&lt;br /&gt;
&lt;br /&gt;
You've now created a new area with attributes.  Yay.&lt;br /&gt;
&lt;br /&gt;
Click 'Save and exit'.  You're done.&lt;/div&gt;</summary>
		<author><name>⚠️Caitifty</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Digitizing_Area_Features&amp;diff=10762</id>
		<title>Digitizing Area Features</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Digitizing_Area_Features&amp;diff=10762"/>
		<updated>2010-04-18T19:55:51Z</updated>

		<summary type="html">&lt;p&gt;⚠️Caitifty: /* Specific instructions for digitizing areas */ fix linewrap on code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Digitizing area features with attributes=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
GIS users with experience creating and editing non-topological shapefiles sometimes encounter problems when adding attributes to area features in the GRASS digitizer &amp;lt;tt&amp;gt; v.digit &amp;lt;/tt&amp;gt;. This section will attempt to offer a few tips and clear up this issue. Much has already been written explaining the strict topological vector model which GRASS uses. Please read first:&amp;lt;br&amp;gt;&lt;br /&gt;
:from the wiki- [http://grass.osgeo.org/wiki/Vector_FAQ_GRASS6] [http://grass.osgeo.org/wiki/Vectordata]&amp;lt;br&amp;gt;&lt;br /&gt;
:and from the manual pages- [http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html]&lt;br /&gt;
&lt;br /&gt;
==Problem Description==&lt;br /&gt;
When creating a polygon shapefile, after the user finishes clicking around the perimeter of the polygon, GIS software applications will often pop up a window with all the attribute columns available and the user enters values for that polygon. In the non-topological shapefile format, the area boundary and the enclosed polygon are one and the same. Thus the boundary attributes also refer to the enclosed area. In the shapefile diagram below the labels A-1, A-2, A-3 are taken from the polygon attribute table.  This fact might seem so obvious to shapefile users that they would wonder why it needs mentioning. &lt;br /&gt;
&lt;br /&gt;
In the strict topological model used in GRASS, this is not the case. In a GRASS vector the surrounding boundary, and its enclosed area are two separate entities, which have two separate rows in the accompanying attribute table. The boundary is made up of line segments, and the area is represented by its ''centroid'' – a point within the closed boundary. (Centroids should be placed only within closed boundaries.) A line segment which is part of the boundary enclosing an area does not “belong” to that area, rather it often is common to two adjacent areas.  In the GRASS vector diagram below, boundary B-1 separates areas A-1 and A-2. Boundaries B-3 and B-8 separate between areas A-1 and A-3. Furthermore, the boundary of area A-2 is composed of B-1, B-2 and B-5.  Obviously it would not make sense to attach '''area''' attributes to any boundary, so instead the area ''centroids'' serve to connect to the attribute table rows holding the area attributes. Thus, the labels B-1, B-2, etc. come from the vector attribute table (line features) and the A-1, A-2 labels, also from the attribute table, are ''centroid'' features.  Using the GRASS digitizer, &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt;, care needs to be taken to attach attributes to the correct features.&lt;br /&gt;
&lt;br /&gt;
[[Image:Shape.png|left|400px]] [[Image:Grass_vectors.png|center|400px]]&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
First, it's worth pointing out that when using &amp;lt;tt&amp;gt;v.in.ogr&amp;lt;/TT&amp;gt; to import a polygon shapefile into GRASS, steps are automatically taken to insure that the resulting vector gets the attributes as expected. (This behind-the-scenes procedure might actually fool naive users into believing that GRASS vectors are just like polygon shapefiles).&lt;br /&gt;
*Polygons are imported as boundary lines&lt;br /&gt;
*These lines are split at intersections, and all overlapping boundaries are removed (topologically cleaned)&lt;br /&gt;
*Centroids are placed in each closed boundary&lt;br /&gt;
*The centroids are given a cat value, and attributes from the original shapefile are inserted into the attached database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following are suggestions for adding attributes when using the GRASS digitizer, which more or less duplicate the above process. Detailed explanations of the &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; interface can be found both in the GRASS ([http://www.grassbook.org/ Book]) and the GDF Hannover ([http://www.gdf-hannover.de/lit_html/grass60_v1.2_en/node56.html tutorial]). The new wxGUI digitizer has a good manual page at: [http://grass.osgeo.org/grass64/manuals/html64_user/wxGUI.Vector_Digitizing_Tool.html]&lt;br /&gt;
&lt;br /&gt;
===General case===&lt;br /&gt;
The process that users should follow when manually creating area vectors with &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; will produce boundaries with no attributes, and a centroid connected thru its cat value to the area attributes. First, in the &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; interface, use the settings dialog to set up the attribute table as required by the data, and choose an appropriate snapping tolerance. Also in the settings dialog, under the Attributes tab, there is a drop down list to choose Category Mode (how the cat values will be chosen). For digitizing boundaries, it is possible to &amp;lt;u&amp;gt;choose “No category”&amp;lt;/u&amp;gt; since, as explained above, the boundary lines themselves might not require any attributes. Next digitize boundaries, being careful to &lt;br /&gt;
*close boundaries which delineate areas. &lt;br /&gt;
*never digitize the boundary between adjacent areas twice&lt;br /&gt;
*be sure to enter a node at every intersection of two boundary lines (no crossing boundaries without an intersection node)&lt;br /&gt;
Now, back in the Settings-&amp;gt;Attributes window, reset the Category Mode to &amp;lt;u&amp;gt;“Next not used”&amp;lt;/u&amp;gt;, and begin to digitize centroids for each area. After marking the location for a centroid, enter all attribute data into the table relevant to that area. And that's it.&lt;br /&gt;
&lt;br /&gt;
===A Special Case===&lt;br /&gt;
There are situations where attributes need to be attached also to the boundary lines. For example: in a project mapping out species distribution, the boundaries might have an attribute value indicating the rate of spread of a species across a border. In this case, the boundaries will get a cat value (optionally defined as a separate GRASS “layer”, with a separate database connection). While digitizing, the user will enter values into the attribute table relevant to each boundary. But still, centroids need to be digitized, and attributes entered for each centroid which are relevant to the areas. &lt;br /&gt;
&lt;br /&gt;
===Another Special Case=== &lt;br /&gt;
In some situations a single boundary line exactly encompasses an area, with no adjacent areas. (In other words, each area is an “isle” in GRASS terminology.) An example might be a vector map of water bodies. Obviously no water body touches any other. And the perimeter is one continuous line. Users might want the attribute table to be attached to both the area and the boundary – perhaps to display the length of the perimeter along the perimeter rather than at the centroid. In order to achieve this, boundaries will be digitized with a cat value, and the centroids will be forced to use that same cat value as the boundary. This is done as follows.&amp;lt;br&amp;gt; While working on the boundary, the user should take note of its category value. Next, before marking the centroid, the user will switch the Category Mode to “Manual entry”. Now she digitizes the centroid for that closed boundary and manually types in the &amp;lt;u&amp;gt;same cat value&amp;lt;/u&amp;gt; as the surrounding boundary. This creates two vector features: a boundary line and a centroid, with identical category values, and thus a single row in the database. So all attributes are common to both the boundary and the centroid (area).  &lt;br /&gt;
&lt;br /&gt;
===Note: v.centroids===&lt;br /&gt;
The GRASS tool for adding missing centroids to closed boundaries is &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt;. It is important to realize that the centroids will be created with category values that have no connection to the enclosing boundaries. If you run &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt; on a vector that already has closed boundary lines with attribute values, these attribute values will '''not be attached to the area enclosed''', since the new centroids will be assigned some new category value.  This point is explained in the &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt; [[http://grass.osgeo.org/grass63/manuals/html63_user/v.centroids.html manual]] page.&lt;br /&gt;
   &lt;br /&gt;
--[[User:Micha|Micha]] 22:12, 14 February 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Specific instructions for digitizing areas===&lt;br /&gt;
&lt;br /&gt;
I found this issue to be not that well documented, so here's a specific method for digitizing areas:&lt;br /&gt;
&lt;br /&gt;
An area comprises two primitives - a boundary and a centroid.  The boundary has no attributes; the centroid holds the attributes (if any).&lt;br /&gt;
&lt;br /&gt;
To create an area, a two step process is needed.  First, a boundary is defined, then a centroid added.  You can batch them - define all the boundaries then add the centroids.  I don't know the rules for overlapping areas though - might be better to do those separately.&lt;br /&gt;
&lt;br /&gt;
In this example, you have some existing map layers (for example a layer showing some parks as areas and a layer showing roads) and you want to create a new area by manually digitizing an area based on the existing map layers (eg you want to digitize an area bounded by some specific streets near a park).&lt;br /&gt;
&lt;br /&gt;
These steps create a new map, give it an attribute table, link the attribute table to the map, and open the new map in v.digit displaying the existing layer/s:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
v.in.ascii -e output=newmapname&lt;br /&gt;
&lt;br /&gt;
echo 'create table newmapname (cat integer, DAY date)' | db.execute&lt;br /&gt;
&lt;br /&gt;
v.db.connect -o map=newmapname table=newmapname&lt;br /&gt;
&lt;br /&gt;
v.digit map=newmapname bgcmd=&amp;quot;d.vect map=existingmap1 type=area fcolor=green; d.vect map=existingmap2&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create as many attribute fields as you want within the () area, using whatever field types are allowable for the database type you're using.  If you're using an 'external' database type like mysql, you can also just create a cat field in this step and use regular mysql commands or tools to add additional fields to the table if that's easier.&lt;br /&gt;
&lt;br /&gt;
In the window that opens, zoom the the relevant area, then click the 'Digitize new boundary' button.  IMPORTANT: Before doing anything else, CHANGE MODE TO 'No Category'.  Use the tool to define the boundary of the area, and right-click to close the boundary.  If the boundary is successfully closed, the boundary line will turn bright green. If not, it'll remain grey.  Easiest fix is to click the 'move vertex' button, move one of the vertices back a bit, then using the 'create new boundary' tool, join the two red crosses.  This almost always works, for some reason I can never get the original boundary to join properly.  The 'settings' tool also lets you change snapping distance, but altering that hasn't helped me much yet.  If the boundary isn't bright green after all this, it isn't closed and the next step won't work.&lt;br /&gt;
&lt;br /&gt;
Select the 'Digitize new centroid' tool.  IMPORTANT:  Before continuing, CHANGE MODE BACK TO 'Next not used'.  Use the tool to select somewhere inside the boundary.  The attributes window will open, and you can fill in any area attributes you've created columns for.&lt;br /&gt;
&lt;br /&gt;
You've now created a new area with attributes.  Yay.&lt;br /&gt;
&lt;br /&gt;
Click 'Save and exit'.  You're done.&lt;/div&gt;</summary>
		<author><name>⚠️Caitifty</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Digitizing_Area_Features&amp;diff=10761</id>
		<title>Digitizing Area Features</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Digitizing_Area_Features&amp;diff=10761"/>
		<updated>2010-04-17T20:44:29Z</updated>

		<summary type="html">&lt;p&gt;⚠️Caitifty: Add specific directions for creating an area/centroid with attributes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Digitizing area features with attributes=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
GIS users with experience creating and editing non-topological shapefiles sometimes encounter problems when adding attributes to area features in the GRASS digitizer &amp;lt;tt&amp;gt; v.digit &amp;lt;/tt&amp;gt;. This section will attempt to offer a few tips and clear up this issue. Much has already been written explaining the strict topological vector model which GRASS uses. Please read first:&amp;lt;br&amp;gt;&lt;br /&gt;
:from the wiki- [http://grass.osgeo.org/wiki/Vector_FAQ_GRASS6] [http://grass.osgeo.org/wiki/Vectordata]&amp;lt;br&amp;gt;&lt;br /&gt;
:and from the manual pages- [http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html]&lt;br /&gt;
&lt;br /&gt;
==Problem Description==&lt;br /&gt;
When creating a polygon shapefile, after the user finishes clicking around the perimeter of the polygon, GIS software applications will often pop up a window with all the attribute columns available and the user enters values for that polygon. In the non-topological shapefile format, the area boundary and the enclosed polygon are one and the same. Thus the boundary attributes also refer to the enclosed area. In the shapefile diagram below the labels A-1, A-2, A-3 are taken from the polygon attribute table.  This fact might seem so obvious to shapefile users that they would wonder why it needs mentioning. &lt;br /&gt;
&lt;br /&gt;
In the strict topological model used in GRASS, this is not the case. In a GRASS vector the surrounding boundary, and its enclosed area are two separate entities, which have two separate rows in the accompanying attribute table. The boundary is made up of line segments, and the area is represented by its ''centroid'' – a point within the closed boundary. (Centroids should be placed only within closed boundaries.) A line segment which is part of the boundary enclosing an area does not “belong” to that area, rather it often is common to two adjacent areas.  In the GRASS vector diagram below, boundary B-1 separates areas A-1 and A-2. Boundaries B-3 and B-8 separate between areas A-1 and A-3. Furthermore, the boundary of area A-2 is composed of B-1, B-2 and B-5.  Obviously it would not make sense to attach '''area''' attributes to any boundary, so instead the area ''centroids'' serve to connect to the attribute table rows holding the area attributes. Thus, the labels B-1, B-2, etc. come from the vector attribute table (line features) and the A-1, A-2 labels, also from the attribute table, are ''centroid'' features.  Using the GRASS digitizer, &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt;, care needs to be taken to attach attributes to the correct features.&lt;br /&gt;
&lt;br /&gt;
[[Image:Shape.png|left|400px]] [[Image:Grass_vectors.png|center|400px]]&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
First, it's worth pointing out that when using &amp;lt;tt&amp;gt;v.in.ogr&amp;lt;/TT&amp;gt; to import a polygon shapefile into GRASS, steps are automatically taken to insure that the resulting vector gets the attributes as expected. (This behind-the-scenes procedure might actually fool naive users into believing that GRASS vectors are just like polygon shapefiles).&lt;br /&gt;
*Polygons are imported as boundary lines&lt;br /&gt;
*These lines are split at intersections, and all overlapping boundaries are removed (topologically cleaned)&lt;br /&gt;
*Centroids are placed in each closed boundary&lt;br /&gt;
*The centroids are given a cat value, and attributes from the original shapefile are inserted into the attached database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following are suggestions for adding attributes when using the GRASS digitizer, which more or less duplicate the above process. Detailed explanations of the &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; interface can be found both in the GRASS ([http://www.grassbook.org/ Book]) and the GDF Hannover ([http://www.gdf-hannover.de/lit_html/grass60_v1.2_en/node56.html tutorial]). The new wxGUI digitizer has a good manual page at: [http://grass.osgeo.org/grass64/manuals/html64_user/wxGUI.Vector_Digitizing_Tool.html]&lt;br /&gt;
&lt;br /&gt;
===General case===&lt;br /&gt;
The process that users should follow when manually creating area vectors with &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; will produce boundaries with no attributes, and a centroid connected thru its cat value to the area attributes. First, in the &amp;lt;tt&amp;gt;v.digit&amp;lt;/tt&amp;gt; interface, use the settings dialog to set up the attribute table as required by the data, and choose an appropriate snapping tolerance. Also in the settings dialog, under the Attributes tab, there is a drop down list to choose Category Mode (how the cat values will be chosen). For digitizing boundaries, it is possible to &amp;lt;u&amp;gt;choose “No category”&amp;lt;/u&amp;gt; since, as explained above, the boundary lines themselves might not require any attributes. Next digitize boundaries, being careful to &lt;br /&gt;
*close boundaries which delineate areas. &lt;br /&gt;
*never digitize the boundary between adjacent areas twice&lt;br /&gt;
*be sure to enter a node at every intersection of two boundary lines (no crossing boundaries without an intersection node)&lt;br /&gt;
Now, back in the Settings-&amp;gt;Attributes window, reset the Category Mode to &amp;lt;u&amp;gt;“Next not used”&amp;lt;/u&amp;gt;, and begin to digitize centroids for each area. After marking the location for a centroid, enter all attribute data into the table relevant to that area. And that's it.&lt;br /&gt;
&lt;br /&gt;
===A Special Case===&lt;br /&gt;
There are situations where attributes need to be attached also to the boundary lines. For example: in a project mapping out species distribution, the boundaries might have an attribute value indicating the rate of spread of a species across a border. In this case, the boundaries will get a cat value (optionally defined as a separate GRASS “layer”, with a separate database connection). While digitizing, the user will enter values into the attribute table relevant to each boundary. But still, centroids need to be digitized, and attributes entered for each centroid which are relevant to the areas. &lt;br /&gt;
&lt;br /&gt;
===Another Special Case=== &lt;br /&gt;
In some situations a single boundary line exactly encompasses an area, with no adjacent areas. (In other words, each area is an “isle” in GRASS terminology.) An example might be a vector map of water bodies. Obviously no water body touches any other. And the perimeter is one continuous line. Users might want the attribute table to be attached to both the area and the boundary – perhaps to display the length of the perimeter along the perimeter rather than at the centroid. In order to achieve this, boundaries will be digitized with a cat value, and the centroids will be forced to use that same cat value as the boundary. This is done as follows.&amp;lt;br&amp;gt; While working on the boundary, the user should take note of its category value. Next, before marking the centroid, the user will switch the Category Mode to “Manual entry”. Now she digitizes the centroid for that closed boundary and manually types in the &amp;lt;u&amp;gt;same cat value&amp;lt;/u&amp;gt; as the surrounding boundary. This creates two vector features: a boundary line and a centroid, with identical category values, and thus a single row in the database. So all attributes are common to both the boundary and the centroid (area).  &lt;br /&gt;
&lt;br /&gt;
===Note: v.centroids===&lt;br /&gt;
The GRASS tool for adding missing centroids to closed boundaries is &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt;. It is important to realize that the centroids will be created with category values that have no connection to the enclosing boundaries. If you run &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt; on a vector that already has closed boundary lines with attribute values, these attribute values will '''not be attached to the area enclosed''', since the new centroids will be assigned some new category value.  This point is explained in the &amp;lt;tt&amp;gt;v.centroids&amp;lt;/tt&amp;gt; [[http://grass.osgeo.org/grass63/manuals/html63_user/v.centroids.html manual]] page.&lt;br /&gt;
   &lt;br /&gt;
--[[User:Micha|Micha]] 22:12, 14 February 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Specific instructions for digitizing areas===&lt;br /&gt;
&lt;br /&gt;
I found this issue to be not that well documented, so here's a specific method for digitizing areas:&lt;br /&gt;
&lt;br /&gt;
An area comprises two primitives - a boundary and a centroid.  The boundary has no attributes; the centroid holds the attributes (if any).&lt;br /&gt;
&lt;br /&gt;
To create an area, a two step process is needed.  First, a boundary is defined, then a centroid added.  You can batch them - define all the boundaries then add the centroids.  I don't know the rules for overlapping areas though - might be better to do those separately.&lt;br /&gt;
&lt;br /&gt;
In this example, you have some existing map layers (for example a layer showing some parks as areas and a layer showing roads) and you want to create a new area by manually digitizing an area based on the existing map layers (eg you want to digitize an area bounded by some specific streets near a park).&lt;br /&gt;
&lt;br /&gt;
These steps create a new map, give it an attribute table, link the attribute table to the map, and open the new map in v.digit displaying the existing layer/s:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
v.in.ascii -e output=newmapname&lt;br /&gt;
echo 'create table newmapname (cat integer, DAY date)' | db.execute&lt;br /&gt;
v.db.connect -o map=newmapname table=newmapname&lt;br /&gt;
v.digit map=newmapname bgcmd=&amp;quot;d.vect map=existingmap1 type=area fcolor=green; d.vect map=existingmap2&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create as many attribute fields as you want within the () area, using whatever field types are allowable for the database type you're using.  If you're using an 'external' database type like mysql, you can also just create a cat field in this step and use regular mysql commands or tools to add additional fields to the table if that's easier.&lt;br /&gt;
&lt;br /&gt;
In the window that opens, zoom the the relevant area, then click the 'Digitize new boundary' button.  IMPORTANT: Before doing anything else, CHANGE MODE TO 'No Category'.  Use the tool to define the boundary of the area, and right-click to close the boundary.  If the boundary is successfully closed, the boundary line will turn bright green. If not, it'll remain grey.  Easiest fix is to click the 'move vertex' button, move one of the vertices back a bit, then using the 'create new boundary' tool, join the two red crosses.  This almost always works, for some reason I can never get the original boundary to join properly.  The 'settings' tool also lets you change snapping distance, but altering that hasn't helped me much yet.  If the boundary isn't bright green after all this, it isn't closed and the next step won't work.&lt;br /&gt;
&lt;br /&gt;
Select the 'Digitize new centroid' tool.  IMPORTANT:  Before continuing, CHANGE MODE BACK TO 'Next not used'.  Use the tool to select somewhere inside the boundary.  The attributes window will open, and you can fill in any area attributes you've created columns for.&lt;br /&gt;
&lt;br /&gt;
You've now created a new area with attributes.  Yay.&lt;br /&gt;
&lt;br /&gt;
Click 'Save and exit'.  You're done.&lt;/div&gt;</summary>
		<author><name>⚠️Caitifty</name></author>
	</entry>
</feed>