Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import os
- from osgeo import ogr, osr
- ogr.RegisterAll()
- # Shapefile lost parameter +towgs84
- pathFile = '/home/lmotta/data/script_gis_dev/data/test_utm_sad69.shp'
- strDrive= 'ESRI Shapefile'
- # GML use all parameters
- #pathFile = '/home/lmotta/data/script_gis_dev/data/test_utm_sad69.gml'
- #strDrive= 'GML'
- proj4Sr = '+proj=utm +zone=21 +south +ellps=aust_SA +towgs84=-57,1,-41,0,0,0,0 +units=m +no_defs'
- sr = osr.SpatialReference()
- sr.ImportFromProj4( proj4Sr )
- # Create Shapefile with SpatialReference (delete if exist)
- drv = ogr.GetDriverByName(strDrive)
- ds = drv.CreateDataSource(pathFile)
- lyr = ds.CreateLayer(pathFile, sr, ogr.wkbPolygon)
- print 'proj4Sr: %s' % proj4Sr
- print 'Layer : %s' % lyr.GetSpatialRef().ExportToProj4()
- # Free
- ds.Destroy()
- ds = None
- lyr = None
- if strDrive == 'GML':
- os.remove(pathFile)
- os.remove(pathFile.replace('.gml', '.xsd'))
- else:
- drv.DeleteDataSource(pathFile)
Advertisement
Add Comment
Please, Sign In to add comment