wradlib.io.misc.write_polygon_to_text

wradlib.io.misc.write_polygon_to_text(fname, polygons)

Writes Polygons to a Text file which can be interpreted by ESRI ArcGIS’s “Create Features from Text File (Samples)” tool.

This is (yet) only a convenience function with limited functionality. E.g. interior rings are not yet supported.

Parameters:
  • fname (string) – name of the file to save the vertex data to
  • polygons (list of lists) – list of polygon vertices. Each vertex itself is a list of 3 coordinate values and an additional value. The third coordinate and the fourth value may be nan.
Returns:

None

Note

As Polygons are closed shapes, the first and the last vertex of each polygon must be the same!

Examples

Writes two triangle Polygons to a text file::
poly1 = [[0.,0.,0.,0.],[0.,1.,0.,1.],[1.,1.,0.,2.],[0.,0.,0.,0.]] poly2 = [[0.,0.,0.,0.],[0.,1.,0.,1.],[1.,1.,0.,2.],[0.,0.,0.,0.]] polygons = [poly1, poly2] write_polygon_to_text(‘polygons.txt’, polygons)
The resulting text file will look like this::
Polygon 0 0 0 0.000000 0.000000 0.000000 0.000000 1 0.000000 1.000000 0.000000 1.000000 2 1.000000 1.000000 0.000000 2.000000 3 0.000000 0.000000 0.000000 0.000000 1 0 0 0.000000 0.000000 0.000000 0.000000 1 0.000000 1.000000 0.000000 1.000000 2 1.000000 1.000000 0.000000 2.000000 3 0.000000 0.000000 0.000000 0.000000 END