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.
To fit into this documentation, illustrations show a small Manifold desktop, with only a few panes, docked to the right side. In real life we use a much larger Manifold desktop, and more panes would be turned on, with panes docked to the left or to the right, or undocked, as we prefer. Right-click a pane's tab to change where it is docked. Manifold will remember that new arrangement for our next session.
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.
We launch Manifold and then choose File - Link.
In the Link dialog we browse into the folder where our shapefiles are located, we click on the .shp file and then press Link.
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.
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.
Most 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 Info 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.
Clicking on the Info 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 Info 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.
We click
on the coordinate picker button and see the only option is to Assign Initial Coordinate
System.
That unfolds a menu with a More... choice 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.
The Latitude / Longitude system appears in the Info 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...
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.
Click the Project tab to get the Project pane back (not particularly necessary for what we are doing, but we like the lighter illustrations...).
Ctrl-click on some of the area objects to select them. Selected objects appear in red selection color. If desired, we can change the selection color used by Manifold in the Tools - Options dialog.
The Counts pane in the Status bar reports the number of objects we have selected, out of the total number of records (objects are records in the drawing's table).
Choose Edit - Delete.
Manifold by default raises a confirmation dialog. This may be eliminated either in Tools - Options or by checking the Never show this again box.
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.
We will now make a small change to a record, changing one of the field values, also known as attributes.
Double-click the states Table table to open it.
Double-click into the Place_name cell for the province of Durango, to start editing that attribute.
Edit the name of the province to use a mix of upper and lower case. Press Enter to apply the edit.
We choose File - Save As to save the project as Edit a Shapefile.map. This saves changes to the linked shapefile as well.
The linked data's database cylinder no longer has an * asterisk sub-icon since we have saved the changes.
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.
Choose File - Import.
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.
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.
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.
We will assign the correct coordinate system to show the data appears correctly when the correct coordinate system is applied.
In the Info pane we click
on the coordinate picker button
We choose Latitude / Longitude projection from the list of two favorites.
Moving the mouse cursor over the states window, we can see from the status bar readout that the geographic coordinates for Mexico seem to be correct.
We can verify our province areas are correctly georeferenced by showing them as a layer in a map together with a "known good" layer such as Bing satellite.
We choose File - Create - New Map.
In the New Map dialog we choose Bing Maps Satellite as the Base layer and we check the box for the states drawing. Press Create Map.
In the illustration above, we have double-clicked open the new Map, and we have used Style to color provinces in Mexico in a variety of pastel colors.
Shapefiles are limited - 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.
Assign Initial Coordinate System
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