Script configured for ArcGIS 9.1: Download
This will not work for ArcGIS 9.0 and has not yet been tested for 9.2. For a narrative of my ArcGIS 9.2 woes, go here.
This script has two potential uses: Edit an existing shapefile or Create a new shapefile in text format.
There are actually two scripts: shp2exch.py and exch2shp.py that are launched independent of each other.
I initially developed the script so that faculty in our Earth & Environmental Science department can disassemble shapefiles, apply tectonic rotation formulas to the resulting text files, and then reassemble the shapefiles.
- shp2txt converts points, polylines (including multipart), and polygons (including multipart and inner circles) to a text file using an exchange format. The text file can be edited by hand or of course another application can be developed to edit these text files.
- txt2shp converts an existing text file in the exchange format to a shapefile.
Download and unzip the contents. Open ArcMap or ArcCatalog 9.1. View the ArcToolbox pane. Right-click on ArcToolbox and select Add Toolbox. Browse to the directory where you unzipped the scripts, and click once on exchanger, and click Open.
Now you can expand the exchanger toolbox to launch the two scripts.
There are also two executable files that launch forms external of ArcGIS. However, ArcGIS still needs to be installed on the system and everything runs slower. You can give it a shot, but I advise using the toolbox within ArcGIS.
The Exchange Format
The text file uses a CSV comma delimited (comma-separated values) file structure with a extension. I used a .csv extension so that the file can be launched directly into Excel by double-clicking.
The text file uses an exchange format that follows the following structure:
- First line contains all of the attribute (field) names in the shapefile, plus xLatitude, xLongitude, and geometry
- Second line contains the field type of the attributes
- The third line through the last line contain the X and Y value for each vertex.
- In addition, each new feature, part, or inner circle
is prefaced with a line beginning with NEW and the attributes for that feature or part.
Here is an example of a text file representing freeway lines in North Central Texas.
- Coordinate system is preserved because the XY units are preserved in the text file. However, I have been having trouble preserving the complete projection information, so the resulting shapefile projections are not defined.
- Currently only works with shapefiles, and not geodatabase feature classes. This is due to poor planning as the script currently relies on the FID field, and does not look for an OBJECTID field.
- Probably does not work with ArcGIS 9.2. After last week's troubles, I do not expect to install and fix any 9.2 bugs within the next couple of weeks.
- Code is currently a bit sloppily written. Needs to be cleaned up a bit.