TestLineString.py
1 |
#!/usr/bin/env python
|
---|---|
2 |
|
3 |
# 201110118979f891
|
4 |
|
5 |
import ogr, os, osr |
6 |
|
7 |
OutFile_str = 'Test100000.shp'
|
8 |
|
9 |
Driver = ogr.GetDriverByName('ESRI Shapefile')
|
10 |
if os.path.exists(OutFile_str):
|
11 |
Driver.DeleteDataSource(OutFile_str) |
12 |
|
13 |
DSrc = Driver.CreateDataSource(OutFile_str) |
14 |
LayerOut = DSrc.CreateLayer(OutFile_str, geom_type=ogr.wkbLineString) |
15 |
|
16 |
x=-40.0; y=20.0; Inc_flt= 0.001; |
17 |
|
18 |
for C1_int in range(0,100000,1): |
19 |
WKT_str = 'LINESTRING(%f %f, %f %f, %f %f, %f %f, %f %f)' % (x, y, x+Inc_flt*(C1_int*2+1), y, x+Inc_flt*(C1_int*2+1), y-Inc_flt*(C1_int*2+1), x , y-Inc_flt*(C1_int*2+1), x, y) |
20 |
x -= Inc_flt; y += Inc_flt; |
21 |
|
22 |
FeatureOut = ogr.Feature(feature_def=LayerOut.GetLayerDefn()) |
23 |
FeatureOut.SetGeometryDirectly(ogr.CreateGeometryFromWkt(WKT_str)) |
24 |
LayerOut.CreateFeature(FeatureOut) |
25 |
FeatureOut.Destroy() |
26 |
|
27 |
DSrc.Destroy() |