Questions tagged [ogr2ogr]

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

OGR Simple Features Toolkit home page - http://www.gdal.org/ogr/
OGR Utilities page - http://www.gdal.org/ogr_utilities.html
ogr2ogr page - http://www.gdal.org/ogr2ogr.html
ogr2ogr Supported formats page http://www.gdal.org/ogr_formats.html

Also see and .

1166 questions
8
votes
1 answer

Specifying element type for DXF creation using ogr2ogr

I am trying to create a DXF from a Polygon Shapefile using ogr2ogr: ogr2ogr -f DXF parcels.dxf parcels.shp The problem is that the polygons are written as hatch elements. How do I specify that ogr2ogr should create LWPOLYLINE elements (Or any…
Scro
  • 2,258
  • 1
  • 17
  • 22
8
votes
1 answer

Use ogr2ogr to delete content of table and load new data from shapefile

Is it possible to load a shapefile to a PostGIS database by replacing the content of the table with the new content of the shapefile WITHOUT DROPPING the table? I want to do this using ogr2ogr. In the past I have used shp2pgsql, which gives you the…
user1919
  • 2,654
  • 2
  • 30
  • 70
7
votes
1 answer

How to add a progress bar to an ogr2ogr script

We have started using ogr2ogr to upload MapInfo tables into Microsoft SQL server in my workplace. Some of the tables are massive (>1,20,000 records) and there is no way of knowing how far the script has progressed without a status bar. I was…
user20637
  • 71
  • 2
7
votes
2 answers

OGR2OGR from mssql to geopackage

Im trying to export a table from MSSQL to geopackage using ogr2ogr: This is the exact command I try in windows terminal (but with real serv,db,user,pass ofc): C:\OSGeo4W64\bin\ogr2ogr.exe -f "GPKG" C:/GIS/data/testdata/test123.gpkg…
BERA
  • 72,339
  • 13
  • 72
  • 161
7
votes
1 answer

ogr2ogr difference between -append and -update

I wonder what's the difference between the ogr2ogr parameters -append and -update. It seems that they both are used to prevent ogr2ogr from creating a new layer: -append: Append to existing layer instead of creating a new one -update: Open existing…
Thomas B
  • 8,807
  • 1
  • 21
  • 62
6
votes
1 answer

Using ogr2ogr to generate a shapefile from a CSV with multipolygon geometries

I have a CSV file with the following structure: id,Geometry 0,MULTIPOLYGON(((343362.10597 7395133.999035, 343362.608646 7395137.592628, 343366.027235 7395138.714539, 343389.482792 7395141.302312, 343390.91157 7395141.3619, 343408.443301…
raylight
  • 1,241
  • 4
  • 19
6
votes
2 answers

Cast column to integer with ogr2ogr

I use ogr2ogr to import an .sqlite file into my PostgreSQL database. The new database table I get has a column of type "character varying". However I want it be of type integer as all the values in the particular column are integer numbers with the…
Elmex80s
  • 163
  • 4
5
votes
1 answer

Can ogr2ogr be used to append multiple DBF files?

Can ogr2ogr be used to append multiple DBF files? It works with SHP files, but I can't see how to do it with DBF files on their own. It ought to be possible, considering DBF is a subset of SHP.
Uffe Kousgaard
  • 2,543
  • 15
  • 24
5
votes
2 answers

How can I debug hanging `ogr2ogr`?

I downloaded one of files from https://use-land-property-data.service.gov.uk/datasets/inspire/download and I am trying to convert it to some friendlier format with ogr2ogr I tried ogr2ogr -f "ESRI Shapefile" output.shp input.gml but ogr2ogr just…
5
votes
0 answers

Reading files from URL with ogr2ogr

I'm trying to move from downloading geodata manually and then working with it using ogr2ogr on the local file to just reading the data in from the url directly in order to have the actual source in the code and save myself some work. For example…
Hugh_Kelley
  • 747
  • 1
  • 6
  • 19
4
votes
1 answer

ogr2ogr fails with 'no such table'

I have downloaded a shape file of Chicago building footprints from here. Unzipped it and ran ogr2ogr -f csv -dialect sqlite -sql "select AsGeoJSON(geometry) AS geom, * from 'geo_export_98941210-c995-4502-8ebb-93a09f29d615'"…
4
votes
2 answers

ogr2ogr get geojson from map server misses features and creates duplicates

I'm querying this map service using ogr2ogr to create a local copy of it's features: http://geoportal.menlhk.go.id/arcgis/rest/services/KLHK/Deforestasi_2006_2009/MapServer/0 Here's my ogr2ogr code, using where clause objectid > 0 to select…
Sam
  • 116
  • 4
4
votes
1 answer

ogr2ogr difference between -a_srs and -s_srs

What's the difference between the two flags -a_srs and -s_srs. From what I read they both define the EPSG the Input-File has. When using -s_srs ogr2ogr says that -t_srs must be used as well. But when setting -a_srs instead of -s_srs it runs without…
Leo.1906
  • 467
  • 7
  • 16
3
votes
1 answer

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 NAD83 stateplane, and wanted decimals truncated, but…
3
votes
1 answer

Add data inside a shapefile incrementally with ogr2ogr

Let's say I have the two following CSV…
raylight
  • 1,241
  • 4
  • 19
1
2 3 4