Questions tagged [ogr2ogr]

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

225 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
117 views

Preventing ogr2ogr from generating invalid geometries in transformation

I have the following GeoPackage: https://drive.google.com/open?id=1COcGcbZQIsW6NrzuD-K-Kijpvg4BYQ54 I have checked it with spatialite and it does not have invalid geometries. It has a ...
5
votes
0answers
920 views

How do I clip Geojson FeatureCollection with another Geojson polygon

I have a GeoJSON file that contains one FeatureCollection with a bunch of features that are polygons. I also have the boundary of the continental USA in another GeoJSON file. I'd like to clip the ...
4
votes
0answers
122 views

ogr2ogr creates too many columns with LEFT JOIN

I am creating a GeoPackage using several shapefiles using ogr2ogr (GDAL 2.2.4): ogr2ogr -f GPKG /path/to/out.gpkg -append -nln out -a_srs EPSG:4326 /path/to/in1.shp ogr2ogr -f GPKG /path/to/out.gpkg -...
4
votes
0answers
1k views

How to clip a big shapefile from another shapefile's extent

I am working on mangroves in Sundarbans (Bangladesh / India), using Landsat pictures. I need to equalize them in reflectance, before classification, for the evolution of the biomass in this region. I ...
4
votes
0answers
2k views

Ogr2ogr: Unable to open datasource problem

I downloaded the Precints shapefile from the City of Boston's data hub, and I'm trying import it into SQLServer (I'm running the Express verson). I've already created the database in the SQLServer (...
3
votes
0answers
107 views

QGIS 3.18 Reprojections result in wrong projection - EPSG 32754 instead of 7854

When I run a QGIS processing tool that includes a new projection, the result is not correctly projected. Instead of EPSG::7854 (GDA2020 / MGA 54), the data ends up with EPSG::32754 (WGS 84 / UTM 54 ...
3
votes
0answers
60 views

Getting the results of a PostGIS query to a file with ogr2ogr with low memory usage

I have a PostGIS query returning geographies and attributes. The result set is deterministic and ordered (so OFFSET and LIMIT work for getting subsets). The result set of my query would exceed my RAM ...
3
votes
0answers
113 views

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 ...
3
votes
0answers
384 views

Correct syntax for specifying multiple Layer Creation Options in ogr2ogr

I am trying to run a GDAL 300 command line command to convert a file to GeoJSONSeq, projecting output using ESRI:102008 (Albers North America), using a SQL query to choose and rename some columns, and ...
3
votes
0answers
1k views

Converting GeoJSON file to vector tiles

I need to display huge GeoJSON file using OpenLayers. So I decided to use VectorTiles. Library geojson-vt.js works perfectly for me, but unfortunately it requires my GeoJSON file to be preloaded on ...
3
votes
0answers
247 views

ogr2ogr styling of KML point features

Using ogr2ogr I want to export tables from a PostGIS database as KML-files. I have succesfully used an "OGR_STYLE"-column/attribute on my line features to define line width and color, see: http://www....
3
votes
0answers
598 views

ogr2ogr{gdalUtils} correct syntax to set Ground Control Points for vector georeferencing

I would like to know correct syntax of R {gdalUtils} package (version 2.0.1.7) to georeference Shapefiles using corner points as GCPs. (These Shapefiles have y=height and x=width information, without ...
3
votes
0answers
352 views

Setting top-level GeoJSON id using ogr2ogr?

I'd like to write the contents of a PostGIS table (or query) to GeoJSON using ogr2ogr. How can I select an attribute and have it be used as a top-level id in the output GeoJSON, without losing it ...
3
votes
0answers
649 views

ogr2ogr imports GML data (not from OSM) to Postgis but without the other_tags "hstore"-column

The problem I'm encountering some issue trying to use ogr2ogr to import some GML input data (not OSM) into Postgres. I'm trying to use COLUMN_TYPES=other_tags=hstore to store all the fields not ...
3
votes
0answers
689 views

Dissolving polygons in a large dataset

I need to dissolve polygons by the ID attribute in a large dataset (+-1gb shapefile). I have been struggling to find an efficient method to do this. I have tried the following methods: Postgis ...
3
votes
0answers
150 views

Reverse clip with ogr2ogr

I'm fairly new to GIS, working on a project where I overlay counties on google maps, and overlay cities on top. I'm using fusion tables, and running into Z-index issues. To get around this I'm hoping ...
3
votes
0answers
730 views

How can you calculate the union/merge two polygons with 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
0answers
484 views

How to convert shapefile to mapinfo file preserving special characters?

I have to convert a bunch of shapefiles to mapinfo files on a machine without a MapInfo license, so I am using ogr2ogr to perform this task. The problem is that when opening the mapinfo files in ...
2
votes
0answers
123 views

"Failed to process SRS definition" error when reprojecting vector layer via ogr2ogr

I'm using GDAL 3.3.1 with all the necessary variables already setup. I'm reprojecting a vector layer using ogr2ogr ogr2ogr -t_srs EPSG:32651 test.shp new_layer.shp and an error says ERROR 1: PROJ: ...
2
votes
0answers
40 views

Using ogr2ogr to convert Natural Earth data to Polar Stereographic projection

I’m trying to build some maps of the North Pole area for my website. I’ve flown over it a few times and want to make a map of the flight paths I took. As you can see, a normal Mapbox map doesn't look ...
2
votes
0answers
265 views

Convert a mbtiles tileset folder into a single .mbtiles SQLite file?

I have a root tileset folder structured with the standard tiling scheme /tileset/{Z}/{X}/{Y}.pbf. When I try using GDAL, I think I miss something: $ ogr2ogr -f MVT sqlite.mbtiles ./tileset FAILURE: ...
2
votes
0answers
37 views

Save point KML with ogr2ogr

So I have a KML file (it contains a point): <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Folder> <...
2
votes
0answers
52 views

Is it possible to prevent ogr2ogr from generating a shapefile if no records are returned from the given intersection?

I am generating shapefiles from a geodatabase file with ogr2ogr via the spatialite dialect using the following command: ogr2ogr -f "ESRI Shapefile" ./clipped.shp -dialect sqlite -sql "...
2
votes
1answer
429 views

Export PostGIS data from one database to another with multiple geometry fields (ogr2ogr)

I am trying to copy the data from one database to another database. Both the source and target tables have 2 geometry columns -- a polygon field and a point field. There are NOT NULL constraints on ...
2
votes
1answer
52 views

KML driver failed to create

I want to convert spatial data from postgres to some basic formats (shp, geopackage, csv, xlsx, gml... ) using python gdal functionality. I read the answer to this question: Using ogr2ogr to convert ...
2
votes
0answers
82 views

ogr2ogr sql query from dbf

In ogr2ogr, I can successfully read *.DBF files and write them to PostgreSQL DB: SET DBCONNECT=host=bla port=blue dbname=blub user=me password=easy active_schema=now SET PGCLIENTENCODING=UTF8 SET ...
2
votes
0answers
192 views

How to correctly append data from ArcInfo GENERATE file to PostGIS table using ogr2ogr

Using CentOS 8.0 with PostgreSQL 12, PostGIS 3, and GDAL/OGR 3.0.2. I am trying to append data in an ArcInfo GENERATE file to an exisiting table. My ArcInfo GENERATE file input.gen looks like this: ...
2
votes
1answer
137 views

Converting PBF to Shapefile with name:xx tags as a column in the attributes

I have a PBF file containing only rivers information (extracted using osmosis when waterway=river). A conversion of this PBF to SHP works fine with ogr2ogr when I am selecting fields like "osm_id" ...
2
votes
1answer
200 views

ogr2ogr append to PostGIS table with PRIMARY KEY -fieldmap: Invalid destination field index 0

I have the following PostgreSQL/PostGIS table CREATE TABLE schema.table ( id bigint NOT NULL CONSTRAINT id_pkey PRIMARY KEY, geog geography NOT NULL ); and an ARCGEN file file.gen ...
2
votes
0answers
113 views

Running ogr2ogr script batchfile from SQL fails due to temporary drive mapping

I am trying to run the SQL procedure EXEC xp_CMDShell 'blahblah.bat' which needs to run an ogr2ogr script to create a kml from sql. The batch file works if I run it alone but with SQL permissions it ...
2
votes
0answers
680 views

Importing SHP to MSSQL using OGR2OGR?

I am trying to import a Shapefile which is in EPSG:4326 coordinates to MSSQL Database but its failing. I am following the below command: ogr2ogr -f MSSQLSpatial -overwrite "MSSQL:server=...
2
votes
0answers
173 views

ogr2ogr missing OSM features

I am wondering why ogr2ogr is dropping certain features when exporting to GeoJSON and how to change this behavior. In the following picture, all the features extracted by ogr2ogr are coded in ...
2
votes
0answers
40 views

Load shapefile in PostgreSQL with intersection rule

I have one segmentation shapefile vector that I would like to load in a PostgreSQL database. However I need to remove the polygons created in background values of landsat image. Since I have a big ...
2
votes
0answers
342 views

different results ogr2ogr command line vs osgeo import ogr with reading osm data

I am trying to read in openstreetmap data (osm.pbf) files into python. Initially, I've always used the ogr2ogr command line approach to convert the data I want from the osm.pbf to a shapefile and then ...
2
votes
0answers
171 views

create am Empty GDB using ogr2ogr

I guess no one has not asked this question yet. Let's say if I want to store my CSV to GDB feature table then the code below works just fine ogr2ogr -f "filegdb" test.gdb my.csv and I thought just ...
2
votes
0answers
86 views

Importing Shapefile into PostGIS and EPSG of created table is different from Shapefile?

I'm trying to import a Shapefile into PostGIS using the ogr2ogr, but it seems that the OGR is not automatically getting the EPSG from Shapefile. My Shapefile has EPSG 4618, but the table created by ...
2
votes
0answers
155 views

Merge ("dissolve") OSM LineStrings from GeoJSON with ST_UNION

I would like to merge the continuous LineStrings from a GeoJSON export of an OpenStreetMap relation (get from Overpass Turbo): "geometry": { "type": "LineString", "coordinates": [ In ...
2
votes
0answers
422 views

OGR2OGR EPSG:27700 Shapefile To EPSG:4326 MSSQL Table With Geography

I have been messing around with OGR2OGR for a while now trying to import a shapefile data into an MSSQL table. I am using the OGR2OGR executable that comes packaged with QGIS Wien (GDAL version 1.11.2)...
2
votes
0answers
493 views

Importing GeoJson data to postgresql using ogr2ogr command

I am using following ogr2ogr command to import GeoJson data to Postgres DB. The command runs successfully but the geometry column is null. ogr2ogr -f PostgreSQL PG:"dbname=test user=postgres ...
2
votes
0answers
340 views

How to fix a shapefile reprojected from sinusoidal projection to lat long?

I have been work in convert the MODIS Tiles Grid from sinusoidal projection to lat long projection using python ogr2ogr. It doens't works well, the shapefile reprojected presents some lines that was ...
2
votes
0answers
121 views

Error importing TIGER census block gdb in GDAL

I have downloaded the 2015 Census Block GDB for the entire country from the census website here: https://www.census.gov/geo/maps-data/data/tiger-geodatabases.html. I am facing a problem in that when ...
2
votes
0answers
133 views

gdalwarp crop_to_cutline generates error for some states

I am trying to crop states of a country by using gdalwarp . For some of the states I get this particular error, while for other states it runs fine. This is my second day at GIS/gdalwarp, so please ...
2
votes
0answers
381 views

JOIN on Oracle table and view with PyQGIS

I have a view v and table st with attributes and SDO_GEOMETRY columns in an oracle database. I want to do an LEFT OUTER JOIN a common value with data filtering on the v. SELECT ST.OBJECTID, V.ID_WS, ...
2
votes
0answers
155 views

Create multipolygons grouped by field, ogr2ogr

There is a large polygon data set which I would like to aggregate some of the polygons with the same values in a specific field to multipolygons. I would like to do this using ogr2ogr. I have the ...
2
votes
0answers
418 views

ERROR 1: Error initializing the metadata tables :

I use ogr2ogr (bundled with QGIS 2.14.3) on Windows to convert an ArcSDE MS SQL Server 2012 database with SQL Geometry to PostGIS (2.1.8). I use the following syntax: ogr2ogr --config ...
2
votes
0answers
204 views

import shapefile to postgis with customized projection using ogr2ogr2

I have a shapefile with a customized projection PROJCS["NAD83_Lambert_Conformal_Conic_CN",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["...
2
votes
1answer
387 views

OGR shapefile output fails - Error 1 in psSHP->sHooks.fSeek()

When trying to use ogr2ogr to convert to ESRI Shapefile format, I get the following error consistently across different files: ERROR 1: Error in psSHP->sHooks.FSeek() while writing object to .shp ...
2
votes
0answers
371 views

Using ogr2ogr in python?

I found this helpful post that got me started using ogr2ogr in python: Using ogr2ogr to convert GML to shapefile in Python? as well as this one: Converting ArcGIS Server JSON to GeoJSON? I am trying ...
2
votes
0answers
210 views

Using ogr2ogr for clipping vector files

I am looking for alternative (more efficient) methods for clipping large feature class datasets. When using the 'Clip' tool in ArcGIS, often times the tool will crash after many hours of processing. ...
2
votes
0answers
4k views

ogr2ogr FAILURE: Couldn't fetch requested layer 'ùnlt'!

I am getting the following error message with ogr2ogr while try to convert into MySQL. I have tried PGeo,Shapefile and FileGDB. FAILURE: Couldn't fetch requested layer 'ùnlt'! My environment is ...

1
2 3 4 5