Sometimes I get ASCII text files of polygons but with unclosed vertices. What I mean is that the first point and last point of the polygon in the ASCII file are not the same. An example is shown in the figure below.
When I load this polygon ASCII file into Global Mapper or GeoMedia, the polygon is displayed as an unclosed line string. An example is shown in the figure below.
To close such cases of unclosed polygons, I decided to use FME 2009. Here are the steps I took to form a close polygon from the unclosed polygon ASCII file. There is a LineCloser Transformer in FME that will do the job.
- Start up the FME Workbench by selecting Start > All Programs > FME > FME Workbench. Choose to work with the Translation Workspace Wizard.
The Create Translation Workspace Wizard dialog box appears.
- In the text box, choose Comma Separated Value (CSV) as the source data format. Click Next.
The Locate Source Data page appears.
- Browse or type in the location and name of the source ASCII file e.g. C:\Temp\polygon.csv. Click Settings.
The Input Settings for Comma Separated Value dialog box appears.
- In the Separator character drop down list, choose space. Click OK. Click Next.
The Select Destination Format page appears.
- Choose ESRI Shape. Click Next until the Wizard is completed.
The Workbench is filled in with the source and destination datasets.
- In the FME Workbench, add in the 2DPointAdder, PointConnector, LineCloser Transformers. Connect them to the source and destination datasets as shown in the figure below.
- Open up the 2DPointAdder Parameters.
- In the X Value drop down list, choose col0. In the Y Value drop down list, choose col1. Click OK.
- Open up the destination dataset Feature Type Properties.
- In the Allowed Geometries drop down list, choose shape_polygon. Click OK.
- Run the translation.
The unclosed polygon ASCII file is transformed to a closed polygon in Shapefile format.