|
|
行1: |
行1: |
− | == GRASS GIS Integration ==
| |
− | <span id='sec:grass'></span>
| |
− |
| |
− | The GRASS plugin provides access to GRASS GIS {{Template:Cite|num=4|ref=GRASSweb}} databases and
| |
− | functionalities. This includes visualization of GRASS raster and vector
| |
− | layers, digitizing vector layers, editing vector attributes, creating new
| |
− | vector layers and analysing GRASS 2D and 3D data with more than 300 GRASS
| |
− | modules.
| |
− |
| |
− | In this Section we'll introduce the plugin functionalities and give some
| |
− | examples on managing and working with GRASS data. Following main features
| |
− | are provided with the toolbar menu, when you start the GRASS plugin, as
| |
− | described in Section [[#sec:starting_grass|9.1]]:
| |
− |
| |
− | <ul>
| |
− | <li>{{Template:ToolBtnTwo|grass_open_mapset|Open mapset}}
| |
− | <li>{{Template:ToolBtnTwo|grass_new_mapset|New mapset}}
| |
− | <li>{{Template:ToolBtnTwo|grass_close_mapset|Close mapset}}
| |
− | <li>{{Template:ToolBtnTwo|grass_add_vector|Add GRASS vector layer}}
| |
− | <li>{{Template:ToolBtnTwo|grass_add_raster|Add GRASS raster layer}}
| |
− | <li>{{Template:ToolBtnTwo|grass_new_vector_layer|Create new GRASS vector}}
| |
− | <li>{{Template:ToolBtnTwo|grass_edit|Edit GRASS vector layer}}
| |
− | <li>{{Template:ToolBtnTwo|grass_tools|Open GRASS tools}}
| |
− | <li>{{Template:ToolBtnTwo|grass_region|Display current GRASS region}}
| |
− | <li>{{Template:ToolBtnTwo|grass_region_edit|Edit current GRASS region}}
| |
− | </ul>
| |
− |
| |
− | === Starting the GRASS plugin ===
| |
− | <span id='sec:starting_grass'></span>
| |
− |
| |
− | To use GRASS functionalities and/or visualize GRASS vector and raster layers
| |
− | in QGIS, you must select and load the GRASS plugin with the Plugin Manager.
| |
− | Therefore click the menu {{Template:MainMenuOpt|Plugins}} > {{Template:MainMenuOpt|Manage Plugins}},
| |
− | select {{Template:DropMenuOpt|GRASS}} and click {{Template:Button|OK}}.
| |
− |
| |
− | You can now start loading raster and vector layers from an existing GRASS
| |
− | {{Template:FileName|LOCATION}} (see Section [[#sec:load_grassdata|9.2]]). Or you create a
| |
− | new GRASS {{Template:FileName|LOCATION}} with QGIS (see Section [[#sec:create_loc|9.3.1]])
| |
− | and import some raster and vector data (see Section [[#sec:import_loc_data|9.4]])
| |
− | for further analysis with the GRASS Toolbox (see Section
| |
− | [[#subsec:grass_toolbox|9.9]]).
| |
− |
| |
− | === Loading GRASS raster and vector layers ===
| |
− | <span id='sec:load_grassdata'></span>
| |
− | With the GRASS plugin, you can load vector or raster layers using the
| |
− | appropriate button on the toolbar menu. As an example we use the QGIS alaska
| |
− | dataset (see Section [[label_sampledata]]). It includes a small sample
| |
− | GRASS {{Template:FileName|LOCATION}} with 3 vector layers and 1 raster elevation map.
| |
− |
| |
− | <ol>
| |
− | <li>Create a new folder {{Template:FileName|grassdata}}, download the QGIS alaska
| |
− | dataset {{Template:FileName|qgis_sample_data.zip}} from
| |
− | {{Template:URL|http://download.osgeo.org/qgis/data/}} and unzip the file into
| |
− | {{Template:FileName|grassdata}}.
| |
− | <li>Start QGIS.
| |
− | <li>If not already done in a previous QGIS session, load the GRASS plugin
| |
− | clicking on {{Template:MainMenuOpt|Plugins}} > {{Template:MainMenuOpt|Manage Plugins}} and
| |
− | selecting {{Template:DropMenuOpt|GRASS}}. The GRASS toolbar appears on the toolbar menu.
| |
− | <li>In the GRASS toolbar, click the {{Template:ToolBtnTwo|grass_open_mapset|Open
| |
− | mapset}} icon to bring up the {{Template:FileName|MAPSET}} wizard.
| |
− | <li>For {{Template:FileName|Gisdbase}} browse and select or enter the path to the
| |
− | newly created folder {{Template:FileName|grassdata}}.
| |
− | <li>You should now be able to select the {{Template:FileName|LOCATION alaska}}
| |
− | and the MAPSET {{Template:FileName|demo}}.
| |
− | <li>Click {{Template:Button|OK}}. Notice that some previously disabled tools in the
| |
− | GRASS toolbar are now enabled.
| |
− | <li>Click on {{Template:ToolBtnTwo|grass_add_raster|Add GRASS raster layer}},
| |
− | choose the map name {{Template:FileName|gtopo30}} and click {{Template:Button|OK}}. The elevation
| |
− | layer will be visualized.
| |
− | <li>Click on {{Template:ToolBtnTwo|grass_add_vector|Add GRASS vector layer}},
| |
− | choose the map name {{Template:FileName|alaska}} and click {{Template:Button|OK}}. The alaska
| |
− | boundary vector layer will be overlayed on top of the gtopo30 map. You can
| |
− | now adapt the layer properties as described in chapter [[sec:vectorprops]],
| |
− | e.g. change opacity, fill and outline color.
| |
− | <li>Also load the other two vector layers {{Template:FileName|rivers}} and
| |
− | {{Template:FileName|airports}} and adapt their properties.
| |
− | </ol>
| |
− |
| |
− | As you see, it is very simple to load GRASS raster and vector layers in QGIS.
| |
− | See following Sections for editing GRASS data and creating a new
| |
− | {{Template:FileName|LOCATION}}. More sample GRASS {{Template:FileName|LOCATIONs}} are available at
| |
− | the GRASS website at {{Template:URL|http://grass.osgeo.org/download/data.php}}.
| |
− |
| |
− | {{Template:Tip
| |
− | |num=34
| |
− | |caption=GRASS Data Loading
| |
− | |qgistip=If you have problems loading data or QGIS terminates abnormally,
| |
− | check to make sure you have loaded the GRASS plugin properly as described in
| |
− | Section [[#sec:starting_grass|9.1]].
| |
− |
| |
− | }}
| |
− |
| |
− | === GRASS LOCATION and MAPSET ===
| |
− | <span id='sec:about_loc'></span>
| |
− | GRASS data are stored in a directory referred to as GISDBASE. This directory
| |
− | often called {{Template:FileName|grassdata}}, must be created before you start working
| |
− | with the GRASS plugin in QGIS. Within this directory, the GRASS GIS data
| |
− | are organized by projects stored in subdirectories called {{Template:FileName|LOCATION}}.
| |
− | Each {{Template:FileName|LOCATION}} is defined by its coordinate system, map projection
| |
− | and geographical boundaries. Each {{Template:FileName|LOCATION}} can have several
| |
− | {{Template:FileName|MAPSETs}} (subdirectories of the {{Template:FileName|LOCATION}}) that are used
| |
− | to subdivide the project into different topics, subregions, or as workspaces
| |
− | for individual team members (Neteler & Mitasova 2008
| |
− | {{Template:Cite|num=2|ref=neteler_mitasova08}}). In order to analyze vector and raster layers with
| |
− | GRASS modules, you must import them into a GRASS {{Template:FileName|LOCATION}}.
| |
− | <ref>This is not strictly true - with the GRASS modules
| |
− | {{Template:FileName|r.external}} and {{Template:FileName|v.external}} you can create read-only links
| |
− | to external GDAL/OGR-supported data sets without importing them. But because
| |
− | this is not the usual way for beginners to work with GRASS, this functionality
| |
− | will not be described here.</ref>
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 25:''' GRASS data in the alaska LOCATION (adapted from Neteler &
| |
− | Mitasova 2008 {{Template:Cite|num=2|ref=neteler_mitasova08)}}</caption>
| |
− | <tr><td><span id='fig:grass_location'></span>
| |
− | [[File:grass_location.png]]</td></tr></table>
| |
− |
| |
− | ==== Creating a new GRASS LOCATION ====
| |
− | <span id='sec:create_loc'></span>
| |
− | As an an example you find the instructions how the sample GRASS
| |
− | {{Template:FileName|LOCATION alaska}}, which is projected in Albers Equal Area
| |
− | projection with unit feet was created for the QGIS sample dataset. This
| |
− | sample GRASS {{Template:FileName|LOCATION alaska}} will be used for all examples and
| |
− | exercises in the following GRASS GIS related chapters. It is useful to
| |
− | download and install the dataset on your computer [[label_sampledata]]).
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 26:''' Creating a new GRASS LOCATION or a new MAPSET in QGIS {{Template:Nix}}</caption>
| |
− | <tr><td>
| |
− | <span id='fig:create_grass_location'></span>
| |
− | [[File:create_grass_location.png|378px]]</td></tr></table>
| |
− |
| |
− | <ol>
| |
− | <li>Start QGIS and make sure the GRASS plugin is loaded
| |
− | <li>Visualize the {{Template:FileName|alaska.shp}} Shapefile (see Section
| |
− | [[sec:load_shapefile]]) from the QGIS alaska dataset~[[label_sampledata]].
| |
− | <li>In the GRASS toolbar, click on the {{Template:ToolBtnTwo|grass_open_mapset|Open
| |
− | mapset}} icon to bring up the {{Template:FileName|MAPSET}} wizard.
| |
− | <li>Select an existing GRASS database (GISDBASE) folder
| |
− | {{Template:FileName|grassdata}} or create one for the new {{Template:FileName|LOCATION}} using a
| |
− | file manager on your computer. Then click {{Template:Button|Next}}.
| |
− | <li>We can use this wizard to create a new {{Template:FileName|MAPSET}} within an
| |
− | existing {{Template:FileName|LOCATION}} (see Section~[[sec:add_mapset]]) or to create
| |
− | a new {{Template:FileName|LOCATION}} altogether. Click on the radio button
| |
− | {{Template:RadioButtonOn|Create new location}} (see Figure [[#fig:create_grass_location|26]]).
| |
− | <li>Enter a name for the {{Template:FileName|LOCATION}} - we used alaska and click
| |
− | {{Template:Button|Next}}
| |
− | <li>Define the projection by clicking on the radio button
| |
− | {{Template:RadioButtonOn|Projection}} to enable the projection list
| |
− | <li>We are using Albers Equal Area Alaska (feet) projection. Since we
| |
− | happen to know that it is represented by the EPSG ID 2964, we enter it in
| |
− | the search box. (Note: If you want to repeat this process for another
| |
− | {{Template:FileName|LOCATION}} and projection and haven't memorized the EPSG ID,
| |
− | click on the
| |
− | {{Template:ToolBtnTwo|mIconProjectionEnabled|projector}} icon in the lower right-hand
| |
− | corner of the status bar (see Section [[label_projstart]])).
| |
− | <li>Click {{Template:Button|Find}} to select the projection
| |
− | <li>Click {{Template:Button|Next}}
| |
− | <li>To define the default region, we have to enter the {{Template:FileName|LOCATION}}
| |
− | bounds in north, south, east, and west direction. Here we simply click on
| |
− | the button {{Template:Button|Set current QGIS extent}}, to apply the extend of the
| |
− | loaded layer {{Template:FileName|alaska.shp}} as the GRASS default region extend.
| |
− | <li>Click {{Template:Button|Next}}
| |
− | <li>We also need to define a {{Template:FileName|MAPSET}} within our new
| |
− | {{Template:FileName|LOCATION}}. You can name it whatever you like - we used demo.
| |
− | <ref>{When creating a new {{Template:FileName|LOCATION}}, GRASS automatically
| |
− | creates a special {{Template:FileName|MAPSET}} called {{Template:FileName|PERMANENT}} designed to
| |
− | store the core data for the project, its default spatial extend and
| |
− | coordinate system definitions (Neteler & Mitasova 2008
| |
− | {{Template:Cite|num=2|ref=neteler_mitasova08}}).</ref>
| |
− | <li>Check out the summary to make sure it's correct and click
| |
− | {{Template:Button|Finish}}
| |
− | <li>The new {{Template:FileName|LOCATION alaska}} and two {{Template:FileName|MAPSETs demo}}
| |
− | and {{Template:FileName|PERMANENT}} are created. The currently opened working set is
| |
− | {{Template:FileName|MAPSET demo}}, as you defined.
| |
− | <li>Notice that some of the tools in the GRASS toolbar that were
| |
− | disabled are now enabled.
| |
− | </ol>
| |
− |
| |
− | If that seemed like a lot of steps, it's really not all that bad and a very
| |
− | quick way to create a {{Template:FileName|LOCATION}}. The {{Template:FileName|LOCATION alaska}} is
| |
− | now ready for data import (see Section [[#sec:import_loc_data|9.4]]).
| |
− | You can also use the already existing vector and raster data in the sample
| |
− | GRASS {{Template:FileName|LOCATION alaska}} included in the QGIS alaska dataset
| |
− | [[label_sampledata]] and move on to Section [[#label_vectmodel|9.5]].
| |
− |
| |
− | ==== Adding a new MAPSET ====
| |
− | <span id='sec:add_mapset'></span>
| |
− | A user has only write access to a GRASS {{Template:FileName|MAPSET}} he created. This
| |
− | means, besides access to his own {{Template:FileName|MAPSET}}, each user can also read
| |
− | maps in other user's {{Template:FileName|MAPSETs}}, but he can modify or remove only
| |
− | the maps in his own {{Template:FileName|MAPSET}}. All {{Template:FileName|MAPSETs}} include a
| |
− | {{Template:FileName|WIND}} file that stores the current boundary coordinate values and
| |
− | the currently selected raster resolution (Neteler & Mitasova 2008
| |
− | {{Template:Cite|num=2|ref=neteler_mitasova08}}, see Section [[#sec:grass_region|9.8]]).
| |
− |
| |
− | <ol>
| |
− | <li>Start QGIS and make sure the GRASS plugin is loaded
| |
− | <li>In the GRASS toolbar, click on the
| |
− | {{Template:ToolBtnTwo|grass_new_mapset|New mapset}} icon to bring up the
| |
− | {{Template:FileName|MAPSET}} wizard.
| |
− | <li>Select the GRASS database (GISDBASE) folder {{Template:FileName|grassdata}}
| |
− | with the {{Template:FileName|LOCATION alaska}}, where we want to add a further
| |
− | {{Template:FileName|MAPSET}}, called test.
| |
− | <li>Click {{Template:Button|Next}}.
| |
− | <li>We can use this wizard to create a new {{Template:FileName|MAPSET}} within an
| |
− | existing {{Template:FileName|LOCATION}} or to create a new {{Template:FileName|LOCATION}}
| |
− | altogether. Click on the radio button {{Template:RadioButtonOn|Select location}}
| |
− | (see Figure [[#fig:create_grass_location|26]]) and click {{Template:Button|Next}}.
| |
− | <li>Enter the name {{Template:FileName|text}} for the new {{Template:FileName|MAPSET}}. Below
| |
− | in the wizard you see a list of existing {{Template:FileName|MAPSETs}} and its owners.
| |
− | <li>Click {{Template:Button|Next}}, check out the summary to make sure it's all
| |
− | correct and click {{Template:Button|Finish}}
| |
− | </ol>
| |
− |
| |
− | === Importing data into a GRASS LOCATION ===
| |
− | <span id='sec:import_loc_data'></span>
| |
− | This Section gives an example how to import raster and vector data into the
| |
− | {{Template:FileName|alaska}} GRASS {{Template:FileName|LOCATION}} provided by the QGIS alaska
| |
− | dataset. Therefore we use a landcover raster map {{Template:FileName|landcover.img}}
| |
− | and a vector GML File {{Template:FileName|lakes.gml}} from the QGIS alaska
| |
− | dataset [[label_sampledata]].
| |
− |
| |
− | <ol>
| |
− | <li>Start QGIS and make sure the GRASS plugin is loaded.
| |
− | <li>In the GRASS toolbar, click the {{Template:ToolBtnTwo|grass_open_mapset|Open
| |
− | MAPSET}} icon to bring up the {{Template:FileName|MAPSET}} wizard.
| |
− | <li>Select as GRASS database the folder {{Template:FileName|grassdata}} in the QGIS
| |
− | alaska dataset, as {{Template:FileName|LOCATION alaska}}, as {{Template:FileName|MAPSET}}
| |
− | {{Template:FileName|demo}} and click {{Template:Button|OK}}.
| |
− | <li>Now click the {{Template:ToolBtnTwo|grass_tools|Open GRASS tools}} icon. The
| |
− | GRASS Toolbox (see Section [[#subsec:grass_toolbox|9.9]]) dialog appears.
| |
− | <li>To import the raster map {{Template:FileName|landcover.img}}, click the module
| |
− | {{Template:FileName|r.in.gdal}} in the {{Template:Tab|Modules Tree}} tab. This GRASS module
| |
− | allows to import GDAL supported raster files into a GRASS
| |
− | {{Template:FileName|LOCATION}}. The module dialog for {{Template:FileName|r.in.gdal}} appears.
| |
− | <li>Browse to the folder {{Template:FileName|raster}} in the QGIS alaska dataset
| |
− | and select the file {{Template:FileName|landcover.img}}.
| |
− | <li>As raster output name define {{Template:FileName|landcover_grass}} and click
| |
− | {{Template:Button|Run}}. In the {{Template:Tab|Output}} tab you see the currently running GRASS
| |
− | command {{Template:FileName|1=r.in.gdal -o input=/path/to/landcover.img
| |
− | output=landcover_grass}}.
| |
− | <li>When it says '''Succesfully finished''' click {{Template:Button|View output}}.
| |
− | The {{Template:FileName|landcover_grass}} raster layer is now imported into GRASS and
| |
− | will be visualized in the QGIS canvas.
| |
− | <li>To import the vector GML file {{Template:FileName|lakes.gml}}, click the module
| |
− | {{Template:FileName|v.in.ogr}} in the {{Template:Tab|Modules Tree}} tab. This GRASS module allows
| |
− | to import OGR supported vector files into a GRASS {{Template:FileName|LOCATION}}. The
| |
− | module dialog for {{Template:FileName|v.in.ogr}} appears.
| |
− | <li>Browse to the folder {{Template:FileName|gml}} in the QGIS alaska
| |
− | dataset and select the file {{Template:FileName|lakes.gml}} as OGR file.
| |
− | <li>As vector output name define {{Template:FileName|lakes_grass}} and click
| |
− | {{Template:Button|Run}}. You don't have to care about the other options in this
| |
− | example. In the {{Template:Tab|Output}} tab you see the currently running GRASS
| |
− | command {{Template:FileName|1=v.in.ogr -o dsn=/path/to/lakes.gml output=lakes_grass}}.
| |
− | <li>When it says '''Succesfully finished''' click {{Template:Button|View output}}.
| |
− | The {{Template:FileName|lakes_grass}} vector layer is now imported into GRASS and will
| |
− | be visualized in the QGIS canvas.
| |
− | </ol>
| |
− |
| |
− | === The GRASS vector data model ===
| |
− | <span id='label_vectmodel'></span>
| |
− |
| |
− | It is important to understand the GRASS vector data model prior to
| |
− | digitizing. In general, GRASS uses a topological
| |
− | vector model. This means that areas are not represented
| |
− | as closed polygons, but by one or more boundaries. A boundary between two
| |
− | adjacent areas is digitized only once, and it is shared by both areas.
| |
− | Boundaries must be connected without gaps. An area is identified (labeled)
| |
− | by the centroid of the area.
| |
− |
| |
− | Besides boundaries and centroids, a vector map can also contain
| |
− | points and lines. All these geometry elements can be mixed
| |
− | in one vector and will be represented in different so called 'layers' inside
| |
− | one GRASS vector map. So in GRASS a layer is not a vector or raster map but a
| |
− | level inside a vector layer. This is important to distinguish carefully.
| |
− | <ref>Although it
| |
− | is possible to mix geometry elements, it is unusual and even in GRASS only
| |
− | used in special cases such as vector network analysis. Normally you should
| |
− | prefere to store different geometry elements in different layers.</ref>
| |
− | It is possible to store more 'layers' in one vector dataset. For example,
| |
− | fields, forests and lakes can be stored in one vector. Adjacent
| |
− | forest and lake can share the same boundary, but they have separate attribute
| |
− | tables. It is also possible to attach attributes to boundaries. For example,
| |
− | the boundary between lake and forest is a road, so it can have a different
| |
− | attribute table.
| |
− |
| |
− | The 'layer' of the feature is defined by 'layer' inside GRASS. 'Layer' is the
| |
− | number which defines if there are more than one layer inside the dataset, e.g.
| |
− | if the geometry is forest or lake. For now, it can be only a number, in the
| |
− | future GRASS will also support names as fields in the user interface.
| |
− |
| |
− | Attributes can be stored inside the GRASS {{Template:FileName|LOCATION}} as DBase or
| |
− | SQLITE3 or in external database tables, for example PostgreSQL, MySQL,
| |
− | Oracle, etc.
| |
− |
| |
− | Attributes in database tables are linked to geometry elements using
| |
− | a 'category' value. 'Category' (key, ID) is an
| |
− | integer attached to geometry primitives, and it is used as the link to one
| |
− | key column in the database table.
| |
− |
| |
− | {{Template:Tip
| |
− | |num=35
| |
− | |caption=Learning the GRASS Vector Model
| |
− | |qgistip=
| |
− | The best way to learn the GRASS vector model and its capabilities is to
| |
− | download one of the many GRASS tutorials where the vector model is described
| |
− | more deeply. See {{Template:URL|http://grass.osgeo.org/gdp/manuals.php}} for more
| |
− | information, books and tutorials in several languages.
| |
− | }}
| |
− |
| |
− | === Creating a new GRASS vector layer ===
| |
− | <span id='sec:creating_new_grass_vectors'></span>
| |
− | To create a new GRASS vector layer with the GRASS plugin click the
| |
− | {{Template:ToolBtnTwo|grass_new_vector_layer|Create new GRASS vector}} toolbar icon.
| |
− | Enter a name in the text box and you can start digitizing point, line or
| |
− | polygone geometries, following the procedure described in Section
| |
− | [[#grass_digitising|9.7]].
| |
− |
| |
− | In GRASS it is possible to organize all sort of geometry types (point, line
| |
− | and area) in one layer, because GRASS uses a topological vector model, so you
| |
− | don't need to select the geometry type when creating a new GRASS vector. This
| |
− | is different from Shapefile creation with QGIS, because Shapefiles use the
| |
− | Simple Feature vector model (see Section [[sec:create shape]]).
| |
− |
| |
− | {{Template:Tip
| |
− | |num=36
| |
− | |caption=Creating an attribute table for a new GRASS vector layer
| |
− | |qgistip=
| |
− | If you want to assign attributes to your digitized geometry features, make sure to create an attribute table with columns before you start digitizing (see Figure [[#fig:grass_digitizing_table|31]]).
| |
− | }}
| |
− |
| |
− | === Digitizing and editing a GRASS vector layer ===
| |
− | <span id='grass_digitising'></span>
| |
− | The digitizing tools for GRASS vector layers are accessed using the
| |
− | {{Template:ToolBtnTwo|grass_edit|Edit GRASS vector layer}} icon on the toolbar. Make
| |
− | sure you have loaded a GRASS vector and it is the selected layer in the legend
| |
− | before clicking on the edit tool. Figure [[#fig:grass_digitizing_category|28]]
| |
− | shows the GRASS edit dialog that is displayed when you click on the edit tool.
| |
− | The tools and settings are discussed in the following sections.
| |
− |
| |
− | {{Template:Tip
| |
− | |num=37
| |
− | |caption=Digitizing polygones in GRASS
| |
− | |qgistip=
| |
− | If you want to create a polygone in GRASS, you first digitize the boundary of
| |
− | the polygone, setting the mode to {{Template:UserText|No category}}. Then you add a
| |
− | centroid (label point) into the closed boundary, setting the mode to
| |
− | {{Template:UserText|Next not used}}. The reason is, that a topological vector model links
| |
− | attribute information of a polygon always to the centroid and not to the
| |
− | boundary.
| |
− | }}
| |
− |
| |
− | ===== Toolbar =====
| |
− | <span id='label_grasstoolbar'></span>
| |
− | In Figure [[#fig:grass_digitizing_toolbar|27]] you see the GRASS digitizing
| |
− | toolbar icons provided by the GRASS plugin. Table [[tab:grass_tools]]
| |
− | explains the available functionalities.
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 27:''' GRASS Digitizing Toolbar {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_digitizing_toolbar'></span>
| |
− | [[File:grass_digitizing_toolbar.png|454px]]</td></tr></table>
| |
− |
| |
− | <table border='1' aligh='center'><caption>'''表 3:''' GRASS Digitizing Tools</caption><span id='tab:grass_tools'></span>
| |
− | <!-- {|l|l|p{5in}|} -->
| |
− | <tr><td> '''Icon''' <td> '''Tool''' <td width='480'> '''Purpose''' </tr>
| |
− | <tr><td> [[File:grass_new_point.png|26px]] <td> New Point <td> Digitize
| |
− | new point </tr>
| |
− | <tr><td> [[File:grass_new_line.png|26px]] <td> New Line <td> Digitize
| |
− | new line (finish by selecting new tool) </tr>
| |
− | <tr><td> [[File:grass_new_boundary.png|26px]] <td> New Boundary <td>
| |
− | Digitize new boundary (finish by selecting new tool)</tr>
| |
− | <tr><td> [[File:grass_new_centroid.png|26px]] <td> New Centroid <td>
| |
− | Digitize new centroid (label existing area)</tr>
| |
− | <tr><td> [[File:grass_move_vertex.png|26px]] <td> Move vertex <td> Move
| |
− | one vertex of existing line or boundary and identify new position</tr>
| |
− | <tr><td> [[File:grass_add_vertex.png|26px]] <td> Add vertex <td> Add a
| |
− | new vertex to existing line</tr>
| |
− | <tr><td> [[File:grass_delete_vertex.png|26px]] <td> Delete vertex <td>
| |
− | Delete vertex from existing line (confirm selected vertex by another click)</tr>
| |
− | <tr><td> [[File:grass_move_line.png|26px]] <td> Move element <td> Move
| |
− | selected boundary, line, point or centroid and click on new position</tr>
| |
− | <tr><td> [[File:grass_split_line.png|26px]] <td> Split line <td> Split
| |
− | an existing line to 2 parts</tr>
| |
− | <tr><td> [[File:grass_delete_line.png|26px]] <td> Delete element <td>
| |
− | Delete existing boundary, line, point or centroid (confirm selected element by
| |
− | another click)</tr>
| |
− | <tr><td> [[File:grass_edit_attributes.png|26px]] <td> Edit attributes
| |
− | <td> Edit attributes of selected element (note that one element can represent
| |
− | more features, see above)</tr>
| |
− | <tr><td> [[File:grass_close_edit.png|26px]] <td> Close <td> Close
| |
− | session and save current status (rebuilds topology afterwards)</tr>
| |
− | </table>
| |
− |
| |
− | ===== Category Tab =====
| |
− |
| |
− | The {{Template:Tab|Category}} tab allows you to define the way in which the category
| |
− | values will be assigned to a new geometry element.
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 28:''' GRASS Digitizing Category Tab {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_digitizing_category'></span>
| |
− | [[File:grass_digitizing_category.png|378px]]</td></tr></table>
| |
− |
| |
− | <ul>
| |
− | <li>'''Mode''': what category value shall be applied to new geometry
| |
− | elements.
| |
− | <ul>
| |
− | <li>Next not used - apply next not yet used category value to geometry
| |
− | element.
| |
− | <li>Manual entry - manually define the category value for the geometry
| |
− | element in the 'Category'-entry field.
| |
− | <li>No category - Do not apply a category value to the geometry element.
| |
− | This is e.g. used for area boundaries, because the category values are
| |
− | connected via the centroid.
| |
− | </ul>
| |
− | <li>'''Category''' - A number (ID) is attached to each digitized geometry
| |
− | element. It is used to connect each geometry element with its attributes.
| |
− | <li>'''Field (layer)''' - Each geometry element can be connected with
| |
− | several attribute tables using different GRASS geometry layers. Default layer
| |
− | number is 1.
| |
− | </ul>
| |
− |
| |
− | {{Template:Tip
| |
− | |num=38
| |
− | |caption=Creating an additional GRASS 'layer' with QGIS
| |
− | |qgistip=If you would like to add more layers to your dataset, just add a new
| |
− | number in the 'Field (layer)' entry box and press return. In the Table tab
| |
− | you can create your new table connected to your new layer.
| |
− | }}
| |
− |
| |
− | ===== Settings Tab =====
| |
− | <span id='label_settingtab'></span>
| |
− |
| |
− | The {{Template:Tab|Settings}} tab allows you to set the snapping in screen pixels. The
| |
− | threshold defines at what distance new points or line ends are snapped to
| |
− | existing nodes. This helps to prevent gaps or dangles between boundaries. The
| |
− | default is set to 10 pixels.
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 29:''' GRASS Digitizing Settings Tab {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_digitizing_settings'></span>
| |
− | [[File:grass_digitizing_settings.png|302px]]</td></tr></table>
| |
− |
| |
− | ===== Symbology Tab =====
| |
− |
| |
− | The {{Template:Tab|Symbology}} tab allows you to view and set symbology and color
| |
− | settings for various geometry types and their topological status (e.g. closed
| |
− | / opened boundary).
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 30:''' GRASS Digitizing Symbolog Tab {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_digitizing_symbology'></span>
| |
− | [[File:grass_digitizing_symbology.png|302px]]</td></tr></table>
| |
− |
| |
− | ===== Table Tab =====
| |
− |
| |
− | The {{Template:Tab|Table}} tab provides information about the database table for
| |
− | a given 'layer'. Here you can add new columns to an existing attribute table,
| |
− | or create a new database table for a new GRASS vector layer (see Section
| |
− | [[#sec:creating_new_grass_vectors|9.6]]).
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 31:''' GRASS Digitizing Table Tab {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_digitizing_table'></span>
| |
− | [[File:grass_digitizing_table.png|378px]]</td></tr></table>
| |
− |
| |
− | {{Template:Tip
| |
− | |num=39
| |
− | |caption=GRASS Edit Permissions
| |
− | |qgistip=You must be the owner of the GRASS {{Template:FileName|MAPSET}} you want to
| |
− | edit. It is impossible to edit data layers in a {{Template:FileName|MAPSET}} that is not
| |
− | yours, even if you have write permissions.
| |
− | }}
| |
− |
| |
− | === The GRASS region tool ===
| |
− | <span id='sec:grass_region'></span>
| |
− | The region definition (setting a spatial working window) in GRASS is important
| |
− | for working with raster layers. Vector analysis is per default not limited
| |
− | to any defined region definitions. All newly-created rasters will have the
| |
− | spatial extension and resolution of the currently defined GRASS region,
| |
− | regardless of their original extension and resolution. The current GRASS
| |
− | region is stored in the {{Template:FileName|$LOCATION/$MAPSET/WIND}} file, and it
| |
− | defines north, south, east and west bounds, number of columns and rows,
| |
− | horizontal and vertical spatial resolution.
| |
− |
| |
− | It is possible to switch on/off the visualization of the GRASS region in the
| |
− | QGIS canvas using the {{Template:ToolBtnTwo|grass_region|Display current GRASS region}}
| |
− | button. .
| |
− |
| |
− | With the {{Template:ToolBtnTwo|grass_region_edit|Edit current GRASS region}} icon you
| |
− | can open a dialog to change the current region and the symbology of the GRASS
| |
− | region rectangle in the QGIS canvas. Type in the new region bounds and
| |
− | resolution and click {{Template:Button|OK}}. It also allows to select a new region
| |
− | interactively with your mouse on the QGIS canvas. Therefore click with the
| |
− | left mouse button in the QGIS canvas, open a rectangle, close it using the
| |
− | left mouse button again and click {{Template:Button|OK}}.
| |
− | The GRASS module {{Template:FileName|g.region}} provide a lot more parameters to define
| |
− | an appropriate region extend and resolution for your raster analysis. You can
| |
− | use these parameters with the GRASS Toolbox, described in Section
| |
− | [[#subsec:grass_toolbox|9.9]].
| |
− |
| |
− | === The GRASS toolbox ===
| |
− | <span id='subsec:grass_toolbox'></span>
| |
− | The {{Template:ToolBtnTwo|grass_tools|Open GRASS Tools}} box provides GRASS module
| |
− | functionalities to work with data inside a selected GRASS {{Template:FileName|LOCATION}}
| |
− | and {{Template:FileName|MAPSET}}. To use the GRASS toolbox you need to open a
| |
− | {{Template:FileName|LOCATION}} and {{Template:FileName|MAPSET}} where you have write-permission
| |
− | (usually granted, if you created the {{Template:FileName|MAPSET}}). This is necessary,
| |
− | because new raster or vector layers created during analysis need to be written
| |
− | to the currently selected {{Template:FileName|LOCATION}} and {{Template:FileName|MAPSET}}.
| |
− |
| |
− | ==== Working with GRASS modules ====
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 32:''' GRASS Toolbox and searchable Modules List {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_modules'></span>
| |
− | <table align='center'><caption align='bottom'>(a) Modules Tree</caption><tr><td><span id='subfig:grass_module_tree'></span>[[File:grass_toolbox_moduletree.png|296px]]</td></tr></table>
| |
− | <table align='center'><caption align='bottom'>(b) Searchable Modules List</caption><tr><td><span id='subfig:grass_module_list'></span>[[File:grass_toolbox_modulelist.png|296px]]</td></tr></table>
| |
− | </td></tr></table>
| |
− |
| |
− | The GRASS Shell inside the GRASS Toolbox provides access to almost all (more
| |
− | than 300) GRASS modules in command line modus. To offer a more user
| |
− | friendly working environment, about 200 of the available GRASS modules and
| |
− | functionalities are also provided by graphical dialogs. These dialogs are
| |
− | grouped in thematic blocks, but are searchable as well. You find a complete
| |
− | list of GRASS modules available in QGIS version \CURRENT
| |
− | in appendix [[appdx_grass_toolbox_modules]]. It is also possible to
| |
− | customize the GRASS Toolbox content. It is described in Section
| |
− | [[sec:toolbox-customizing]].
| |
− |
| |
− | As shown in Figure [[#fig:grass_modules|32]], you can look for the appropriate
| |
− | GRASS module using the thematically grouped {{Template:Tab|Modules Tree}} or the
| |
− | searchable {{Template:Tab|Modules List}} tab.
| |
− |
| |
− | Clicking on a grapical module icon a new tab will be added to the toolbox
| |
− | dialog providing three new sub-tabs {{Template:Tab|Options}}, {{Template:Tab|Output}} and
| |
− | {{Template:Tab|Manual}}. In Figure [[#fig:grass_module_dialog|33]] you see an example
| |
− | for the GRASS module {{Template:FileName|v.buffer}}.
| |
− |
| |
− | <table align='center'>
| |
− | <caption>'''図 33:''' GRASS Toolbox Module Dialogs {{Template:Nix}}</caption>
| |
− | <tr><td><span id='fig:grass_module_dialog'></span>
| |
− | <table align='center'><caption align='bottom'>(a) Module Options</caption><tr><td><span id='subfig:grass_module_option'></span>[[File:grass_module_option.png|222px]]</td></tr></table>
| |
− | <table align='center'><caption align='bottom'>(b) Modules Output</caption><tr><td><span id='subfig:grass_module_output'></span>[[File:grass_module_output.png|222px]]</td></tr></table>
| |
− | <table align='center'><caption align='bottom'>(c) Module Manual</caption><tr><td><span id='subfig:grass_module_manual'></span>[[File:grass_module_manual.png|222px]]</td></tr></table>
| |
− | </td></tr></table>
| |
− |
| |
− | ===== Options =====
| |
− |
| |
− | The {{Template:Tab|Options}} tab provides a simplified module dialog where you can
| |
− | usually select a raster or vector layer visualized in the QGIS canvas and
| |
− | enter further module specific parameters to run the module. The provided
| |
− | module parameters are often not complete to keep the dialog clear. If you want
| |
− | to use further module parameters and flags, you need to start the GRASS Shell
| |
− | and run the module in the command line.
| |
− |
| |
− | ===== Output =====
| |
− |
| |
− | The {{Template:Tab|Output}} tab provides information about the output status of the
| |
− | module. When you click the {{Template:Button|Run}} button, the module switches to the
| |
− | {{Template:Tab|Output}} tab and you see information about the analysis process. If all
| |
− | works well, you will finally see a {{Template:UserText|Successfully finished}} message.
| |
− |
| |
− | ===== Manual =====
| |
− |
| |
− | The {{Template:Tab|Manual}} tab shows the HTML help page of the GRASS module. You can
| |
− | use it to check further module parameters and flags or to get a deeper
| |
− | knowledge about the purpose of the module. At the end of each module
| |
− | manual page you see further links to the {{Template:FileName|Main Help index}}, the
| |
− | {{Template:FileName|Thematic index}} and the {{Template:FileName|Full index}}. These links provide
| |
− | the same information as if you use the module {{Template:FileName|g.manual}}
| |
− |
| |
− | {{Template:Tip
| |
− | |num=40
| |
− | |caption=Display results immediately
| |
− | |qgistip=If you want to display your calculation results immediately in your
| |
− | map canvas, you can use the 'View Output' button at the bottom of the
| |
− | module tab.
| |
− |
| |
− | }}
| |
− |
| |
| ==== Working with the GRASS LOCATION browser ==== | | ==== Working with the GRASS LOCATION browser ==== |
| | | |
| Another useful feature inside the GRASS Toolbox is the GRASS | | Another useful feature inside the GRASS Toolbox is the GRASS |
− | {{Template:FileName|LOCATION}} browser. In Figure~[[fig:grass_mapset_browser]] you | + | {{Template:FileName|LOCATION}} browser. In Figure [[#fig:grass_mapset_browser|34]] you |
| can see the current working {{Template:FileName|LOCATION}} with its {{Template:FileName|MAPSETs}}. | | can see the current working {{Template:FileName|LOCATION}} with its {{Template:FileName|MAPSETs}}. |
| | | |
行595: |
行12: |
| | | |
| <table align='center'> | | <table align='center'> |
− | <caption>'''Figure xx:''' GRASS LOCATION browser {{Template:Nix</caption> | + | <caption>'''図 34:''' GRASS LOCATION browser {{Template:Nix}}</caption> |
− | <tr><td>}caption}<span id='fig:grass_mapset_browser'></span> | + | <tr><td><span id='fig:grass_mapset_browser'></span> |
| [[File:grass_mapset_browser.png|378px]]</td></tr></table> | | [[File:grass_mapset_browser.png|378px]]</td></tr></table> |
| | | |
行615: |
行32: |
| your currently selected {{Template:FileName|MAPSET}}. All other tools also work with | | your currently selected {{Template:FileName|MAPSET}}. All other tools also work with |
| raster and vector layers in another {{Template:FileName|MAPSET}}. | | raster and vector layers in another {{Template:FileName|MAPSET}}. |
− |
| |
− | ==== Customizing the GRASS Toolbox ====
| |
− | <span id='sec:toolbox-customizing'></span>
| |
− |
| |
− | Nearly all GRASS modules can be added to the GRASS toolbox. A XML
| |
− | interface is provided to parse the pretty simple XML files which configures
| |
− | the modules appearance and parameters inside the toolbox.
| |
− |
| |
− | A sample XML file for generating the module {{Template:UserText|v.buffer}} (v.buffer.qgm)
| |
− | looks like this:
| |
− | <pre>
| |
− | <?xml version="1.0" encoding="UTF-8"?>
| |
− | <!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
| |
− |
| |
− | <qgisgrassmodule label="Vector buffer" module="v.buffer">
| |
− | <option key="input" typeoption="type" layeroption="layer" />
| |
− | <option key="buffer"/>
| |
− | <option key="output" />
| |
− | </qgisgrassmodule>
| |
− | </pre>
| |
− |
| |
− | The parser reads this definition and creates a new tab inside the toolbox
| |
− | when you select the module. A more detailed description for adding new
| |
− | modules, changing the modules group, etc. can be found on the QGIS wiki at <br>
| |
− | {{Template:URL|http://wiki.qgis.org/qgiswiki/Adding_New_Tools_to_the_GRASS_Toolbox}}.
| |