Editing Shapefiles

[ezcol_2third]

CMaps Plugin and GMaps Plugin uses ESRI shapefiles as a mechanism for loading geographic boundaries within your map. The shapefile format is widely used as a standard format used across every GIS toolset and application. A shapefile can be edited and manipulated using GIS tools.ESRI Arc GIS is one of the most widely used by professional GIS developers. However, there are a wide variety of tools, some of which are open source, that allow you to edit and published shapefiles. At Centigon Solutions, we use and recommend Quantum GIS which is an open source application that you can download and use for free for editing shapefiles. The same way you use Photoshop to edit photos, you can use Quantum GIS to edit shapedata.

NOTE: Quantum GIS is not required for use with CMaps Plugin or GMaps Plugin and there is no server requirements for Quantum GIS

1. Obtain Quantum GIS 

Quantum GIS is an open source GIS (geographic information system) desktop tool viewing and editing geospatial data. The same way you use Photoshop for editing photos, GIS tools like Quantum GIS or ESRI ArcGIS allow you to accomplish a variety of tasks related to spatial data. Because QGIS is an open source initiative, there is no cost. You will need to install QGIS on your desktop only. No server software is required.

Obtain Quantum GIS from: http://www.qgis.org/

2. Obtain and Copy Shapefiles

Before importing your shapefile, make sure you make a copy. Once you start editing a shapefile, you are modifying the contents of the file and want to have the original on-hand.
Free Shapefile Resources from Centigon Solutions

3. Import a Shapefile
Select Layer>Add Vector Layer or click on the add layer icon add layer
You will browse to a file location on your computer and select a .SHP file. You are required to also have the .DBF and .SHX files together to successfully import your shape file.

4. Edit the Shapefile
Toggle edit mode on for the shape file by selecting Layer>Toggle Editing or click on the edit icon edit

NOTE: Prior to editing a shapefile, we highly recommend saving a copy. Learn how to save a new shapefile

5. Selecting individual shapes

There are two ways that you can select shapes from a shapefile:

1. Selecting from the map imagery: Choose the select type for how you will pick shapes from your map. You can either manually click on each shape or select with a bounding box to choose multiple shapes.

2. Select from the attributes table:The second way to select shapes is directly from the attributes table, where you can manually click on each row, or use a select statement to programmatically choose what shapes you want to edit. To open the attributes table, click on Layer>Open Attributes Table, or click on the attributes icon. 

With the attribute table open, you can click “Advanced Search” to expose a simple query builder making it much easier to programmatically select the regions that you would like to modify. For example

NAME =’Brown’ OR NAME = ‘Duval’

This would select the Brown and Duval locations with you having to manually find them.

6. Edit Shapes

With shapes selected, there are multiple ways for which you can edit shapes once they have been imported as a layer:

deleteDelete Shapes: With shapes selected on the map or in the attributes table, you can delete the shapes from the file by clicking on the delete button. Once deleting the shape, the changes are applied directly to your shapefile. This is why it is important to make a copy before editing.

Merging Shapes: In many cases, you may want to merge multiple multiple shapes together to make one single shape. Perhaps your western region is a combination of states, or a local zone is made up of zip codes. The merge functionality will combine the attributes and make one single shape. With your shapes selected, click on the merge button: 
Before the shapes or completely merged, Quantum GIS will prompt you to decide what attribute data will be assigned to this newly merged shape.

 7. Saving your Shapefile

With your shapefile edited, you should plan to save a copy in all cases. This is a good best practice to inherit to ensure that the final output has the proper projection file.

To save the new shapefile click  Layer>Save edits.

This will prompt you with a screen where you will choose the file format which should be “ESRI Shapefile”, the Save As Path, the encoding which should be “System” and the CRS.

Changing the CRS: To ensure that you always have the correct map projection, click browse next to CRS, and then navigate to the option called “WGS 84”. This is a standard projection used by Google Maps and is located at:

Geographic Coordinate Systems>WGS 84

There are multiple instances of WGS 84, so make sure the Authority ID is EPSG:4326

Other Global Shapefile Modifications

Simplifying Geometry

If your shapefile is very large, there is a chance that you would benefit from simplifying the geometry. This will essentially reduce the total number of data points required to draw shapes. Depending on the origin and purpose of your shapefiles, you may find that the file size is un-necessarily bloated. To simplify the geometry select: Vector>Geometry Tools>Simplify Geometries

You will be prompted to select the new shapefile destination and a Tolerance. You may need to generate multiple files to get the tolerance right so make sure to include the tolerance value in the file name. A good starting point is “0.001.” Once, the simplified file is to your desired specification, unless you are 100% certain that the projection is correct, you may need to perform step 6 above.

Re-projecting Shapefiles: To ensure that you always have the correct map projection you may need to re-project your shapefiles for use with GMaps Plugin.

The easiest way to re-project is via the “Save As” feature shown in Step 6 above.

 

[/ezcol_2third] [ezcol_1third_end]

Working with Geo-Data

Tech-Tuesday: Creating and Analyzing your own regions

Free Shapefiles

Other Tutorials for Quantum GIS

[post_list name=”QuantumGIS Tutorials”]
[/ezcol_1third_end]