<s> '''<STR_LIT>''' <EOL> import os <EOL> try : <EOL> import ogr <EOL> except ImportError : <EOL> from osgeo import ogr <EOL> try : <EOL> import osr <EOL> except ImportError : <EOL> from osgeo import osr <EOL> in_shp_file = '<STR_LIT>' <EOL> driver = ogr . GetDriverByName ( '<STR_LIT>' ) <EOL> in_shp_datasource = driver . Open ( in_shp_file ) <EOL> in_layer = in_shp_datasource . GetLayerByIndex ( <NUM_LIT:0> ) <EOL> in_geom_type = in_layer . GetGeomType ( ) <EOL> source = in_layer . GetSpatialRef ( ) <EOL> target = osr . SpatialReference ( ) <EOL> target . ImportFromEPSG ( <NUM_LIT> ) <EOL> transform = osr . CoordinateTransformation ( source , target ) <EOL> out_shp = '<STR_LIT>' <EOL> out_layer_name = '<STR_LIT>' <EOL> if os . path . exists ( out_shp ) : <EOL> driver . DeleteDataSource ( out_shp ) <EOL> data_source = driver . CreateDataSource ( out_shp ) <EOL> out_layer = data_source . CreateLayer ( out_layer_name , target , in_geom_type ) <EOL> in_layer_defn = in_layer . GetLayerDefn ( ) <EOL> num_field_col = in_layer_defn . GetFieldCount ( ) <EOL> for each in range ( num_field_col ) : <EOL> field = in_layer_defn . GetFieldDefn ( each ) <EOL> out_layer . CreateField ( field ) <EOL> in_num_feature = in_layer . GetFeatureCount ( ) <EOL> for feature in range ( in_num_feature ) : <EOL> in_feature = in_layer . GetFeature ( feature ) <EOL> in_geom = in_feature . GetGeometryRef ( ) <EOL> in_geom . Transform ( transform ) <EOL> feature = ogr . Feature ( out_layer . GetLayerDefn ( ) ) <EOL> feature . SetGeometry ( in_geom ) <EOL> out_layer . CreateFeature ( feature ) </s>
