First i downloaded http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/ogr2ogr.py and i am importing this. How can i get ogr2ogr to run in my script? nothing seems to be working and i not sure how to continue problem solving.
#!/usr/bin/env python
import ogr2ogr
import sys
if __name__=="__main__":
ogr2ogr.main('-f', "Mapinfo File", '/home/firstuser/birmingham/Wood.tab', "/home/firstuser/birmingham/Wood.shp")
With this i get main() takes at most 3 arguments (4 given)
and when i do .
if __name__=="__main__":
ogr2ogr.main('-f', "Mapinfo File", '/home/firstuser/birmingham/Wood.tab')
i get
Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update] [-gt n]
[-select field_list] [-where restricted_where]
[-progress] [-sql <sql statement>]
[-spat xmin ymin xmax ymax] [-preserve_fid] [-fid FID]
[-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]
[-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]
[-simplify tolerance]
[-fieldTypeToString All|(type1[,type2]*)] [-explodecollections]
dst_datasource_name src_datasource_name
[-lco NAME=VALUE] [-nln name] [-nlt type] [-dim 2|3] [layer [layer ...]]
-f format_name: output file format name, possible values are:
-f "ESRI Shapefile"
-f "MapInfo File"
-f "TIGER"
-f "S57"
-f "DGN"
-f "Memory"
-f "BNA"
-f "CSV"
-f "GML"
-f "GPX"
-f "KML"
-f "GeoJSON"
-f "Interlis 1"
-f "Interlis 2"
-f "GMT"
-f "SQLite"
-f "ODBC"
-f "MSSQLSpatial"
-f "PostgreSQL"
-f "MySQL"
-f "PCIDSK"
-f "DXF"
-f "Geoconcept"
-f "GeoRSS"
-f "GPSTrackMaker"
-f "PGDump"
-f "GPSBabel"
-append: Append to existing layer instead of creating new if it exists
-overwrite: delete the output layer and recreate it empty
-update: Open existing output datasource in update mode
-progress: Display progress on terminal. Only works if input layers have the "fast feature count" capability
-select field_list: Comma-delimited list of fields from input layer to
copy to the new layer (defaults to all)
-where restricted_where: Attribute query (like SQL WHERE)
-sql statement: Execute given SQL statement and save result.
-skipfailures: skip features or layers that fail to convert
-gt n: group n features per transaction (default 200)
-spat xmin ymin xmax ymax: spatial query extents
-simplify tolerance: distance tolerance for simplification.
-dsco NAME=VALUE: Dataset creation option (format specific)
-lco NAME=VALUE: Layer creation option (format specific)
-nln name: Assign an alternate name to the new layer
-nlt type: Force a geometry type for new layer. One of NONE, GEOMETRY,
POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION, MULTIPOINT,
MULTIPOLYGON, or MULTILINESTRING. Add "25D" for 3D layers.
Default is type of source layer.
-dim dimension: Force the coordinate dimension to the specified value.
-fieldTypeToString type1,...: Converts fields of specified types to
fields of type string in the new layer. Valid types are :
Integer, Real, String, Date, Time, DateTime, Binary, IntegerList, RealList,
StringList. Special value All can be used to convert all fields to strings.
-a_srs srs_def: Assign an output SRS
-t_srs srs_def: Reproject/transform to this SRS on output
-s_srs srs_def: Override source SRS
Srs_def can be a full WKT definition (hard to escape properly),
or a well known definition (ie. EPSG:4326) or a file with a WKT
definition.
Many thanks