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

learn more… | top users | synonyms

6
votes
7answers
5k views

ogr2ogr convert all shapefiles in a directory

I have a directory with several shapefiles. How can convert all these shapefiles to MapInfo with ogr2ogr. I know how I can convert one file. And I can make a batch script writing a line for each file. ...
9
votes
7answers
2k views

How to add field with filename when merging shapefiles with ogr2ogr?

I'm merging some shapefiles and I had some problems doing so inside QGIS, so i'm using ogr2ogr directly. I'm doing this (in a batch): ogr2ogr -overwrite %destination% %n1% ogr2ogr -update -append ...
3
votes
1answer
2k views

How do you open shapefiles with ogr2ogr

I'm following along the D3 tutorial, and on this line: ogr2ogr \ -f GeoJSON \ -where "adm0_a3 IN ('GBR', 'IRL')" \ subunits.json \ ne_10m_admin_0_map_subunits.shp run into the following ...
0
votes
1answer
822 views

How current is GDAL in Java

I have used the ogr2ogr to import various formats to Postgres and have used GDAL utilities. Is there a complete Java port for these tools? Or are they simply wrappers calling JNI to C++ code? I have ...
8
votes
1answer
1k views

GeoJson to ESRI Shapefile using ogr2ogr

I have a GeoJson file that I want to convert to ESRI Shapefile using ogr2ogr in FWTools. I tried using ogr2ogr -F "ESRI Shapefile" filename.shp geojsonfile.json OGRGeoJSON I got output ERROR ...
3
votes
4answers
3k views

How do I use ogr2ogr to convert a GML to shapefile in Python

I am trying to convert a GML to an ESRI shapefile using ogr2ogr utility in a python script. I have successfully installed the GDAL/OGR package via osgeo but I am now struggling to find/understand ...
4
votes
1answer
2k views

How to re-project shapefiles?

I wanted to re-project a QGIS project, but there is no such option. When searching for an answer I see ogr2ogr suggested for this task, by re-projecting each vector layer (shapefile in this example). ...
2
votes
4answers
3k views

How to convert SHP into GPX or JSON?

I would like to convert the tree inventory shape files of London (Canada) into a GPX file and if possible into a JSON file. You can download the archive from their Open Data website. It contains the ...
1
vote
1answer
448 views

How to Import ESRI Geodatabase format .gdb into PostGIS

I ran into a problem when loading a ESRI Geodatabase format .gdb into PostGIS. I have data 2.5GB GDB file. I followed some tutorials on the internet, but it seems that doesn't work out. I created a ...
3
votes
1answer
3k views

Converting kml to shape file via ogr2ogr including all attributes

Here is the example kml file I am using: <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>My Golf Course Example</name> <Placemark> <name>Club ...
2
votes
1answer
298 views

GDAL 1.9.1 ogr2ogr KML to PostGIS not incuding ExtendedData

I have a KML file utilizing a Schema in the document and ExtendedData in each placemark. The ExtendedData does not seem to pass in conversion to PostGIS or shapefile. Any assistance would be much ...
5
votes
2answers
519 views

OGR merge shapefiles of different geom type into a single GeoJSON feature collection

I'd like to merge shapefiles of different geometry types into a single geojson feature collection, but OGR says it doesn't support update of GeoJSON files: $ ogr2ogr -f GeoJSON -t_srs crs:84 -lco ...
3
votes
1answer
824 views

How do I split polygons that cross the dateline?

I have a dataset of country borders which I obtained from: http://thematicmapping.org/downloads/world_borders.php/ I have that dataset in both shp and SQL, but I'll put out there that I don't feel ...
2
votes
3answers
2k views

GDAL 1.10 ogr2ogr OSM “Unable to open datasource”

I have a problem with ogr2ogr and osm file. I install from source (on Ubuntu 12.04.2 LTS) newest GDAL libary and OGR still can't read osm files. gdal-config --version 1.10.0 ogr2ogr --version GDAL ...
2
votes
2answers
1k views

Shapefile to MSSQL with ogr2ogr fails to make connection

I am using ogr2ogr from OSGeo4W on my Windows 7 box to import a shapefile into a SQL Server database on one of my servers. I was able to successfully complete the conversion using shp2sqlserver, but I ...
1
vote
2answers
299 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
500 views

How to change shapefile longitude from -180 - 180 to 0 - 360?

I have a shapefile of world countries, with longitude between -180° and 180°. How can I change the shapefile (eg. with ogr2ogr) for having longitude between 0 and 360°. Following OSGEO/Trac ...
1
vote
1answer
189 views

Multiple input shapefiles for ogr2ogr sqlite spatial operations

I'm running up against an issue doing a spatial operation requiring multiple input shapefiles using ogr2ogr and sqlite. I have: ogr2ogr -f "ESRI Shapefile" output.shp input.shp -dialect sqlite -sql ...
1
vote
2answers
1k views

OGR DXF to KML conversion

I'm trying to convert a DXF 2010 file to KML using ogr2ogr: ogr2ogr -f "KML" outfile.kml infile.dxf In the file, $INSUNITS is 6, that's meters, if I'm correct? The problem is that DXF is not ...
4
votes
2answers
682 views

How to preserve non-ASCII characters in ogr2ogr import?

I want to import a list of international place names and their locations into a SQL Server database using ogr2ogr. The source data is a CSV file encoded in UTF-8. I've prepared a five-record sample ...
4
votes
4answers
2k views

How to convert multipoint layer to point

I have a Spatialite layer which is multipoint (following a QGIS Save As from shapefile). I need it to be PostGIS and POINT. I have tried ogr2ogr -nlt POINT and got 'new row for relation "xxx" violates ...
3
votes
1answer
69 views

New attribute creation using ogr and regex

I've got a folder full of dxf files with elevation values included as part of a long text attribute. I've written a regex expression to extract the elevation value, and would like to add it as a new ...
3
votes
1answer
356 views

ogr2ogr / GDAL remove features in FileGDB while in use by ArcGIS Server map service

I'm using ogr2ogr to pull features out of Oracle and put them into a File GeoDatabase. The FGDB is being used by an active ArcGIS Server map service. This is all done for performance / reducing DB ...
2
votes
1answer
1k views

How to reproject shapefile using ogr2ogr

I have shapefile in EPSG:2834 and I want to reproject it into EPSG:4326. I am trying to use ogr2ogr in Windows; however, I get this failure output: C:\Users\Nik\Desktop\Logan_Lines>ogr2ogr -t_srs ...
1
vote
1answer
484 views

Why does ogr2ogr SHP import error out trying to create a database?

All, Can anyone tell me what the error is with OGR2OGR when trying to import a .SHP into MSSQLSPATIAL? ERROR 1: MSSQL Spatial driver doesn't currently support database creation. Please create ...
1
vote
1answer
467 views

Exporting vector to kml with ogr2ogr without extended data

If I convert a shapefile as kml in QGIS, GRASS or ogr2ogr directly, defining the name and/or description field with the -dsco tag, all columns in the attribute table of the input layer are exported to ...