Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 1872

ogr2ogr is an open source command line utility popular for converting to and from various vector spatial data formats.

7 votes
Accepted

Can ogr2ogr be used to append multiple DBF files?

From a system shell, use ogr2ogr with the -append flag: $ ogr2ogr -append all.dbf a.dbf $ ogr2ogr -append all.dbf b.dbf $ ogr2ogr -append all.dbf c.dbf These files can be either shapefiles or sole DBF …
Mike T's user avatar
  • 42.4k
2 votes

Using "ogr2ogr -sql" without an input fiile

You could make a tiny Python script, e.g. wkt2json.py #!/usr/bin/env python import sys from osgeo import ogr ogr.UseExceptions() print(ogr.CreateGeometryFromWkt(sys.argv[1]).ExportToJson()) And use …
Mike T's user avatar
  • 42.4k
2 votes
Accepted

ogr2ogr Set Feature to Column Name?

can even modify the "sql_statement" label to something else with adding another option: -dsco OGR_DATASOURCE="States" The order of these options are important, where the full working command is: ogr2ogr
Mike T's user avatar
  • 42.4k
11 votes

Piping data to ogr2ogr

ogr2ogr -f KML countries.kml https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_50m_admin_0_countries.geojson …
Mike T's user avatar
  • 42.4k
0 votes
Accepted

Convert Canadian census subdivision polygons to WKT (4326) using ogr2ogr?

Use ogr2ogr to reproject vector data using something like this: ogr2ogr -s_srs EPSG:3347 -t_srs EPSG:4326 new.shp old.shp …
Mike T's user avatar
  • 42.4k
2 votes
Accepted

How to debug ogr2ogr ERROR 1: Did not get at least 2 values or invalid number of set of coor...

Add -dim 3 to force the coordinate dimension to 3D for both the layer geometry type, and feature geometries. This option requires GDAL 1.10, which is currently in development.
Mike T's user avatar
  • 42.4k
3 votes

shell script ogr2ogr export

read -p "enter country code: " CODE echo "exporting data from $CODE" SRC="PG:'dbname=alamedaok user=postgres host=localhost'" SQL="SELECT id_alameda, pais, geom FROM poblaciones_def WHERE pais=$CODE" ogr2ogr
Mike T's user avatar
  • 42.4k
3 votes
Accepted

Lossless conversion from shapefiles to XML/JSON/Text

These are passed to ogr2ogr using -dco and -lco flags. …
Mike T's user avatar
  • 42.4k
5 votes
Accepted

OGR2OGR and SQL: selecting 30 biggest places from a country?

If you have GDAL/OGR 1.10 or later, use -dialect SQLITE for the SQLite SQL dialect, which supports ORDER BY POP_MAX DESC LIMIT 30 in SQL statements.
Mike T's user avatar
  • 42.4k
3 votes

How to Aggregate and dissolve MySQL geometry

If you have MySQL 5.7.5 or later, you can use MySQL's ST_Union function from ogr2ogr: ogr2ogr -sql "SELECT ST_Union(geo) FROM counties" -f KML counties.kml MySQL:"..." … As a special case, "Union" is called GUnion: ogr2ogr -dialect SQLITE -sql "SELECT GUnion(geo) FROM counties" -f KML counties.kml MySQL:"..." …
Mike T's user avatar
  • 42.4k
1 vote
Accepted

How can I convert ESRI personal geodatabase (.mdb) to shapefile using OGR in C#?

Does the ogr2ogr command work? An easy one would be to run it from C#. Otherwise you can use the C# SWIG bindings, if you can get these for your programming environment with PGeo support. …
Mike T's user avatar
  • 42.4k
11 votes
Accepted

How to convert curved features into geojson

You're on the right track. Curved geometries were brought into GDAL/OGR 2.x. You can approximate curved geometries as a linear geometry. Both OGR and Shapely can export as a GeoJSON-like dict (via map …
Mike T's user avatar
  • 42.4k
39 votes
Accepted

Using ogr2ogr to convert all shapefiles in directory?

On Windows, for the current and sub-directories under the current, try this command: for /R %f in (*.shp) do ogr2ogr -f "MapInfo File" "%~dpnf.tab" "%f" To briefly explain the trickery of what is going …
Mike T's user avatar
  • 42.4k
12 votes
Accepted

How to rename ogr2ogr tables on export to Spatialite?

From the ogr2ogr docs, use the -nln name option to assign an alternate name to the new layer. …
Mike T's user avatar
  • 42.4k
4 votes

ogr2ogr kml to shp conversion created 184 shapefiles?! What am I missing?

From your SQL: CREATE SCHEMA import; Now from your shell (I'm using OSGeo4W Shell): $ ogr2ogr -append -f PostgreSQL PG:"dbname='your_db' user='postgres' password='secret'" \ doc.kml -lco SCHEMA …
Mike T's user avatar
  • 42.4k

15 30 50 per page