I want to create new a Ogr Layer using the Datasource.GetLayer() method:
driver = ogr.Open(input_file).GetDriver()
datasource = driver.Open(input_file, 0)
input_layer = datasource.GetLayer()
If the input datasource does not have a spatial reference (as usually i.e. by GeoJson data) the new layer has SRS = 4326. If I write the data to a new Postgis table, the table has 4326 as geometry srid:
output_data_source.CopyLayer(input_layer,
table_name,
['OVERWRITE=YES', 'GEOMETRY_NAME=geom', 'DIM=2', 'FID=id', 'PG_USE_COPY=YES'])
How can I set the layer SRS? Something like:
input_layer.SetSrs(new_srs)
but the API does not offer a such method: (http://gdal.org/python/osgeo.ogr.Layer-class.html). The command line tool ogr2ogr offers for this purpose the parameters s_srs and t_srs. I.e:
ogr2ogr -t_srs 'EPSG:32632' -f "PostgreSQL" PG:"dbname=test host=localhost" input.geojson