<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> srs = osr . SpatialReference ( ) <EOL> srs . ImportFromEPSG ( <NUM_LIT> ) <EOL> driver = ogr . GetDriverByName ( '<STR_LIT>' ) <EOL> json_file = "<STR_LIT>" <EOL> geojson_datasource = ogr . Open ( json_file ) <EOL> geojson_layer_number = geojson_datasource . GetLayerCount ( ) <EOL> for layer in range ( geojson_layer_number ) : <EOL> geojson_layer = geojson_datasource . GetLayerByIndex ( layer ) <EOL> geojson_feature_number = geojson_layer . GetFeatureCount ( ) <EOL> for feature in range ( geojson_feature_number ) : <EOL> geojson_feature = geojson_layer . GetFeature ( feature ) <EOL> geojson_feature_geom = geojson_feature . GetGeometryRef ( ) <EOL> geojson_feature_type = geojson_feature_geom . GetGeometryType ( ) <EOL> geojson_feature_name = geojson_feature_geom . GetGeometryName ( ) <EOL> kml_file = '<STR_LIT>' . format ( geojson_feature_name ) <EOL> layer_name = '<STR_LIT>' <EOL> kml_datasource = driver . CreateDataSource ( kml_file ) <EOL> kml_layer = kml_datasource . CreateLayer ( layer_name , srs , geojson_feature_type ) <EOL> feature = ogr . Feature ( kml_layer . GetLayerDefn ( ) ) <EOL> feature . SetGeometry ( geojson_feature_geom ) <EOL> kml_layer . CreateFeature ( feature ) </s>
