Example: Edit a Shapefile In Place

 

Example: Edit a Shapefile In Place

In this example we learn how to edit ESRI shapefiles  "in place," that is, leaving the data in the shapefile and only linking it into a project and not importing it into the project.

Link a Shapefile into the Project

To edit a file in place we can either link it into the project or create a new data source using the file.   For connections to more complex data such tables within an Oracle database, we would create a new data source using File - Create - New Data Source.   For simple files like shapefiles we will link it into the project using File - Link.

 

 

eg_edit_single_file01_01.png

 

We launch Manifold and then choose File - Link.

 

eg_edit_single_file01_02.png

 

In the Link dialog we browse into the folder where our shapefiles are located, we click on the .shp file and then press Link.

 

 

eg_edit_single_file01_03.png

 

The link appears in the project as a database cylinder, indicating the data is hosted outside of the project.  We click on the + plus icon to expand it.

 

eg_edit_single_file01_04.png

 

Within the linked data hierarchy we double-click on the states drawing to open it. The drawing shows provinces ("states") in Mexico.   Note that the database cylinder now has an asterisk sub-icon to indicate it has been used and thus may have been changed.

Assign Initial Coordinate System

Many shapefiles we encounter in modern times will have a .prj file as part of the shapefile ensemble that provides coordinate system information.   Manifold will automatically assign the correct coordinate system when linking to or importing such shapefiles, saving us from having to manually assign an initial coordinate system.

 

Since examples are less educational if they assume everything is easy and done for us automatically, for this example we have chosen shapefiles which did not have a .prj file.   Without a .prj file, we know the shapefile does not specify the coordinate system used by the drawing.  Before we edit the drawing we must assign an initial coordinate system.

 

In any case, shapefiles are such a wretchedly backward format that any time we link to or import from a shapefile, we should check to see if Manifold has been able to automatically harvest a coordinate system from the shapefile.   That is easy to do with a single click by checking the Component panel of the Contents pane.  If it reports the coordinate system used by the shapefile in red text, that means the shapefile did not provide any coordinate system info and we must assign the initial coordinate system manually.  

 

eg_edit_single_file01_04a.png

 

Clicking on the Component panel of the Contents pane we see that Manifold has detected the spatially brain-dead lack of a .prj file in this particular shapefile ensemble.   Manifold, has provisionally assigned a placeholder coordinate system of Pseudo-Mercator, and is reporting the coordinate system using red text to warn us it is a provisional assignment.  Manifold wants us to assign an initial coordinate system manually, since the shapefile fails to do so.  

 

If we failed to notice the lack of a .prj file, or failed to notice the red text in the Contents pane, we might notice the strange coordinates reported in the Status bar when we move the mouse cursor over Mexico.

 

Assigning an initial coordinate system is easy.  The two most likely choices are even built-in Favorites, that we can choose with a single click.  

 

eg_edit_single_file01_04b.png

We click on the coordinate picker button and see the only option is to Assign Initial Coordinate System.   That unfolds a menu that allow us to launch the full Coordinate System dialog with a choice of thousands of systems, choose one of the two Favorites built into Manifold, or to edit the Favorite Coordinate Systems dialog.   We know this particular shapefile uses Latitude / Longitude projection so that is what we choose.

 

eg_edit_single_file01_04c.png

 

The Latitude / Longitude system appears in the Contents pane, which uses black text to report it, indicating the initial coordinate system has been assigned.  The Status bar now reports expected coordinates, right about where Mexico should be, when we move the mouse cursor over the drawing.   Onward to editing...

Edit the Drawing

 

When we edit the drawing that is in the linked shapefile we are editing the shapefile.   To demonstrate, we will do two simple edits.  First we will delete some objects from the drawing and then next we will edit a field in the drawing's table.

 

eg_edit_single_file01_05.png

 

Ctrl-click on some of the area objects to select them.   Choose Edit - Delete.

 

 

 

eg_edit_single_file01_05a.png

 

Manifold by default raises a confirmation dialog.  This may be eliminated either in Tools - Options or by checking the Never show this again box.

 

eg_edit_single_file01_06.png

 

The confirmation dialog asks about deleting records because objects in drawings are nothing more than geometry records in the associated table.   Press OK and the selected objects are deleted.

 

Edit a Record

We will now make a small change to a record.

 

eg_edit_single_file01_07.png

 

Double-click the states Table table to open it.   

 

eg_edit_single_file01_08.png

 

We double-click into the PROVINCE cell for the province of Durango and we edit it to use a mix of upper and lower case.  Press Enter to close the edit.

 

eg_edit_single_file01_09.png

 

We choose File - Save As to save the project as Edit a Shapefile.map.  This saves changes to the linked shapefile as well.

 

eg_edit_single_file01_10.png

 

The linked data's database cylinder no longer has an * asterisk sub-icon since we have saved the changes.

Verify the Shapefile has been Edited

Now that we have edited the shapefile in place, we can try importing it into a new blank project to see if we have indeed made the edits we intended.   We choose File - New to close the project and to open a new, blank project.

 

eg_edit_single_file01_11.png

 

Choose File - Import.

 

eg_edit_single_file01_12.png

 

In the Import dialog we browse over to the shapefile, click it to highlight it and then press Import.   Note that in the file folder there is now a .mapcache file that Manifold wrote when we edited the shapefile, to make it easier and quicker for Manifold to use the shapefile again.

 

eg_edit_single_file01_13.png

 

The shapefile imports as a drawing and the drawing's table.  We double-click on the drawing to open it.   We see that the provinces we deleted are indeed deleted.  

 

Note also from the Status bar Location readout that the coordinates are strange.   We have not yet assigned the initial coordinate system to the drawing, which was imported from a shapefile that still lacks a .prj.   If instead of linking the shapefile we had imported the shapefile and then exported it with the changes we made, Manifold would have written a .prj file to the shapefile ensemble.   But by linking the shapefile in place we leave it in as original condition as possible excepting the edits made.

 

eg_edit_single_file01_14.png

 

We double-click on the table to open that as well.  We can see that the edit we made to the PROVINCE field for the province of Durango has indeed happened: the name of the province is in mixed case.

Notes

Shapefiles have limitations as discussed in the SHP, Shapefiles  topic.   For example, a shapefile can contain only points, or only lines or only areas, but not a mix of points, lines and areas.   Because of that limitation of shapefile format we could have edited this shapefile to add a square shape to it, for example, but we could not have edited it to add group of points or lines.

See Also

File - Export

 

Assign Initial Coordinate System

 

Change Coordinate System

 

SHP, Shapefiles

 

Example: Import a Shapefile - ESRI shapefiles are a very popular format for publishing GIS and other spatial data.  Unfortunately, shapefiles often will not specify what projection should be used.  This example shows how to deal with that quickly and easily.

 

Latitude and Longitude are Not Enough

 

Shapefiles Strangely Out of Shape

 

Three Letter Extensions