-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheden_grid_boundary_poly_shape.py
More file actions
executable file
·80 lines (54 loc) · 1.7 KB
/
eden_grid_boundary_poly_shape.py
File metadata and controls
executable file
·80 lines (54 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
import osgeo
import osgeo.osr
from osgeo import ogr
import sys
import string
import os
debug = True
#
# Create and Define the Spatial Reference
#
if debug: print "Creating Spatial Reference"
spatialReference = osgeo.osr.SpatialReference()
spatialReference.ImportFromProj4('+proj=utm +zone=17 +ellps=WGS84 +datum=WGS84 +units=m')
#
# Establish Driver for Shapefile
#
if debug: print "creating driver"
driverName = "ESRI Shapefile"
driver = ogr.GetDriverByName( driverName )
if driver is None:
print "Driver Not Available: %s" % driverName
sys.exit( 1 )
if debug: print "creating dataSource"
path = "/opt/physical/util/kevdev/gis/shapefile/eden"
dataSource = driver.CreateDataSource( path )
if dataSource is None:
print "Creation of DataSource output file FAILED"
sys.exit( 1 )
if debug: print "creating Layer"
#
# Create the Layer
# This will be the name of the shapefile that is written to the DataSource Directory
#
grid_layer = dataSource.CreateLayer( "grid_boundary", spatialReference, osgeo.ogr.wkbMultiPolygon )
if debug: print type( grid_layer )
grid_layer_defn = grid_layer.GetLayerDefn()
if debug: print "creating Geometry"
ring = osgeo.ogr.Geometry( osgeo.ogr.wkbLinearRing )
ring.AddPoint( 463200, 2790000 )
ring.AddPoint( 578000, 2790000 )
ring.AddPoint( 578000, 2952000 )
ring.AddPoint( 463200, 2952000 )
ring.AddPoint( 463200, 2790000 )
if debug: print "creating Polygone"
polygon1 = ogr.Geometry( ogr.wkbPolygon )
polygon1.AddGeometry( ring )
featureIndex = 0
feature = osgeo.ogr.Feature( grid_layer_defn )
feature.SetGeometry( polygon1 )
feature.SetFID( featureIndex )
if debug: print "adding feature to layer"
grid_layer.CreateFeature( feature )
dataSource.Destroy()