
Suppose you have a foobar.csv file that looks like this: You can now write a little csv help file to indicate the columns types to OGR.

Tigerpoly.py tgr46081.rt1 tiger_area.shp OGR CSV driver: easily indicate column types Ogr2ogr tiger_lines.shp tgr46081.rt1 CompleteChainĮxport PYTHONPATH=/usr/local/lib/python2.5/site-packages The -s_srs switch is assigning a source coordinate system to your input data (in case it didn’t have this properly defined already), and the -t_srs is defining a target coordinate system to reproject to. And if you prefix the filename with ESRI:: the library will interprete the WKT as being ESRI WKT and convert to “standard” format accordingly. Most comand line options for GDAL/OGR tools that accept a coordinate system will allow you to give the name of a file containing WKT. Ogr2ogr -s_srs WGS84 -t_srs ESRI::out.wkt out_dir indatasource If you save it to a text file called out.wkt you can do the following in a translation to reproject input latlong points to this coordinate system: nln archsites Using WKT files with ogr2ogr Ogr2ogr archsites.shp grassdata/spearfish60/PERMANENT/vector/archsites/head 1 \ # -nln is “new layer name” for the result: Ogr2ogr out.shape PG:’host= user=postgres dbname=ogc_simple’ lake_geom GRASS 6 and OGRĬonvert GRASS 6 vector map to SHAPE (needs GDAL-OGR-GRASS plugin): Ogrinfo PG:’host= user=postgres dbname=ogc_simple’ Gltp:/vrf/grass0/warmerdam/v0eur/vmaplv0/eurnasia Connect OGR and PostgreSQL/PostGIS Gltp:/vrf/grass0/warmerdam/v0eur/vmaplv0/eurnasia lakes of Trentino province in Italy: Gltp:/vrf/grass0/warmerdam/v0eur/vmaplv0/eurnasia elevation spots (points) for Germany: Gltp:/vrf/grass0/warmerdam/v0eur/vmaplv0/eurnasia -summary polbnda_germany.shp polbnda_germany | grep Extent Ogr2ogr -t_srs “EPSG:4326” -where “na2 = ‘GM'” polbnda_germany.shp

Gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr Germany, reproject on the fly from NAD83 to WGS84, store as SHAPE: Ogr2ogr -t_srs “EPSG:4326” -where “na2 = ‘BC'” polbnda_botswana.shp \ Or read the VMAP0 Military specs, page 75Įxtract Botswana, reproject on the fly from NAD83 to WGS84, store as SHAPE: Ogdi_info -u gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr \ Gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr VMAP0 examples Sample ‘where’ statements (use -sql for PostgreSQL driver): Polbnda_botswana.shp gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr OGR and SQL Ogrinfo -ro gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr -ro gltp:/vrf/grass0/warmerdam/v0eur/vmaplv0/eurnasia Extract spatial subregion, reproject from NAD83 to WGS84 Ogrinfo -ro gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr | grep bnd Ogrinfo -ro gltp:/vrf/grass0/warmerdam/v0soa/vmaplv0/soamafr Ogr2ogr ARC_BZ.shp -spat 10 45 13 47 ARC.shp Use spatial query extents: -spat xmin ymin xmax ymax (W S E N) Ogr2ogr -t_srs “`g.proj -wf`” polbnda_italy_GB_ovest.shp polbnda_italy_LL.shp Reproject to current GRASS location projection: prj file is missing, you can use the ‘epsg_tr.py’ utility to create it if you know the EPSG code: Ogr2ogr vmap0rd_ll.shp -t_srs “EPSG:4326” vmap0rd.shp We reproject from the source projection (as defined in. The -nln option sets the name of the layer to be copied to.

#Python ogr gdal kml to csv update
The second command is opening file_merged.shp in update mode, and trying to find existing layers and append the features being copied. Ogr2ogr -update -append file_merged.shp file2.shp -nln file_merged file2 Merge of two SHAPE files ‘file1.shp’ and ‘file2.shp’ into a new file ‘file_merged.shp’ is performed like this: You can easily grep the map extent of a vector map (bounding box):
