<s> '''<STR_LIT>''' <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> shp_file = "<STR_LIT>" <EOL> shp_datasource = ogr . Open ( shp_file ) <EOL> srs = osr . SpatialReference ( ) <EOL> srs . ImportFromEPSG ( <NUM_LIT> ) <EOL> driver = ogr . GetDriverByName ( '<STR_LIT>' ) <EOL> kml_file = '<STR_LIT>' <EOL> layer_name = '<STR_LIT>' <EOL> kml_datasource = driver . CreateDataSource ( kml_file ) <EOL> kml_layer = kml_datasource . CreateLayer ( layer_name , srs , ogr . wkbLineString ) <EOL> layer_number = shp_datasource . GetLayerCount ( ) <EOL> for each in range ( layer_number ) : <EOL> layer = shp_datasource . GetLayerByIndex ( each ) <EOL> features_number = layer . GetFeatureCount ( ) <EOL> for i in range ( features_number ) : <EOL> shp_feature = layer . GetFeature ( i ) <EOL> feature_geometry = shp_feature . GetGeometryRef ( ) <EOL> kml_feature = ogr . Feature ( kml_layer . GetLayerDefn ( ) ) <EOL> kml_feature . SetGeometry ( feature_geometry ) <EOL> kml_layer . CreateFeature ( kml_feature ) </s>
