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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSWxDQDqNFFuHrq9bMQ_Bi3mLOhdejrUwI-c03WGpzSqgE13YosLetNxccVwXmz_ZpL2I1LVgmbSdRTsUs0OVhefulEV6Ve4sU_XiAGfvPKTrp3iyrV2gJGZw7UkMNXJVdpaVErYvsQg/s400/close01.png)
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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAQhGOGd1ZCmIFO8ZxzCwdXXzHIA2mShhSycVoG_4JWZr1Y5gsJ9m-08G1j6cT_TX4DrKP_8z57-1BmuJdk2q6TQZl_tCuFbRbRGTUIQPSKz0q3549e0RBQbq_SGb0Eke6kS7fr7VyBQ/s400/close02.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAQhGOGd1ZCmIFO8ZxzCwdXXzHIA2mShhSycVoG_4JWZr1Y5gsJ9m-08G1j6cT_TX4DrKP_8z57-1BmuJdk2q6TQZl_tCuFbRbRGTUIQPSKz0q3549e0RBQbq_SGb0Eke6kS7fr7VyBQ/s400/close02.png)
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.