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

learn more… | top users | synonyms

1
vote
1answer
21 views

Merge multiple linestring features into a single multilinestring

Using QGis or ogr2ogr how do I convert a vector file containing multiple linestrings features into a single multilinestring feature? At the moment I've been doing this manually by converting the data ...
1
vote
0answers
15 views

Debugging ogr2ogr “AddGeometryColumn failed” and “Terminating translation prematurely after failed translation of layer”

As noted in the title, I'm getting the following error: ERROR 1: AddGeometryColumn failed for layer pretty_polys, layer creation has failed. ERROR 1: Terminating translation prematurely after failed ...
1
vote
1answer
12 views

How to connect to CouchBase with ogr2ogr?

I am trying to load a Shapefile to CouchBase (version: 2.5.0 DEV edition, installed on Ubuntu), but with no success. According to this documentation it is possible like this: ogr2ogr -f couchdb ...
0
votes
1answer
31 views

ogr2ogr - Looping through files in a folder on a Mac

I am attempting to use OGR2ORG on Mac OS X to loop through 30 shapefiles, change their projection and save the files into a new directory. I am new to using Macs and the OGR2OGR command line ...
0
votes
0answers
33 views

How can you calculate the union/merge two polygons in ogr2ogr?

I want to calculate the union/merge two overlapping polygons using ogr2ogr (as I have 300+ to do). I want the output to be the same as you would get if you used the 'Merge shapefiles to one' command ...
3
votes
1answer
25 views

ogr2gui geojson to csv do not export coordinates

I tried to convert ogr2gui to convert geojson files to csv. The geojson file contains point data only. The resulting csv only contains attribute data, no coordinates. Is there a way to get the ...
0
votes
1answer
31 views

ogr2ogr: How to get center point of line?

How to get the center point of a line using ogr2ogr command line? I am unable to get a proper script to get this work.
0
votes
1answer
52 views

Why do I get an error when I try and clip a shapefile to a shapefile using ogr2ogr?

I want to clip a shapefile to a shapefile. The input shapefile is a 1 m vector grid generated in QGIS. The tile I'm clipping to is just a simple polygon (the geometry is contained within the 1 m ...
1
vote
1answer
33 views

Will ogr2ogr correctly merge features from several OSM files to resulting set

In GDAL >= 1.10, ogr2ogr contains osm driver I want to try this feature and migrate OSM to PostGIS (I'm aware of osm2pqsql existence) I have several relatively small OSM files and wonder if ...
1
vote
2answers
57 views

Convert shapefiles from WGS84 to Miller Projection

I have some shapefiles of the world from Natural Earth at WGS84. I would like to convert them to the Miller Projection. I have ogr2ogr, but I'm not sure what the parameters for this conversion ...
0
votes
1answer
32 views

Add GPX files to postgreSQL database and add one column with a given value

I already found out how to add a gpx track information into my postgres database: `ogr2ogr -append -f PostgreSQL "PG:dbname=your_db user=xxxx password=yyyy" filename.gpx` Everything works fine but ...
0
votes
0answers
54 views

Export GeoJSON to MSSQL with UTF-8 encoding

I'm testing this command to migrate GeoJSON data to MSSQL table: ogr2ogr -f MSSQLSpatial "MSSQL:server=.\SQLEXPRESS;database=geodb;trusted_connection=yes" test.json -nln test It works beautifully, ...
0
votes
1answer
66 views

How to dissolve naturalearth vectordata with gdal?

trying to use the workflow described by @aflaciano at How to render area that crosses 180°? I did the following: 1) downloaded and installed gdal-111-1600-x64-core.msi from ...
1
vote
3answers
105 views

Dismiss invalid Polygons in PostGIS

I Have a massive Dataset from OpenStreetMap and imported it into a Postgres-Database using ogr2ogr. I got several warnings during this process because of multipolygons with too little vertices. Now I ...
1
vote
2answers
61 views

How to align/georeference distorted vector layers in QGIS?

I've got a shapefile which has been digitized from a strongly distorted historical map, and would like to align it as nicely as possible to another precise shapefile layer. The transformation must ...
2
votes
2answers
99 views

Error exporting data from Oracle to shp using ogr2ogr

I have an oracle table which I would like to query/make a selection. I would then like to export the selection to a shp file. I'm using gdal and ogr2ogr. Following the guidelines here and here I ...
1
vote
2answers
109 views

PostGIS to GeoJSON with GDAL: how to get lat/longs?

I'm trying to convert line features from PostGIS to GeoJSON files, as follows: from psycopg2 import * from subprocess import call conn = connect(dbname='gis') cur=conn.cursor() cur.execute("SELECT ...
0
votes
1answer
165 views

ogr2ogr : Converting KML to GeoJson

I have a requirement convert .HML file to GeoJSON or JSON. Can you please recommend open source command line tools on GNU/Linux(2.6.32-358.14.1.el6.x86_64)? I have installed gdal, I am getting beloow ...
1
vote
1answer
74 views

How to call ogr2ogr from command line with Python 2.7 from ArcGIS 10.2 for Desktop?

I am trying to access ogr2ogr in the command line, and this is the message I receive: 'ogr2ogr' is not recognized as an internal or external command, operable program or batch file. This is ...
0
votes
1answer
52 views

Import non spatial data into SQL Server using ogr2ogr

I am trying to import a CSV files in to SQL Server 2012 using ogr2ogr. The spatial data imports without any problems, but I cannot work out why the non spatial tables fail. I can import the data using ...
0
votes
1answer
48 views

ogr2ogr from MIF to KML including MID generating split kmls

I have a set of MIF and MID files that I would like to translate to KML. I used ogr2ogr to transform the MIF into one big KML which worked ok like so: ogr2ogr -f "KML" geo-kml geo-mif I have two ...
1
vote
1answer
64 views

Reproject CSV file to different projecton using ogr2ogr

I have a CSV file "visivisi.csv" with two columns "x,y" which is in my country local projection. The proj4 line is +proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 ...
0
votes
1answer
92 views

GDal problem “no suitable image found” when I run “ogr2ogr” command

I am trying to run "ogr2ogr" command macbook$ sudo ogr2ogr -f "PostgreSQL" PG:"dbname=test user=postgres" /Users/macbook/planning.gdb But I am getting this error: dyld: Library not loaded: ...
0
votes
0answers
18 views

GDal problem: “Unable to open datasource” when I run “ogr2ogr” command [duplicate]

I am trying to load gdb file to postgis, I created a database "test", then run a command using "ogr2ogr". sudo ogr2ogr -f "PostgreSQL" PG:"dbname=test user=postgres" planning.gdb FAILURE: Unable to ...
1
vote
2answers
42 views

ogr2ogr MIF to KML fails on writing kml in linux

I have a bunch of MIF files which I would like to translate to KML format. ogr2ogr -f "KML" geo-mif geo-kml FAILURE: Unable to open datasource `geo-kml' with the following drivers. seems that ...
1
vote
1answer
67 views

Load data to exists table with ogr2ogr

Could I load spatial data to Oracle when table structure was created before this step? Specifically I have problem with default name of attribute OGR_FID . If my primary key has different name, I ...
2
votes
2answers
74 views

How to save python ogr2ogr shapefile to memory, and stream to web client as zip

I'm trying to accomplish something similar to the site http://ogre.adc4gis.com/ I want to be able to manipulate a geojson file, and send it to the client as a shapefile, in a single zip file. I'm ...
0
votes
1answer
38 views

How do I use ogr2ogr with python GDAL? [duplicate]

I've just installed GDAL, but I don't know how to import/use ogr2ogr. I've tried: from osgeo import gdal from osgeo import ogr and searched both for ogr2ogr, but it wasn't there.
0
votes
0answers
17 views

converting from JSON to Shape files [duplicate]

I have a quick question about converting JSON to Shapefile. I'm trying to convert multiple polygon geometry JSON files into a single shape file and I'm not sure what kind of json this is ?[I'm ...
1
vote
0answers
26 views

ogr2ogr giving “ERROR 1: Failed connect to 192.168.4.18:8181; Operation timed out” error?

This is my command, which was working OK yesterday: ogr2ogr -f "GeoJSON" ../geojson/myfile.geojson ../data/gml/myfile.gml -s_srs EPSG:27700 -t_srs EPSG:4326 The output is this: ERROR 1: Failed ...
0
votes
2answers
48 views

Is there any way to use open source tools to make sure that lines on a map dont overlap?

I am a generalist developer getting the hang of basic gis. I made this geojson map by clipping and converting different shapefiles. The problem is that the precincts of New Orleans extend into the ...
0
votes
0answers
40 views

How to use ogr2ogr to remove features from a shapefile using sql statements (Unable to open datasource `action/North' with the following drivers.)

OK, I've spent the obligatory 15-25 minutes on this and haven't gotten anywhere so, here's the command I'm trying to get to work right now: ogr2ogr -f "ESRI Shapefile" -where "area > 4000" ...
1
vote
1answer
75 views

ogr2ogr/python overwrite PostGIS table

Using ogr2ogr command line I can overwrite or append to an existing PostGIS table like: ogr2ogr -f "PostgreSQL"-overwrite PG:"host=myserver port=54321 user=user dbname=mydbname password=mypassword" ...
1
vote
1answer
34 views

How can I see the layers in an .OSM file?

I have an osm file. I am trying to convert it to geojson with ogr2ogr. I get an error that ogr2ogr can't handle multiple layers. How can I tell what layers are in the file and remove them? I see from ...
3
votes
1answer
44 views

How can you prevent ogr2ogr from truncating trailing zeros when setting coordinate_precision=0 and saving to GeoJSON?

This weekend I started using ogr2ogr and discovered that it's a great tool for converting from one spatial reference system to another. I used it to convert a shapefile to GeoJSON, from WGS84 to a ...
2
votes
1answer
162 views

Converting JSON/GeoJSON files to Shapefiles

I have a quick question please about converting JSON/GeoJSON files. I'm trying to convert some JSON files into something I know how to work with (shapefile, R objects or PostGIS). I'm afraid I have ...
0
votes
1answer
78 views

ogr2ogr GeoJSON GeometryCollection

All, I have a Postgres/PostGIS DB with two geometries in a single table. I want to export them as a GeoJSON GeometryCollection (see here) but I can't seem to get the GEOMETRY_AS_COLLECTION layer ...
4
votes
1answer
113 views

How do I teach ogr2ogr about a projection?

I have JSON generated from ArcGIS that I want to convert to GeoJSON in EPSG 4326. This fails: $ ogr2ogr -f GeoJSON -t_srs EPSG:4326 out.geo.json in.arcgis.json OGRGeoJSON ERROR 6: EPSG PCS/GCS code ...
2
votes
1answer
368 views

Converting multilayer KML files to GeoJSON using ogr2ogr

I have a kml file that I'm trying to convert to GeoJSON. However, it turns out there's multiple layers, and ogr2ogr isn't happy. $ ogr2ogr -f GeoJSON shapes.json shapes.kml ERROR 6: GeoJSON driver ...
1
vote
1answer
73 views

How to Set the Vertical Coordinate system when creating 3D Shapefile?

I have data of wells in CSV format, which I'm converting to a 3D shapefile, using ogr2ogr. The latitude and longitude are in WGS84, while the depth is from the WGS84 geoid. I have the OSGeo4W ...
1
vote
1answer
56 views

If using ogr2ogr to load a PostGIS DB, does the PG string need host and port arguments?

The ogr2ogr command in this question How to Import ESRI Geodatabase format .gdb into PostGIS was missing the host and port arguments, or so I thought. My answer included something like this ogr2ogr ...
0
votes
1answer
249 views

Will MapInfo only read PostGIS data that has been loaded via EasyLoader?

NMZ says in this thread that MapInfo will only read data in PostGIS that has been loaded by MapInfo's EasyLoader. I wasn't sure if this was still the case so I've loaded data into postgis via ogr2ogr ...
1
vote
1answer
78 views

Lost relation when importing from OSM to PostgreSQL with ogr2ogr

I am currently trying to import all administrative boundaries (countries, states, cities, etc) from OSM. I downloaded a small file from Geofabrik (Corsica), in order to run my tests. I understand ...
1
vote
1answer
135 views

In Ogr2OGR: what is SRS?

I am trying to understand this command: ogr2ogr -f "MapInfo File" original.tab wgs84.shp -s_srs EPSG:27700 -t_srs EPSG:4326 I don't understand the s_srs and t_srs paramaters. The help file says ...
1
vote
1answer
210 views

Merge multiple geometry type TAB files in QGIS/OGR

I have a number of vector layers with all types of geometry (point, line/multiline, poly) and I want to combine them into a single layer in QGIS. I know MapInfo can do it but with the other 99% of my ...
1
vote
1answer
88 views

Aggregate/dissolve MySQL geometry

On Centos, I have a MySQL 5 database with a MyISAM table that has a geometry column with a spatial index, containing US county boundaries. Trying to combine/aggregate/dissolve some of these into as ...
1
vote
2answers
288 views

Dissolve/aggregate polygons with ogr2ogr or gpc?

I have a large number of polygons representing the boundaries of US counties which I need to merge into as few polygons as possible. Is it possible to do this with non-commercial software, or ...
1
vote
2answers
65 views

Which format to choose to convert to ShapeFiles?

Given the following format options: all.json, all.xml, all.xls, all.csv, all.kml, all.gjson Which one is the best/easiest to convert the data into standard ERSI Shapefiles which contains the ...
0
votes
0answers
37 views

ESRI 3D generate file format to ShapeZ

Can GDAL (ogr2ogr) convert ESRI 3D generate file format (class PointZ, LineZ and PolylineZ) to 3D Shapefiles? The format description can be found here: 3D Formats information. The PolylineZ format ...
1
vote
1answer
130 views

Python ogr2ogr language character encoding

In python script i'm exporting .shp files to .csv/.gpx/.kml import ogr, ogr2ogr ... ogr2ogr.main(["","-f", "CSV", csvfile, shpfile, "-lco", "GEOMETRY=AS_WKT", "-lco", "SEPARATOR=SEMICOLON"]) ...