[FWTools] setting the projection on a Shape file

Moreau, Jean-Sebastien jmoreau at nrcan.gc.ca
Wed Mar 8 10:03:26 EST 2006


Hi list!

I'm trying to create a shape file with a polygon in it and I want to set the
coordinate system to NAD83. Here's my python script:
----------------------------------
import ogr,osr

wkt = 'POLYGON ((%f %f, %f %f, %f %f, %f %f, %f %f))' %
(llx,lly,ulx,uly,urx,ury,lrx,lry,llx,lly)

driver=ogr.GetDriverByName('ESRI Shapefile')
datasource=driver.CreateDataSource(shapePath)

layer=datasource.CreateLayer('cadre',geom_type=ogr.wkbPolygon)
geom=ogr.CreateGeometryFromWkt(wkt)

spatial=osr.SpatialReference()
spatial.SetWellKnownGeogCS("NAD83")

#Assignation de la géoréference à l'objet géométrique
		
geom.AssignSpatialReference(spatial)
		
#Activation de la géométrie dans le feature puis dans le layer
		
feat=ogr.Feature(layer.GetLayerDefn())
feat.SetGeometry(geom)
layer.CreateFeature(feat)
		
#Fermeture du fichier
		
datasource.Destroy()
-----------------------------------------
Assuming the llx,lly, etc are correct coordinates, I should get a shape file
with the correct coordinate system. However when I open it in ArcMap and go
to the properties, it says the coordinate system is NAD27.

Am I doing something wrong?

Thanks

Jean-Sébastien Moreau

Centre d'information topographique de Sherbrooke 
Ressources naturelles Canada 
2144, rue King Ouest, bureau 010 
Sherbrooke (Québec) J1J 2E8 
Tél. : (819) 564-5600-ext 295     Téléc. : (819) 564-5698 
Courrier électronique : jmoreau at RNCan.gc.ca 

Centre for Topographic Information of Sherbrooke 
Natural Resources Canada 
2144, King Street West, Suite 010 
Sherbrooke, Quebec  J1J 2E8 
Tel.:  (819) 564-5600-ext 295     Fax:  (819) 564-5698 
E-mail:  jmoreau at NRCan.gc.ca 





More information about the FWTools mailing list