BC Consulting

Home

bccshpv  Shapefile Structure Viewer and Editor
V0.1.4 - 27 December 2011

This QGIS plugin, bccshpv, is used to view the geometry data and attributes of shapefiles (points, polylines and polygons). It also allows editing the geometry data and the attributes data. Thus it is a potentially very dangerous plugin (it is not bug free: some unreported bugs could lurk around and be dangerous to your data! Furthermore, limited testing has been done on the new features added since version 0.0.2). The plugin is not suitable for large shapefiles with thousands of geometry points.

This plugin will only fully work on QGIS 1.5 to 1.8.
It will NOT work on QGIS 2.0 and above.  

Please read all sections before using the plugin.
Using this plugin you are the mechanics, not the driver!

Once installed the bccshpv plugin can be found in the 'Vector/Shapefiles ' menu.

Before launching the plugin, you can select features in the shapefile (from V0.0.3). The plugin will then ask if you want to work with those selected features or work with the entire content of the shapefile.
There is one very important caevat when working with selected features, see here.

 

You use this plugin entirely at your own risk

bccshpv is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It is distributed under the GNU General Public License. Read the GPL licence here.
 


bccshpv - main window
V0.0.3 interface


--- How to use this plugin ---

As a shapefile geometry viewer:

  1. Select a shapefile layer in the QGIS legend.
  2. Open the plugin: Plugins -> ShapeFiles -> Shapefile Viewer
  3. The plugin window will then display the geometry and attributes data of the selected layer. See image above.
  4. You can select cells and copy them to the clipboard.
  5. When inspection is done, close plugin.

As a shapefile editor (Please see tutorial below):

  1. Select a shapefile layer in the QGIS legend.
  2. Open the plugin: Plugins -> ShapeFiles -> Shapefile Viewer
  3. The plugin window will then display the geometry and attributes data of the selected layer. See tutorial.
  4. Click the edit button.
  5. Modify the features you need. Be aware that you do modify the geometry and attributes of the shapefile at your own risk!
  6. When you are finished editing the shapefile, click the edit button again to end editing. At this stage no commit is done to the file, so you can close and all edits will be lost.
  7. If you are really sure your edits are valid you then click on the save button and your edits are commited to the shapefile with no possibilities whatsoever of undo.

Please note that shapefiles with thousands of geometry points will take a very long time to load, if at all!

Please report any bug/problem/wish to the QGIS User mailing list [mailto: qgis - user at lists dot osgeo dot org].


Guided tour (Version 0.0.3)

How to use

New 0.0.4 toolbar
V0.0.4 toolbar: note the addition of the "Save as..." button and the Save as... dialog below (V0.0.6):

Save as dialog

Click "Choose a file to save to..." button to select a shapefile name.

What to save: entire table (all the content of the data displayed in the plugin) or only the selected rows in the table (only those selected rows will be saved. So if you've partially selected a feature it will most probably mess up the saved shapefile!)

Change type to: If you've done the right modifications on the table data you can try to change the type of the shapefile. You could promote a point layer to a line or polygon shapefile if you've done the correct editing. Similarly you could denote a line layer to a point shapefile or promote it to a polygon shapefile. Same with a polygon layer. BUT REMEMBER: you first have to do the correct editing yourself!!!

Click Save to save the data or Cancel to dismiss the dialog

By default all the attributes in the table are selected. Use the shift and control keys to select the attributes you want saved.


Download

Please read the section below and look at the section above before downloading.

Usage of this plugin can be dangerous for your data.

You use it entirely at your own risk.

bccshpv is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Download bccshpv

See here instructions on how to install QGIS plugins manually.

This plugin is also available in the QGIS user contributed repository.
It carries an Experimental flag and is only recommended for QGIS 1.5 and above.


Tutorial

This tutorial is based on version 0.0.1 of the plugin. See sections below for more recent editing capabilities.

The following is a brief introduction on how to use the plugin to create shapefile by keying coordinates values. If you want to create a shapefile by clicking points please see the QGIS User Manual.

The first step is to create the physical shapefile on disk. To do that we will use QGIS 'New shapefile layer' (new shapefile layer). Please refer to QGIS 1.5.0 User Manual, section 3.5.5 page 63, for information on how to do that. It is outside of the scope of this tutorial.

Now you have created the shapefile with the correct geometry (point or line or polygon). We will see how to edit the three types below.

Let's start by editing a point shapefile.

To edit a line or polygon shapefile, the same procedure detailed above needs to be followed.

For a line shapefile the following warning is issued when the edit button is clicked:

line edit warning

And for a polygon shapefile the following warning is issued:

line edit warning

Please take note of those warnings! You will damage and render your shapefile unusable if you don't respect those constraints.

Below are examples of a line shapefile (having two lines), left, and a polygon shapefile with one polygon having one ring, right.

line edit warning line edit warning
Note the ellipsis (...) to mark the first point of the ring -->  

Putting the three shapefiles together gives (don't look for any meaning, they are just dumb examples):

end result

Please note that multipolygons and multipoints are not dealt with by the plugin.

Be prudent and enjoy!


Editing shapefiles

Version 0.0.3 provides more editing functions than the previous versions (see also guided tour):

Editing funcitons

In editing mode you can now:

Before using those functions please read the following :


Tips and tricks


Selection of features
Only applies to Moving (XY-offset), and to moving along display stack actions

If you want to apply an offset to only one row of a feature (line or polygon) you cannot use the Move button. In that case, simply type in the new coords in the grid. This is because if only one point in a line/polygon feature is selected when the offsets are given the entire feature is selected first and the offset applied to the entire feature.


History

  • 0.1.4:
    • Move plugin to the Vector menu.
  • 0.1.3:
    • Add a "Close" button at Richard Martin-Nielsen's request. On Mac OS there is no close icon in the title bar, so a Close button is necessary to exit the plugin window.
  • 0.1.2:
    • Corrected two other bugs reported by Alister Hood:
      • Problems with some characters (convert str() to unicode() calls)
      • Correct bug when copying an empty selection to clipboard
    • Changed the menu name from "ShapeFiles" to "Vector"
  • 0.1.1: Corrected bug reported by Alister Hood: 'copy to clipboard could not handle some characters'.
  • 0.1.0: As follows:
    • Fixed bug when saving multi-parts polylines: all the parts were saved as one line!
    • Set row height to a smaller size than the default (see Point 2 of V0.0.3 below)
    • Allow changing the type of the shapefile, see image below, when using 'Save as...'. That one can be a real killer, because if you do not correctly arrange the shapefile geometry before changing its style and saving, the resulting shapefile will most certainly be invalid!
      Accept working with selected features
  • 0.0.5: Add safeguards in the import of a shapefile and correctly ignore multipart points and polygons and bad multipart lines.
     
  • 0.0.4: Try to implement Joe's suggestions:
 1. Edit columns- both add and remove them as I see fit.
 -> For that you can use the Table Manager plugin. Unfortunately I do not plan
    to duplicate it with the shapefile viewer plugin because I do not want the
    plugin to fiddle with the structure of a shapefile, only with its data.

 2. Edit rows- as above.
 -> Added in V0.0.3.

 3. "Save selection as" Really practical command. Out of my 1,000 points I
    would love to transfer say 50x to a new shapefile layer.
 -> Done: there is a new "Save as..." button (Save as). When clicked it
    displays a dialog where you have to give the name of a shapefile.
    Accept working with selected features
    Optionally you can select to save the current selection in the table or
    the entire table. Note that here, selection means the rows selected in the
    table, not the features selected before launching the plugin. This also
    means that you have to select entire features (line or polygon) yourself
    otherwise the resulting shapefile will be a mess!
    A second option let you select the fields (columns in the table) you want
    to save to the new shapefile. By default all fields are selected.
    You can use shift-click and control-click to alter the selection of the fields.
    Accept working with selected features
    Optionally you can select to save the current selection in the table or
    the entire table. Note that here, selection means the rows selected in the
    table, not the features selected before launching the plugin. This also
    means that you have to select entire features (line or polygon) yourself
    otherwise the resulting shapefile will be a mess!
    A second option let you select the fields (columns in the table) you want
    to save to the new shapefile. By default all fields are selected.
    You can use shift-click and control-click to alter the selection of the fields.
  • 0.0.3: Try to implement Maxim's suggestions and some more:
 1. Please consider working (or showing) only selected feature(s).
    It is not of much use if there are many polygons with many vertexes, you
    have to scroll up&down a lot to find needed feature. I can still see that
    seeing everythig is useful when you're working with empty layer (adding
    features), but a switch 'show only selected feature(s)' would these
    both suggestions.
 -> Done. See important remarks at point 6 below.
    The following warning is shown when working with a selection:
    Accept working with selected features
    Clicking 'Yes' will only import the selected feature(s) into the plugin.
    Clicking 'No' will try to import all the features of the layer into the plugin.

 2. Is it possible to shrink row height? May be its Windows, but mine
    are extra inflated occupying valuable space. Check this screenshot [1]
   (first two rows I shrank manually)
 -> I need a PyQt guru to show me how to do that!

 3. It would be really nice if node selected in the table would
    highlight in map canvas, thus allowing us to track were are they exactly.
 -> Done for vertices. On a point layer the selected point is highlighted in
    red. On line/polygon layers, the current point of the feature is in red
    and all the other points of the feature are in blue.

 4. I think 'close' button and little graphic on the left are
    unnecessary. I'd add current layer name and its type right in the window
    title.
 -> The icon of the dialog shows the type of shapefile loaded. Shapefile name
    is added to the title bar with the numbere of (selected) features.

 5. It would be nice to able to delete a node(s) as well.
 -> Done, use at own risks, no undo, no checking...

 6. Please consider moving 'start|stop editing' functionality to QGIS
    itself, so that you'd have to start and stop editing in QGIS, I think
    it will be more straightforward.
 -> Not possible in the current implementation: the edited shapefile *IS* the
    table and the table *IS* the shapefile. There is a total disconnection
    between the table and the shapefile. So any edit on the table are lost if
    user does not save them in the plugin. This allows for a bit of safety.

    IMPORTANT remarks:
      - If some features are selected in QGIS and the plugin is called, you
        will be asked if you want to work with that selection only or work
        with the entire file.
        If you choose to work with the selection, the important point below
        must be taken into consideration:
           - Even if you do no editing but simply enter edit mode, exit edit
             mode and save, then the selected features will be put on top of
             the display stack: the order of the features is modified in the
             shapefile!
      - Any edit will thus result in a change of ID numbering. QGIS displays
        the features in a shapefile by increasing ID number.
      - You better not change the ID column in the plugin because your changes
        will be lost when you save! The plugin changes the ID of the features
        before saving to the shapefile. It is done for consistency and all
        user's changes are lost.


Some extras:
-----------

 7. Added possibility to promote, demote a feature relative to the other
    features in the shapefile: a shapefile is drawn to the canvas by drawing
    the first feature in the file first and the last feature last.
    So by changing the order features are saved in the file the drawing order
    can be controlled and a feature can be placed on top or below others!
 -> For points:
       Select the point(s) you want to move and click one of the four arrow
       buttons (move at bottom, move below previous, move above next and move
       at top).
 -> For lines and polygons:
       1) Put the current cell inside a feature and click one of the four
          arrow buttons. This will move the entire feature.
       2) Select ENTIRE features and click one of the four arrows to move them
          at once. (This method will only move the selection, so if a feature
          is not entirely selected you will mess up your shapefile! Use it at
          your own risk).

 8. Added offsets: you can move a single feature or a selection of points by
    a given X and/or Y offset values. In case of line and polygon shapefiles
    you cannot offset a single point. In that case, simply type in the new
    coords in the grid. This is because if only one point in a line/polygon
    feature is selected when the offsets are given the entire feature is
    selected first and the offset applied to the entire feature.
 -> Done.
  • 0.0.2: Add display of coordinate reference system (CRS) of the loaded shapefile.
  • 0.0.1: Original published.