「編集」の版間の差分

提供: OSGeo.JP Wiki
移動: 案内検索
(ページの作成: <H2> Editing </H2> <P> QGIS supports basic capabilities for editing vector geometries. Before reading any further you should note that at this stage editing support is still pr…)
 
(Working with the Attribute Table)
 
(2人の利用者による、間の6版が非表示)
行1: 行1:
<H2>
+
=== Editing ===
Editing
+
</H2>
+
  
<P>
 
 
QGIS supports basic capabilities for editing vector geometries.  Before reading any
 
QGIS supports basic capabilities for editing vector geometries.  Before reading any
 
further you should note that at this stage editing support is still preliminary.
 
further you should note that at this stage editing support is still preliminary.
行9: 行6:
 
to edit.  
 
to edit.  
  
<P>
+
'''Note''' - the procedure for editing GRASS layers is different - see
<SPAN  CLASS="textbf">Note</SPAN> - the procedure for editing GRASS layers is different - see
+
Section [[grass_digitising]] for details.
Section <A HREF="#grass_digitising"><IMG  ALIGN="BOTTOM" BORDER="1" ALT="[*]"
+
SRC="/usr/share/latex2html/icons/crossref.png"></A> for details.
+
  
<P>
+
==== Setting the Snapping Tolerance and Search Radius ====
<BR><HR>
+
<!--Table of Child-Links-->
+
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
+
  
<UL CLASS="ChildLinks">
+
Before we can edit vertices, it is very important to set the snapping
<LI><A NAME="tex2html432"
+
tolerance and search radius to a value that allows us an optimal editing of
  HREF="node24.html">Setting the Snapping Tolerance and Search Radius</A>
+
the vector layer geometries.
<LI><A NAME="tex2html433"
+
 
  HREF="node25.html">Topological editing</A>
+
===== Snapping tolerance =====
<LI><A NAME="tex2html434"
+
 
  HREF="node26.html">Editing an Existing Layer</A>
+
Snapping tolerance is the distance QGIS uses to {{Template:UserText|search}} for the
<LI><A NAME="tex2html435"
+
closest vertex and/or segment you are trying to
  HREF="node27.html">Creating a New Layer</A>
+
connect when you set a new vertex or move an existing vertex. If you aren't
<LI><A NAME="tex2html436"
+
within the snap tolerance, QGIS will leave the vertex where you release the
  HREF="node28.html">Working with the Attribute Table</A>
+
mouse button, instead of snapping it to an existing vertex and/or segment.
</UL>
+
 
<!--End of Table of Child-Links-->
+
<ol>
<BR><HR>
+
<li>A general, project wide snapping tolerance can be defined choosing
 +
{{Template:MainMenuOpt|Settings}} > {{Template:DropMenuOptTwo|mActionOptions|Options}}.  
 +
(On Mac: go to  {{Template:MainMenuOpt|QGIS}} > Preferences, on Linux: {{Template:MainMenuOpt|Edit}} > {{Template:DropMenuOptTwo|mActionOptions|Options}}.)
 +
In the {{Template:Tab|Digitizing}} tab you can select between to vertex, to segment or
 +
to vertex and segment as default snap mode. You can also define a default
 +
snapping tolerance and a search radius for vertex edits. The tolerance an be set either in map units or in pixels.
 +
In our digitizing project (working with the
 +
Alaska dataset), the units are in feet. Your results may vary, but something
 +
on the order of 300ft should be fine at a scale of 1:10 000 should be a
 +
reasonable setting.
 +
<li>A layer based snapping tolerance can be defined by choosing
 +
{{Template:MainMenuOpt|Settings}} (or {{Template:MainMenuOpt|File}}) > {{Template:DropMenuOptTwo|mActionOptions|Project
 +
Properties...}}. In the {{Template:Tab|General}} tab, section {{Template:ClassName|Digitize}} you
 +
can click on {{Template:Button|Snapping options...}} to enable and adjust snapping
 +
mode and tolerance on a layer basis (see Figure [[#fig:snappingoptions|13]]).
 +
</ol>
 +
 
 +
<table align='center'>
 +
<caption>'''図 13:''' Edit snapping options on a layer basis {{Template:Nix}}</caption>
 +
<tr><td><span id='fig:snappingoptions'></span>
 +
  [[File:editProjectSnapping.png|529px]]</td></tr></table>
 +
 
 +
===== Search radius =====
 +
 
 +
Search radius is the distance QGIS uses to {{Template:UserText|search}} for the closest
 +
vertex you are trying to move when you click on the
 +
map. If you aren't within the search radius, QGIS won't find and select
 +
any vertex for editing and it will pop up an annoying warning to that effect.
 +
Snap tolerance and search radius are set in map units or pixels, so you may find you
 +
need to experiment to get them set right. If you specify too big of a
 +
tolerance, QGIS may snap to the wrong vertex, especially if you are dealing
 +
with a large number of vertices in close proximity. Set search radius too
 +
small and it won't find anything to move.
 +
 
 +
The search radius for vertex edits in layer units can be defined in the
 +
{{Template:Tab|Digitizing}} tab under {{Template:MainMenuOpt|Settings}} >
 +
{{Template:DropMenuOptTwo|mActionOptions|Options}}. The same place where you define the
 +
general, project wide snapping tolerance.
 +
 
 +
==== Topological editing ====
 +
 
 +
Besides layer based snapping options the {{Template:Tab|General}} tab in menu
 +
{{Template:MainMenuOpt|Settings}} -> {{Template:DropMenuOptTwo|mActionOptions|Project Properties...}}
 +
also provides some topological functionalities.
 +
In the Digitizing option group you can {{Template:CheckBox|Enable topological editing}} and/or activate
 +
{{Template:CheckBox|Avoid intersections of new polygons}}.
 +
 
 +
===== Enable topological editing =====
 +
 
 +
The option {{Template:CheckBox|Enable topological editing}} is for editing and maintaining
 +
common boundaries in polygon mosaics. QGIS "detects" a shared boundary in
 +
a polygon mosaic and you only have to move the vertex once and QGIS will take
 +
care about updating the other boundary.
 +
 
 +
===== Avoid intersections of new polygons =====
 +
 
 +
The second topological option called {{Template:CheckBox|Avoid intersections of new polygons}}
 +
avoids overlaps in polygon mosaics. It is for quicker digitizing of adjacent polygons.
 +
If you already have one polygon, it is possible with this option to digitise the second
 +
one such that both intersect and qgis then cuts the second polygon to the common boundary.
 +
The advantage is that users don't have to digitize all vertices of the common boundary.
 +
 
 +
==== Editing an Existing Layer ====
 +
 
 +
 
 +
<span id='sec:edit_existing_layer'></span>
 +
 
 +
By default, QGIS loads layers read-only: This is a safeguard
 +
to avoid accidentally editing a layer if there is a slip of the mouse.
 +
However, you can choose to edit any layer as long as the data provider supports it,
 +
and the underlying data source is writable (i.e. its files are not read-only).
 +
 
 +
Layer editing is most versatile when used on PostgreSQL/PostGIS data sources.
 +
 
 +
{{Template:Tip
 +
|num=13
 +
|caption=Data Integrity
 +
|qgistip=It is always a good idea to back up your data source before you start
 +
editing. While the authors of QGIS have made every effort to preserve the
 +
integrity of your data, we offer no warranty in this regard.
 +
 
 +
}}
 +
 
 +
{{Template:Tip
 +
|num=14
 +
|caption=Manipulating Attribute data
 +
|qgistip=Currently only PostGIS layers are supported for adding or dropping attribute
 +
columns within this dialog. In future versions of QGIS, other datasources
 +
will be supported, because this feature was recently implemented in GDAL/OGR > 1.6.0
 +
 
 +
}}
 +
 
 +
 
 +
 
 +
{{Template:Tip
 +
|num=15
 +
|caption=Save Regularly
 +
|qgistip=Remember to toggle {{Template:ToolBtnTwo|mActionToggleEditing|Toggle editing}} off regularly. 
 +
This allows you to save your recent changes,
 +
and also confirms that your data source can accept all
 +
your changes.
 +
}}
 +
 
 +
{{Template:Tip
 +
|num=16
 +
|caption=Concurrent Edits
 +
|qgistip=This version of QGIS does not track if somebody else is editing a feature at the same time
 +
as you.  The last person to save their edits wins.
 +
 
 +
}}
 +
 
 +
{{Template:Tip
 +
|num=17
 +
|caption=Zoom in Before Editing
 +
|qgistip=Before editing a layer, you should
 +
zoom in to your area of interest. This
 +
avoids waiting while all the vertex markers are rendered across the entire layer.
 +
 
 +
}}
 +
 
 +
{{Template:Tip
 +
|num=18
 +
|caption=Vertex Markers
 +
|qgistip=
 +
The current version of QGIS supports two kinds of vertex-markers -
 +
a semi-transparent circle or a cross. To change the marker style, choose
 +
{{Template:DropMenuOptTwo|mActionOptions|Options}} from the
 +
{{Template:MainMenuOpt|Settings}} menu and click on the {{Template:Tab|Digitizing}} tab and select
 +
the appropriate entry.
 +
}}
 +
 
 +
All editing sessions start by choosing the {{Template:DropMenuOptTwo|mActionToggleEditing|Toggle editing}} option.
 +
This can be found in the context menu after right clicking on the legend
 +
entry for that layer.
 +
Alternately, you can use the
 +
{{Template:ToolBtnTwo|mActionToggleEditing|Toggle editing}} button from the toolbar to start
 +
or stop the editing mode. Once the layer is in edit mode,
 +
markers will appear at the vertices, and additional tool buttons on the editing
 +
toolbar will become available.
 +
 
 +
===== Zooming and panning with the mouse wheel =====
 +
 
 +
While digitizing you can press the mouse wheel to pan inside of the main
 +
window and you can roll the mouse wheel to zoom in and out on the map. For
 +
zooming place the mouse cursor inside the map area and roll it forward (away from you)
 +
to zoom in and backwards (towards you) to zoom out. The mouse cursor position will
 +
be the center of the zoomed area of interest. You can customize the behavior
 +
of the mouse wheel zoom using the {{Template:Tab|Map tools}} tab under the
 +
{{Template:MainMenuOpt|Settings}} >{{Template:DropMenuOpt|Options}} menu. 
 +
 
 +
===== Panning with the arrow keys =====
 +
 
 +
Panning the Map during digitizing is possible with the arrow keys. Place
 +
the mouse cursor inside the map area and click on the right arrow key to
 +
pan east, left arrow key to pan west, up arrow key to pan north and down arrow
 +
key to pan south.
 +
 
 +
You can also use the spacebar to temporarily cause mouse movements to pan
 +
then map. The PgUp and PgDown keys on your keyboard will cause the map
 +
display to zoom in or out without interrupting your digitising session.
 +
 
 +
You can perform the following editing functions:
 +
 
 +
<ul>
 +
<li>Add Features: {{Template:ToolBtnTwo|mActionCapturePoint|Capture Point}},
 +
  {{Template:ToolBtnTwo|mActionCaptureLine|Capture Line}} and
 +
  {{Template:ToolBtnTwo|mActionCapturePolygon|Capture Polygon}}
 +
<li>{{Template:ToolBtnTwo|mActionAddRing|Add Ring}}
 +
<li>{{Template:ToolBtnTwo|mActionAddIsland|Add Island}}
 +
<li>{{Template:ToolBtnTwo|mActionSplitFeatures|Split Features}}
 +
<li>{{Template:ToolBtnTwo|mActionMoveFeature|Move Features}}
 +
<li>{{Template:ToolBtnTwo|mActionMoveVertex|Move Vertex}}
 +
<li>{{Template:ToolBtnTwo|mActionAddVertex|Add Vertex}}
 +
<li>{{Template:ToolBtnTwo|mActionDeleteVertex|Delete Vertex}}
 +
<li>{{Template:ToolBtnTwo|mActionDeleteSelected|Delete Selected}}
 +
<li>{{Template:ToolBtnTwo|mActionEditCut|Cut Features}}
 +
<li>{{Template:ToolBtnTwo|mActionEditCopy|Copy Features}}
 +
<li>{{Template:ToolBtnTwo|mActionEditPaste|Paste Features}}
 +
</ul>
 +
 
 +
===== Adding Features =====
 +
 
 +
 
 +
Before you start adding features, use the {{Template:ToolBtnTwo|mActionPan|pan}}
 +
and {{Template:ToolBtnTwo|mActionZoomIn|zoom-in}}/{{Template:ToolBtnTwo|mActionZoomOut|zoom-out}}
 +
tools to first navigate to the area of interest.
 +
 
 +
Then you can use the {{Template:ToolBtnTwo|mActionCapturePoint|Capture point}},
 +
{{Template:ToolBtnTwo|mActionCaptureLine|Capture line}} or
 +
{{Template:ToolBtnTwo|mActionCapturePolygon|Capture polygon}} icons on the toolbar to put the QGIS cursor
 +
into digitizing mode.
 +
 
 +
For each feature, you first digitize the geometry, then enter its attributes.
 +
 
 +
To digitize the geometry, left-click on the map area to create the
 +
first point of your new feature.
 +
 
 +
For lines and polygons, keep on left-clicking for each additional
 +
point you wish to capture.  When you have finished adding points,
 +
right-click anywhere on the map area to confirm you have finished entering
 +
the geometry of that feature.
 +
 
 +
The attribute window will appear, allowing you to enter the information for the new feature.
 +
Figure [[fig:vector_digitising]] shows setting attributes for a fictitious
 +
new river in Alaska.
 +
 
 +
<table align='center'>
 +
<caption>'''図 14:''' Enter Attribute Values Dialog after digitizing a new vector
 +
  feature {{Template:Nix}}</caption>
 +
<tr><td><span id='fig:vector_digitising'></span>
 +
  [[File:editDigitizing.png|302px]]</td></tr></table>
 +
 
 +
{{Template:Tip
 +
|num=19
 +
|caption=Attribute Value Types
 +
|qgistip=
 +
At least for shapefile editing the attribue types are validated during the
 +
entry. Because of this, it is not possible to enter a number into the text-column in
 +
the dialog {{Template:Dialog|Enter Attribute Values}} or vica versa. If you need to do so,
 +
you should edit the attributes in a second step within the {{Template:Dialog|Attribute
 +
table}} dialog.
 +
}}
 +
 
 +
===== Move Feature =====
 +
 
 +
 
 +
You can move features using the {{Template:ToolBtnTwo|mActionMoveFeature|Move Feature}} icon
 +
on the toolbar.
 +
 
 +
===== Split Feature =====
 +
 
 +
 
 +
You can split features using the {{Template:ToolBtnTwo|mActionSplitFeatures|Split Features}} icon
 +
on the toolbar.
 +
 
 +
===== Editing Vertices of a Feature =====
 +
 
 +
 
 +
For both PostgreSQL/PostGIS and shapefile-based layers, the vertices of features can be edited.
 +
 
 +
Vertices can be directly edited, that is, you don't
 +
have to choose which feature to edit before you can change
 +
its geometry.
 +
In some cases, several features may share the same vertex
 +
and so the following rules apply when the mouse is pressed
 +
down near map features:
 +
 
 +
<ul>
 +
<li>'''Lines'''    - The nearest line to the mouse position
 +
                          is used as the target feature.
 +
                          Then (for moving and deleting a vertex)
 +
                          the nearest vertex
 +
                          on that line is the editing target.
 +
 
 +
<li>'''Polygons''' - If the mouse is inside a polygon, then it is
 +
                          the target feature; otherwise the nearest polygon
 +
                          is used.
 +
                          Then (for moving and deleting a vertex)
 +
                          the nearest vertex
 +
                          on that polygon is the editing target.
 +
</ul>
 +
 
 +
You will need to set the property
 +
{{Template:MainMenuOpt|Settings}}>{{Template:DropMenuOptTwo|mActionOptions|Options}}>{{Template:Tab|Digitizing}}>{{Template:SelectNumber|Search Radius|10}}
 +
to a number greater than zero.  Otherwise QGIS will not be able to tell which feature is being edited.
 +
 
 +
 
 +
===== Adding Vertices of a Feature =====
 +
 
 +
 
 +
You can add new vertices to a feature by using the
 +
{{Template:ToolBtnTwo|mActionAddVertex|Add Vertex}} icon
 +
on the toolbar.
 +
 
 +
Note, it doesn't make sense to add more vertices to a Point feature!
 +
 
 +
In this version of QGIS, vertices can only be added to an ''existing'' line
 +
segment of a line feature.  If you want to extend a line beyond its end,
 +
you will need to move the terminating vertex first, then add a new vertex where
 +
the terminus used to be.
 +
 
 +
===== Moving Vertices of a Feature =====
 +
 
 +
 
 +
You can move vertices using the {{Template:ToolBtnTwo|mActionMoveVertex|Move Vertex}} icon
 +
on the toolbar.
 +
 
 +
===== Deleting Vertices of a Feature =====
 +
 
 +
 
 +
You can delete vertices by using the {{Template:ToolBtnTwo|mActionDeleteVertex|Delete Vertex}} icon
 +
on the toolbar.
 +
 
 +
Note, it doesn't make sense to delete the vertex of a Point feature!
 +
Delete the whole feature instead.
 +
 
 +
Similarly, a one-vertex line or a two-vertex polygon is also
 +
fairly useless and will lead to unpredictable results elsewhere
 +
in QGIS, so don't do that.
 +
 
 +
'''Warning:''' A vertex is identified for deletion as
 +
soon as you click the mouse near an eligible
 +
feature.  To undo, you will need to toggle
 +
Editing off and then discard your changes.
 +
(Of course this will mean that other unsaved changes will be lost, too.)
 +
 
 +
===== Add Ring =====
 +
 
 +
 
 +
You can create ring polygons using the {{Template:ToolBtnTwo|mActionAddRing|Add Ring}}
 +
icon in the toolbar. This means inside an existing area it is
 +
possible to digitize further polygons, that will occur as a 'whole', so only
 +
the area in between the boundaries of the outer and inner polygons remain as
 +
a ring polygon.
 +
 
 +
===== Add Island =====
 +
 
 +
 
 +
You can {{Template:ToolBtnTwo|mActionAddIsland|add island}} polygons to a selected multipolygon.
 +
The new island polygon has to be digitized outside the selected multipolygon.
 +
 
 +
===== Cutting, Copying and Pasting Features =====
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Selected features can be cut, copied and pasted between layers in the
 +
same QGIS project, as long as destination layers are set to
 +
{{Template:ToolBtnTwo|mActionToggleEditing|Toggle editing}} beforehand.
 +
 
 +
Features can also be pasted to external applications as text:  That is,
 +
the features are represented in CSV format with the geometry data appearing
 +
in the OGC Well-Known Text (WKT) format.
 +
 
 +
 
 +
However in this version of QGIS, text features from outside QGIS cannot
 +
be pasted to a layer within QGIS. When would the copy and paste function
 +
come in handy? Well, it turns out that you can edit more than one layer
 +
at a time and copy/paste features between layers. Why would we want to do
 +
this?  Say we need to do some work on a new layer but only need one or
 +
two lakes, not the 5,000 on our {{Template:FileName|big_lakes}} layer. We can create
 +
a new layer and use copy/paste to plop the needed lakes into it.
 +
 
 +
As an example we are copying some lakes to a new layer:
 +
 
 +
<ol>
 +
<li>Load the layer you want to copy from (source layer)
 +
<li>Load or create the layer you want to copy to (target layer)
 +
<li>Start editing for target layer
 +
<li>Make the source layer active by clicking on it in the legend
 +
<li>Use the {{Template:ToolBtnTwo|mActionSelect|Select}} tool to select the feature(s) on the source layer
 +
<li>Click on the {{Template:ToolBtnTwo|mActionEditCopy|Copy Features}} tool
 +
<li>Make the destination layer active by clicking on it in the legend
 +
<li>Click on the {{Template:ToolBtnTwo|mActionEditPaste|Paste Features}} tool
 +
<li>Stop editing and save the changes
 +
</ol>
 +
 
 +
What happens if the source and target layers have
 +
different schemas (field names and types are not the same)? QGIS populates
 +
what matches and ignores the rest. If you don't care about the attributes
 +
being copied to the target layer, it doesn't matter how you design the
 +
fields and data types. If you want to make sure everything - feature and its
 +
attributes - gets copied, make sure the schemas match.
 +
 
 +
{{Template:Tip
 +
|num=xx
 +
|caption=Congruency of Pasted Features
 +
|qgistip=If your source and destination layers use the
 +
same projection, then the pasted features will have
 +
geometry identical to the source layer.
 +
However if the destination layer is a different projection
 +
then QGIS cannot guarantee the geometry is identical.
 +
This is simply because there are small rounding-off errors
 +
involved when converting between projections.
 +
 
 +
}}
 +
 
 +
===== Deleting Selected Features =====
 +
 
 +
 
 +
If we want to delete an entire polygon, we can do that by first selecting
 +
the polygon using the regular {{Template:ToolBtnTwo|mActionSelect|Select Features}} tool. You can select
 +
multiple features for deletion. Once you have the selection set, use the
 +
{{Template:ToolBtnTwo|mActionDeleteSelected|Delete Selected}} tool to delete the features. There is no undo function,
 +
but remember your layer isn't really changed until you stop editing and choose
 +
to save your changes. So if you make a mistake, you can always cancel the save.
 +
 
 +
The {{Template:ToolBtnTwo|mActionEditCut|Cut Features}} tool on the digitizing toolbar can
 +
also be used to delete features. This effectively deletes the feature but
 +
also places it on a "spatial clipboard". So we cut the feature to delete.
 +
We could then use the {{Template:ToolBtnTwo|mActionEditPaste|paste tool}} to put it back, giving us a one-level undo
 +
capability. Cut, copy, and paste work on the currently selected features,
 +
meaning we can operate on more than one at a time.
 +
 
 +
{{Template:Tip
 +
|num=xx
 +
|caption=Feature Deletion Support
 +
|qgistip=When editing ESRI shapefiles, the deletion
 +
of features only works if QGIS is linked to a GDAL version 1.3.2 or greater.
 +
The OS X and Windows versions of QGIS available from the download site are built
 +
using GDAL 1.3.2 or higher.
 +
 
 +
}}
 +
 
 +
===== Snap Mode =====
 +
 
 +
QGIS allows digitized vertices to be snapped to other vertices of the same layer. To
 +
set the snapping tolerance, go to
 +
{{Template:MainMenuOpt|Settings}}>{{Template:DropMenuOptTwo|mActionOptions|Options}}->{{Template:Tab|Digitizing}}.
 +
(On Mac: go to  {{Template:MainMenuOpt|QGIS}} > Preferences, on Linux: {{Template:MainMenuOpt|Edit}} > {{Template:DropMenuOptTwo|mActionOptions|Options}}.)
 +
Note that the snapping tolerance is in map units or pixels.
 +
 
 +
===== Saving Edited Layers =====
 +
 
 +
 
 +
When a layer is in editing mode, any changes remain in the memory of QGIS.
 +
Therefore they are not committed/saved immediately to the data source or disk.
 +
When you turn editing mode off (or quit QGIS for that matter),
 +
you are then asked if you want to save your
 +
changes or discard them.
 +
 
 +
If the changes cannot be saved (e.g. disk full, or the attributes have
 +
values that are out of range), the QGIS in-memory state is preserved.  This
 +
allows you to adjust your edits and try again.
 +
 
 +
==== Creating a New Layer ====
 +
<span id='sec:create shape'></span>
 +
To create a new layer for editing, choose {{Template:ToolBtnTwo|mActionNewVectorLayer|New Vector Layer}} from the
 +
{{Template:MainMenuOpt|Layer}} menu.
 +
The {{Template:Dialog|New Vector Layer}} dialog will be displayed as
 +
shown in Figure [[#fig:newvectorlayer|15]]. Choose the type of layer (point,
 +
line or polygon).
 +
 
 +
<table align='center'>
 +
<caption>'''図 15:''' Creating a New Vector Dialog {{Template:Nix}}</caption>
 +
<tr><td><span id='fig:newvectorlayer'></span>
 +
  [[File:editNewVector.png|378px]]</td></tr></table>
 +
 
 +
Note that QGIS does not yet support creation of 2.5D
 +
features (i.e. features with X,Y,Z coordinates) or measure features. At this
 +
time, only shapefiles can be created. In a future version of QGIS, creation of
 +
any OGR or PostgreSQL layer type will be supported.
 +
 
 +
Creation of GRASS-layers is supported within the GRASS-plugin. Please refer to section
 +
[[sec:creating_new_grass_vectors]] for more information on creating GRASS vector
 +
layers.
 +
 
 +
To complete the creation of the new layer, add the desired attributes by
 +
clicking on the {{Template:Button|Add}} button and specifying a name and type for the
 +
attribute. Only {{Template:SelectString|Type|real}}, {{Template:SelectString|Type|integer}}, and {{Template:SelectString|Type|string}} attributes are supported. Once you
 +
are happy with the attributes, click {{Template:Button|OK}} and provide a name for the shapefile.
 +
QGIS will automatically add a {{Template:FileName|.shp}} extension to the name you specify.  Once
 +
the layer has been created, it will be added to the map and you can edit it in
 +
the same way as described in Section [[sec:edit_existing_layer]] above.
 +
 
 +
==== Working with the Attribute Table ====
 +
<span id='sec:attribute table'></span>
 +
To open the attribute table for a vector layer, make the layer active by clicking on it in the Map legend area.
 +
Then use {{Template:MainMenuOpt|Layer}} Layer from the main menu and and choose {{Template:DropMenuOptTwo|mActionOpenTable|Open Attribute Table}}
 +
from the menu. It is also possible to rightlick on the layer and choose {{Template:DropMenuOptTwo|mActionOpenTable|Open Attribute Table}}
 +
from the dropdown menu. This will open a new window which displays the attributes for every feature in the layer
 +
(figure [[#fig:attributetable|16]]).
 +
 
 +
<table align='center'>
 +
<caption>'''図 16:''' Attribute Table for Alaska layer {{Template:Nix}}</caption>
 +
<tr><td><span id='fig:attributetable'></span>
 +
  [[File:vectorAttributeTable.png|454px]]</td></tr></table>
 +
 
 +
Each column can be sorted by clicking on its header. A small arrow indicates the sort
 +
order (downward pointing means descending values from the top row down, upward pointing means
 +
ascending values from the top rown down).
 +
For a simple selection by attributes on only one column the {{Template:Button|Look for}} field
 +
can be used. Select the field (column) from which the search should be performed from
 +
the dropdown menu and hit the {{Template:Button|Search}} button. For more complex searches use the
 +
Advanced search {{Template:Button|...}}, which will lauch the Search Query Builder described in
 +
Section [[sec:select_by_query]].
 +
 
 +
To show selected records only, use the checkbox {{Template:CheckBox|Show selected records only}}.
 +
Using the buttons at the bottom left of the window, selected fields can be removed,
 +
moved to the top of the table, or the selection can be inverted. Selected features can
 +
also be copied to the clipboard, which can also be done with {{Template:KeyStroke|Ctrl-C}}. You can also zoom
 +
into the selected features on the map. Toggle editing allows to edit single values of attributes.

2009年10月4日 (日) 19:26時点における最新版

Editing

QGIS supports basic capabilities for editing vector geometries. Before reading any further you should note that at this stage editing support is still preliminary. Before performing any edits, always make a backup of the dataset you are about to edit.

Note - the procedure for editing GRASS layers is different - see Section grass_digitising for details.

Setting the Snapping Tolerance and Search Radius

Before we can edit vertices, it is very important to set the snapping tolerance and search radius to a value that allows us an optimal editing of the vector layer geometries.

Snapping tolerance

Snapping tolerance is the distance QGIS uses to search for the closest vertex and/or segment you are trying to connect when you set a new vertex or move an existing vertex. If you aren't within the snap tolerance, QGIS will leave the vertex where you release the mouse button, instead of snapping it to an existing vertex and/or segment.

  1. A general, project wide snapping tolerance can be defined choosing Settings > MActionOptions.png Options. (On Mac: go to QGIS > Preferences, on Linux: Edit > MActionOptions.png Options.) In the Digitizing tab you can select between to vertex, to segment or to vertex and segment as default snap mode. You can also define a default snapping tolerance and a search radius for vertex edits. The tolerance an be set either in map units or in pixels. In our digitizing project (working with the Alaska dataset), the units are in feet. Your results may vary, but something on the order of 300ft should be fine at a scale of 1:10 000 should be a reasonable setting.
  2. A layer based snapping tolerance can be defined by choosing Settings (or File) > MActionOptions.png Project Properties.... In the General tab, section Digitize you can click on Snapping options... to enable and adjust snapping mode and tolerance on a layer basis (see Figure 13).
図 13: Edit snapping options on a layer basis Nix.png
EditProjectSnapping.png
Search radius

Search radius is the distance QGIS uses to search for the closest vertex you are trying to move when you click on the map. If you aren't within the search radius, QGIS won't find and select any vertex for editing and it will pop up an annoying warning to that effect. Snap tolerance and search radius are set in map units or pixels, so you may find you need to experiment to get them set right. If you specify too big of a tolerance, QGIS may snap to the wrong vertex, especially if you are dealing with a large number of vertices in close proximity. Set search radius too small and it won't find anything to move.

The search radius for vertex edits in layer units can be defined in the Digitizing tab under Settings > MActionOptions.png Options. The same place where you define the general, project wide snapping tolerance.

Topological editing

Besides layer based snapping options the General tab in menu Settings -> MActionOptions.png Project Properties... also provides some topological functionalities. In the Digitizing option group you can CheckBox.pngEnable topological editing and/or activate CheckBox.pngAvoid intersections of new polygons.

Enable topological editing

The option CheckBox.pngEnable topological editing is for editing and maintaining common boundaries in polygon mosaics. QGIS "detects" a shared boundary in a polygon mosaic and you only have to move the vertex once and QGIS will take care about updating the other boundary.

Avoid intersections of new polygons

The second topological option called CheckBox.pngAvoid intersections of new polygons avoids overlaps in polygon mosaics. It is for quicker digitizing of adjacent polygons. If you already have one polygon, it is possible with this option to digitise the second one such that both intersect and qgis then cuts the second polygon to the common boundary. The advantage is that users don't have to digitize all vertices of the common boundary.

Editing an Existing Layer

By default, QGIS loads layers read-only: This is a safeguard to avoid accidentally editing a layer if there is a slip of the mouse. However, you can choose to edit any layer as long as the data provider supports it, and the underlying data source is writable (i.e. its files are not read-only).

Layer editing is most versatile when used on PostgreSQL/PostGIS data sources.


Tip 13 Data Integrity


It is always a good idea to back up your data source before you start editing. While the authors of QGIS have made every effort to preserve the integrity of your data, we offer no warranty in this regard.




Tip 14 Manipulating Attribute data


Currently only PostGIS layers are supported for adding or dropping attribute columns within this dialog. In future versions of QGIS, other datasources will be supported, because this feature was recently implemented in GDAL/OGR > 1.6.0





Tip 15 Save Regularly


Remember to toggle MActionToggleEditing.png Toggle editing off regularly. This allows you to save your recent changes, and also confirms that your data source can accept all your changes.




Tip 16 Concurrent Edits


This version of QGIS does not track if somebody else is editing a feature at the same time as you. The last person to save their edits wins.




Tip 17 Zoom in Before Editing


Before editing a layer, you should zoom in to your area of interest. This avoids waiting while all the vertex markers are rendered across the entire layer.




Tip 18 Vertex Markers


The current version of QGIS supports two kinds of vertex-markers - a semi-transparent circle or a cross. To change the marker style, choose MActionOptions.png Options from the Settings menu and click on the Digitizing tab and select the appropriate entry.



All editing sessions start by choosing the MActionToggleEditing.png Toggle editing option. This can be found in the context menu after right clicking on the legend entry for that layer. Alternately, you can use the MActionToggleEditing.png Toggle editing button from the toolbar to start or stop the editing mode. Once the layer is in edit mode, markers will appear at the vertices, and additional tool buttons on the editing toolbar will become available.

Zooming and panning with the mouse wheel

While digitizing you can press the mouse wheel to pan inside of the main window and you can roll the mouse wheel to zoom in and out on the map. For zooming place the mouse cursor inside the map area and roll it forward (away from you) to zoom in and backwards (towards you) to zoom out. The mouse cursor position will be the center of the zoomed area of interest. You can customize the behavior of the mouse wheel zoom using the Map tools tab under the Settings >Options menu.

Panning with the arrow keys

Panning the Map during digitizing is possible with the arrow keys. Place the mouse cursor inside the map area and click on the right arrow key to pan east, left arrow key to pan west, up arrow key to pan north and down arrow key to pan south.

You can also use the spacebar to temporarily cause mouse movements to pan then map. The PgUp and PgDown keys on your keyboard will cause the map display to zoom in or out without interrupting your digitising session.

You can perform the following editing functions:

  • Add Features: MActionCapturePoint.png Capture Point, MActionCaptureLine.png Capture Line and MActionCapturePolygon.png Capture Polygon
  • MActionAddRing.png Add Ring
  • MActionAddIsland.png Add Island
  • MActionSplitFeatures.png Split Features
  • MActionMoveFeature.png Move Features
  • MActionMoveVertex.png Move Vertex
  • MActionAddVertex.png Add Vertex
  • MActionDeleteVertex.png Delete Vertex
  • MActionDeleteSelected.png Delete Selected
  • MActionEditCut.png Cut Features
  • MActionEditCopy.png Copy Features
  • MActionEditPaste.png Paste Features
Adding Features

Before you start adding features, use the MActionPan.png pan and MActionZoomIn.png zoom-in/MActionZoomOut.png zoom-out tools to first navigate to the area of interest.

Then you can use the MActionCapturePoint.png Capture point, MActionCaptureLine.png Capture line or MActionCapturePolygon.png Capture polygon icons on the toolbar to put the QGIS cursor into digitizing mode.

For each feature, you first digitize the geometry, then enter its attributes.

To digitize the geometry, left-click on the map area to create the first point of your new feature.

For lines and polygons, keep on left-clicking for each additional point you wish to capture. When you have finished adding points, right-click anywhere on the map area to confirm you have finished entering the geometry of that feature.

The attribute window will appear, allowing you to enter the information for the new feature. Figure fig:vector_digitising shows setting attributes for a fictitious new river in Alaska.

図 14: Enter Attribute Values Dialog after digitizing a new vector feature Nix.png
EditDigitizing.png

Tip 19 Attribute Value Types


At least for shapefile editing the attribue types are validated during the entry. Because of this, it is not possible to enter a number into the text-column in the dialog Enter Attribute Values or vica versa. If you need to do so, you should edit the attributes in a second step within the Attribute table dialog.



Move Feature

You can move features using the MActionMoveFeature.png Move Feature icon on the toolbar.

Split Feature

You can split features using the MActionSplitFeatures.png Split Features icon on the toolbar.

Editing Vertices of a Feature

For both PostgreSQL/PostGIS and shapefile-based layers, the vertices of features can be edited.

Vertices can be directly edited, that is, you don't have to choose which feature to edit before you can change its geometry. In some cases, several features may share the same vertex and so the following rules apply when the mouse is pressed down near map features:

  • Lines - The nearest line to the mouse position is used as the target feature. Then (for moving and deleting a vertex) the nearest vertex on that line is the editing target.
  • Polygons - If the mouse is inside a polygon, then it is the target feature; otherwise the nearest polygon is used. Then (for moving and deleting a vertex) the nearest vertex on that polygon is the editing target.

You will need to set the property Settings>MActionOptions.png Options>Digitizing>Search Radius10SelectNumber.png to a number greater than zero. Otherwise QGIS will not be able to tell which feature is being edited.


Adding Vertices of a Feature

You can add new vertices to a feature by using the MActionAddVertex.png Add Vertex icon on the toolbar.

Note, it doesn't make sense to add more vertices to a Point feature!

In this version of QGIS, vertices can only be added to an existing line segment of a line feature. If you want to extend a line beyond its end, you will need to move the terminating vertex first, then add a new vertex where the terminus used to be.

Moving Vertices of a Feature

You can move vertices using the MActionMoveVertex.png Move Vertex icon on the toolbar.

Deleting Vertices of a Feature

You can delete vertices by using the MActionDeleteVertex.png Delete Vertex icon on the toolbar.

Note, it doesn't make sense to delete the vertex of a Point feature! Delete the whole feature instead.

Similarly, a one-vertex line or a two-vertex polygon is also fairly useless and will lead to unpredictable results elsewhere in QGIS, so don't do that.

Warning: A vertex is identified for deletion as soon as you click the mouse near an eligible feature. To undo, you will need to toggle Editing off and then discard your changes. (Of course this will mean that other unsaved changes will be lost, too.)

Add Ring

You can create ring polygons using the MActionAddRing.png Add Ring icon in the toolbar. This means inside an existing area it is possible to digitize further polygons, that will occur as a 'whole', so only the area in between the boundaries of the outer and inner polygons remain as a ring polygon.

Add Island

You can MActionAddIsland.png add island polygons to a selected multipolygon. The new island polygon has to be digitized outside the selected multipolygon.

Cutting, Copying and Pasting Features

Selected features can be cut, copied and pasted between layers in the same QGIS project, as long as destination layers are set to MActionToggleEditing.png Toggle editing beforehand.

Features can also be pasted to external applications as text: That is, the features are represented in CSV format with the geometry data appearing in the OGC Well-Known Text (WKT) format.


However in this version of QGIS, text features from outside QGIS cannot be pasted to a layer within QGIS. When would the copy and paste function come in handy? Well, it turns out that you can edit more than one layer at a time and copy/paste features between layers. Why would we want to do this? Say we need to do some work on a new layer but only need one or two lakes, not the 5,000 on our big_lakes layer. We can create a new layer and use copy/paste to plop the needed lakes into it.

As an example we are copying some lakes to a new layer:

  1. Load the layer you want to copy from (source layer)
  2. Load or create the layer you want to copy to (target layer)
  3. Start editing for target layer
  4. Make the source layer active by clicking on it in the legend
  5. Use the MActionSelect.png Select tool to select the feature(s) on the source layer
  6. Click on the MActionEditCopy.png Copy Features tool
  7. Make the destination layer active by clicking on it in the legend
  8. Click on the MActionEditPaste.png Paste Features tool
  9. Stop editing and save the changes

What happens if the source and target layers have different schemas (field names and types are not the same)? QGIS populates what matches and ignores the rest. If you don't care about the attributes being copied to the target layer, it doesn't matter how you design the fields and data types. If you want to make sure everything - feature and its attributes - gets copied, make sure the schemas match.


Tip xx Congruency of Pasted Features


If your source and destination layers use the same projection, then the pasted features will have geometry identical to the source layer. However if the destination layer is a different projection then QGIS cannot guarantee the geometry is identical. This is simply because there are small rounding-off errors involved when converting between projections.



Deleting Selected Features

If we want to delete an entire polygon, we can do that by first selecting the polygon using the regular MActionSelect.png Select Features tool. You can select multiple features for deletion. Once you have the selection set, use the MActionDeleteSelected.png Delete Selected tool to delete the features. There is no undo function, but remember your layer isn't really changed until you stop editing and choose to save your changes. So if you make a mistake, you can always cancel the save.

The MActionEditCut.png Cut Features tool on the digitizing toolbar can also be used to delete features. This effectively deletes the feature but also places it on a "spatial clipboard". So we cut the feature to delete. We could then use the MActionEditPaste.png paste tool to put it back, giving us a one-level undo capability. Cut, copy, and paste work on the currently selected features, meaning we can operate on more than one at a time.


Tip xx Feature Deletion Support


When editing ESRI shapefiles, the deletion of features only works if QGIS is linked to a GDAL version 1.3.2 or greater. The OS X and Windows versions of QGIS available from the download site are built using GDAL 1.3.2 or higher.



Snap Mode

QGIS allows digitized vertices to be snapped to other vertices of the same layer. To set the snapping tolerance, go to Settings>MActionOptions.png Options->Digitizing. (On Mac: go to QGIS > Preferences, on Linux: Edit > MActionOptions.png Options.) Note that the snapping tolerance is in map units or pixels.

Saving Edited Layers

When a layer is in editing mode, any changes remain in the memory of QGIS. Therefore they are not committed/saved immediately to the data source or disk. When you turn editing mode off (or quit QGIS for that matter), you are then asked if you want to save your changes or discard them.

If the changes cannot be saved (e.g. disk full, or the attributes have values that are out of range), the QGIS in-memory state is preserved. This allows you to adjust your edits and try again.

Creating a New Layer

To create a new layer for editing, choose MActionNewVectorLayer.png New Vector Layer from the Layer menu. The New Vector Layer dialog will be displayed as shown in Figure 15. Choose the type of layer (point, line or polygon).

図 15: Creating a New Vector Dialog Nix.png
EditNewVector.png

Note that QGIS does not yet support creation of 2.5D features (i.e. features with X,Y,Z coordinates) or measure features. At this time, only shapefiles can be created. In a future version of QGIS, creation of any OGR or PostgreSQL layer type will be supported.

Creation of GRASS-layers is supported within the GRASS-plugin. Please refer to section sec:creating_new_grass_vectors for more information on creating GRASS vector layers.

To complete the creation of the new layer, add the desired attributes by clicking on the Add button and specifying a name and type for the attribute. Only Type real SelectString.png, Type integer SelectString.png, and Type string SelectString.png attributes are supported. Once you are happy with the attributes, click OK and provide a name for the shapefile. QGIS will automatically add a .shp extension to the name you specify. Once the layer has been created, it will be added to the map and you can edit it in the same way as described in Section sec:edit_existing_layer above.

Working with the Attribute Table

To open the attribute table for a vector layer, make the layer active by clicking on it in the Map legend area. Then use Layer Layer from the main menu and and choose MActionOpenTable.png Open Attribute Table from the menu. It is also possible to rightlick on the layer and choose MActionOpenTable.png Open Attribute Table from the dropdown menu. This will open a new window which displays the attributes for every feature in the layer (figure 16).

図 16: Attribute Table for Alaska layer Nix.png
VectorAttributeTable.png

Each column can be sorted by clicking on its header. A small arrow indicates the sort order (downward pointing means descending values from the top row down, upward pointing means ascending values from the top rown down). For a simple selection by attributes on only one column the Look for field can be used. Select the field (column) from which the search should be performed from the dropdown menu and hit the Search button. For more complex searches use the Advanced search ..., which will lauch the Search Query Builder described in Section sec:select_by_query.

To show selected records only, use the checkbox CheckBox.pngShow selected records only. Using the buttons at the bottom left of the window, selected fields can be removed, moved to the top of the table, or the selection can be inverted. Selected features can also be copied to the clipboard, which can also be done with Ctrl-C. You can also zoom into the selected features on the map. Toggle editing allows to edit single values of attributes.