Questions tagged [ogr2ogr]
ogr2ogr is an open source command line utility popular for converting to and from various vector spatial data formats.
1,114
questions
1
vote
1
answer
21
views
How to download complete dataset through OAPIF using ogr2ogr?
The National Land Survey of Finland provides data on cadastral parcels using the OGC API - Features system. To list the available datasets, I do:
KEY=example-api-key
URL=avoin-paikkatieto....
2
votes
1
answer
94
views
How to replicate QGIS's Identify Features functionality with ogr2ogr when downloading data from WFS endpoint?
I am working with this WFS endpoint:
https://wxs-gpu.mongeoportail.ign.fr/externe/39wtxmgtn23okfbbs1al2lz3/wfs
In QGIS, I do: Layer -> Add Layer -> Add WFS Layer..., then add the above endpoint. ...
0
votes
1
answer
27
views
Joining CSV to gpkg file with ogr2ogr: 'no such table' error
I'm trying to follow the accepted solution from this post: Join CSV file to shapefile using gdal/ogr
But I keep getting the error "no such table". My CSV does in fact exist. Can somebody ...
0
votes
1
answer
23
views
Convert Canadian census subdivision polygons to WKT (4326) using ogr2ogr?
We've got a large dataset that is in 4326. I'd like to integrate Canadian CSD data from the statcan website into it. But the polygons are in a coordinate system that I don't recognize. Probably Canvec ...
0
votes
1
answer
29
views
Buffer lines using ogr2ogr
I'm trying to create a contour around polygons. I already managed to convert the polygons to lines and now I am trying to use SQLite and the ogr2ogr command to give them thickness. From online ...
0
votes
1
answer
26
views
Why .ToString, Or .STAsText() keeps returning geographies instead of strings
The question underlines the specific issue, but here's some context.
I'm trying to get the closest distance to each point between a set of points and polygons in SQL. The points are just lat/long of ...
2
votes
1
answer
43
views
"Unable to find driver `MSSQLSpatial'" with ogr2ogr in Windows
I am trying to import an ESRI shape file into SQL Server 2019 under Windows 11.
I have a problem similar to Attempting to use ogr2ogr to convert shapefile to SQL Server table; getting error "...
3
votes
2
answers
47
views
Clipping a multipolygon shapefile with another multipolygon shapefile with Python
I have two multipolygon shapefiles. The smaller shapefile is contains polygons that represent water areas during a flood. The larger shapefile is of permanent water bodies for a larger area. I would ...
0
votes
0
answers
31
views
How can I convert a GML with multiple layers to a GeoJSON and store layer name in FeatureType property?
I have a GML file that has multiple layers and I want to convert it to GeoJSON. Apparently, GeoJSON cannot handle multiple layers explicitly. Thus, I want to store the layer name in a property called ...
-1
votes
1
answer
42
views
How to merge two *.gml files with different geometry types into one gml file
I have two gml files one contains linear data and the other one contains polygon data. I want to have the correct ogr command to merge the two gml files into one file.
I found this answer from 2012 ...
3
votes
1
answer
70
views
Specify a PostgreSQL field name with a dash in its name in ogr2ogr
Using ogr2ogr to import a GeoPackage to a PostGIS database, I want to cast a field to another type, using -lco COLUMN_TYPES=
The field name, however has a dash in it's name. I tried:
-lco ...
1
vote
1
answer
33
views
Using ogr2ogr how to set WKT format of .prj file?
I create a shapefile using this ogr2ogr command:
ogr2ogr -f "ESRI Shapefile" -overwrite -a_srs EPSG:28992 -explodecollections \
-makevalid "Clipped.shp" "org.shp" -...
1
vote
0
answers
40
views
Unreadable text when converting .SHP to .CSV
I am trying to convert .SHP file to .CSV using ogr2ogr in QGIS and I also have all the associated files related to the .SHP files. The text in the .SHP file is in Ukrainian and after the conversion, ...
0
votes
1
answer
73
views
Convert multipolygon to polygon with holes using ST_MakePolygon and ogr2ogr
I have a shapefile that is exported by Surfer. This shapefile is invalid and has 3 polygons. 1 large polygon and two smaller ones. The smaller ones lay on top of the large one, instead of in the large ...
0
votes
1
answer
80
views
OSM conversion to SQLite - "Non closed ring detected."
For years I have pulled Open StreetMap datasets from Geofabrik and converted them to SQLite for use within QGIS. Until now, I've had no problem using the following in the OSGeo4W Shell window:
ogr2ogr ...
0
votes
0
answers
35
views
Problem with OSM relation:restriction when mapping OSM data to GeoJSON
In OSM are mapped some restrictions, as for example turn restrictions. These are applied to specific node and to at least an origin linestring (from) and a destination linestring (to).
I used ogr2ogr ...
1
vote
1
answer
76
views
Python GDAL-OSGEO library: shapefile to PostGIS?
I'm working on a Python script which needs to use the gdal python module, and not the subprocess call method.
I've been using this, but I can't find any example or good documentation online about how ...
1
vote
1
answer
62
views
Converting DXF to shapefile with custom attributes (color)
I am trying to convert .dxf to .shp with passing color attribute to entities in .shp. When using
ogrinfo -al test.dxf
I can see colors for line and text features:
OGRFeature(entities):13
Layer (...
0
votes
2
answers
69
views
ogr2ogr cannot open datasource ogrinfo can open
I've got a random .osm.pbf from Geofabrik which I'm trying to extract a small region of:
$ ogr2ogr -f OSM -spat 7 48 8 49 data/osm/extract.osm.pbf data/osm/germany-latest.osm.pbf
ERROR 1: OSM driver ...
0
votes
0
answers
61
views
ogr2ogr PostgreSQL installation without PostgreSQL driver (Windows). Why and how to change path to OSGeo installation
I'm trying to import a shapefile into my PostGIS database with ogr2ogr on Windows.
Running the command ogr2ogr -f PostgreSQL PG:"dbname=database host=localhost user=postgres port=5432" ...
3
votes
1
answer
175
views
ogr2ogr: -clipsrc or -clipdst?
I am trying to replace a naïve bounding box clip when I download data for a study area using ogr2ogr, to one that uses a study area layer with an actual geometry.
ogr2ogr supports both -clipdst and -...
0
votes
1
answer
70
views
Exporting from PostGIS views to gpkg with GDAL (ogr2ogr)
I have successfully exported more than 11.000 PostGIS views to geopackages. I use the GDAL command line for this with ogr2ogr along with GNU parallel for parallel processing. However, for some reason, ...
0
votes
1
answer
101
views
How to download WFS data using ogr2ogr?
My plan is to download data from a WFS (https://www.wfs.nrw.de/geobasis/wfs_nw_alkis_nas-konform?VERSION=2.0.0&SERVICE=WFS&REQUEST=GetCapabilities) and to convert it to GeoJSON using ogr2ogr.
...
0
votes
1
answer
58
views
How to remove the first header line when creating a csv with ogr2ogr?
I use the great approach to large rasters as described here
gdaltindex an_index.shp *.tif
ogr2ogr -f CSV list.csv an_index.shp -spat xmin ymin xmax ymax
gdalbuildvrt -input_file_list list.csv mosaic....
1
vote
1
answer
101
views
Using ogr2ogr (or another vector program) to add field domains to existing file geodatabase
In the FileGDB vector driver documentation, it states that writing support has been added in GDAL 3.5 for field domains. However, it isn't documented how to do so.
For context, I am working on a .gdb ...
2
votes
1
answer
52
views
How to import GeoPackage with ogr2ogr to existing PostgreSQL table with integer PK?
I'm encountering an error Null value in column violates not-null constraint while using the ogr2ogr command to import a GeoPackage into a PostgreSQL table named prj.viewshed_local.
The prj....
1
vote
1
answer
38
views
Using gml:FeatureCollection / gml:featureMember in GMLAS driver via ogr2ogr
Does anyone know how to force the use of the gml:FeatureCollection and gml:featureMember prefixes instead wfs:FeatureCollection and wfs:member, when exporting gml via ogr2ogr using GMLAS driver....
1
vote
1
answer
155
views
Geometry extraction from osm.pbf file using relation id with ogr2ogr
What works
If I need a GeoJSON file with the OpenStreetMap borders of Liechtenstein, I download liechtenstein-latest.osm.pbf from GeoFabrik:
curl https://download.geofabrik.de/europe/liechtenstein-...
1
vote
1
answer
38
views
Get the same behaviour as the 'Difference tool' of QGIS, in ogr2ogr
I have shapefile with lines, and another with polygons. I want to generate an output of those lines that are not covered by any polygon.
I can perfectly do this in QGIS's Difference tool, but want to ...
3
votes
1
answer
87
views
Creating Linestring from GPX file with M coordinate as time
I have several GPX files that I'm trying to load into a PostGIS table, with the goal of map-matching them (I intend to use pgMapMatch but open to other services I can run on my own machine). ...
7
votes
1
answer
225
views
ogr2ogr CSV to PostGIS, cast columns as text
I'm trying to import a CSV file to PostGIS with a subset of columns and cast all columns to the correct data type:
C:\OSGeo4W\bin\ogr2ogr.exe -f "PostgreSQL" "PG: host=localhost user=...
0
votes
1
answer
21
views
How defining feature "name"-tag to a integer attribute when executing ogr2ogr
I'd like to store a PostgrSQL/PostGIS table as a KML-file with the feature -tag as the value of the integer attribute "count". My procedure works when I point the env.variabe ...
3
votes
1
answer
71
views
Chain the output of gdal_polygonize to ogr2ogr
I am doing a two step process:
Polygonize a PNG raster via gdal_polygonize.py
Add a custom field named id
Upload the resulting vector to PostGIS via ogr2ogr
I am currently doing it in two steps, ...
4
votes
1
answer
211
views
SQL functions supported by ogr2ogr
I have a GeoJSON, test.geojson:
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { }, "geometry": { ...
0
votes
1
answer
59
views
How reduce file size of GPX files with GDAL OGR2OGR?
I want to reduce the file size of some gpx files with gdal ogr2ogr.
When I use simplify like the following command in Mac Terminal the file size does not really shrink:
ogr2ogr -simplify 0.00001 ...
1
vote
1
answer
59
views
ogr2ogr SQLite and json_each, filtering using WHERE does not work
using ogr2ogr I want to process a geojson file that has a JSON field (see minimal file below).
I tried the following command to extract the description corresponding to group a from the JSON field:
...
0
votes
1
answer
54
views
Ogr2Ogr appending duplicate records (2X Times) to PostgreSQL Table
I'm synchronizing data from AmigoCloud's table with a PostgreSQL table.
I'm using GDAL's ogr2ogr module in osgeo environment. The command I'm running is as follows:
ogr2ogr -append -f PostgreSQL PG:&...
3
votes
1
answer
134
views
ogr2ogr: Make polygon from points
I have a set of points in a csv file like this (ie. a square):
-77.63333333;-11.75
-77.63333333;-12.25
-77.3;-12.25
-77.3;-11.75
-77.63333333;-11.75
-77.63333333;-11.75
After getting rid of the semi-...
0
votes
1
answer
129
views
Setting different GDAL configuration folder when calling ogr2ogr with Python subprocess
I'm trying to access a web resource through the Python subprocess module and ogr2ogr/ogrinfo.
When calling ogr through the command line, everything works fine.
When calling with subprocess I have an ...
0
votes
0
answers
39
views
Create shapefiles with GDAL and Android studio Warning error on shapefiles created in projection WGS_1984_UTM_Zone_18S
This is my method that creates the shapefile, but the file gets a warning when opened in ArcMap:
The added layers have an extension that is not consistent with the associated spatial reference ...
4
votes
1
answer
119
views
Failing reprojecting from EPSG 4326 to EPSG 3857
I am trying to reproject a CSV file from EPSG:4326 (WGS84 lat/long points) to EPSG:3857 (Web Mercator in meters).
Here is my command:
ogr2ogr -f CSV -overwrite -s_srs EPSG:4326 -t_srs EPSG:3857 Output....
1
vote
1
answer
50
views
ogr2ogr output missing some relations
I'm trying to extract data from planet.osm.pbf with osmium and ogr2ogr as a CSV file. However some relations seem to be missing in the output. For example, this relation doesn't show up as a ...
1
vote
1
answer
139
views
OGR Field Types to FileGDB
I am trying to convert from PostGIS to FileGDB using GDAL (ogr2ogr). One of my fields is an integer field and declared in PostGIS as an int4. However when I do a standard ogr2ogr export looking at the ...
3
votes
1
answer
122
views
'LOWER' function for ogr2ogr?
As part of an ogr2ogr operation, I would like to select a string property in its lowercase form.
Sample geojson:
{
"type": "FeatureCollection",
"name": "...
1
vote
0
answers
93
views
Create DXF file with ogr2ogr, that is visualized in AutoCAD
with ogr2ogr I try to create a DXF file, that is labeled and visualized in AutoCAD directly.
What I did to visualize point objects:
ogr2ogr --config GDAL_DATA "X:\OSGeo4W64\share\gdal" -f &...
1
vote
1
answer
142
views
Use ogr2ogr/ogrinfo to connect to MSSQL on Ubuntu Server
OS: Ubuntu Server 20.04; Software: GDAL/QGIS, ogr2ogr/ogrinfo
My goal is to use ogr to pull data from MSSQL as part of a longer process that I'm working on.
First step is to test out the connection ...
1
vote
2
answers
183
views
ogr2ogr can't find my layer's CRS
I'm running the following command in an effort to convert the shapelayer in the screenshot below to valid WGS84 GeoJSON:
ogr2ogr mhp_ada.geojson -s_srs EPSG:102459 -t_srs EPSG:4326 mobiles.shp
And ...
1
vote
0
answers
74
views
Y coordinate of mbtiles is in descending order (tippecanoe, ogr2ogr)
I want to convert a geojson to MVT and upload it to s3 to use it with Mapbox GLJS.
I tried this tutorial https://geovation.github.io/tippecanoe-directory-support.
With tippecanoe --no-feature-limit --...
0
votes
0
answers
138
views
How to set SRID of the geometry attribute of GeoServer layer (automatically or through code), instead of -1 default value
Because of my problem with spatial queries (INTERSECTS) not working properly on a layer with SRID = -1 created with ogr2ogr - I need to force SRID of the geometry attribute of the layer to be ...
0
votes
0
answers
135
views
No geometry passed when importing shapefile to database with ogr2ogr (QGIS)
I am trying to import a shapefile with the ogr2ogr command into my PostgreSQL database. Unfortunately it does import the attributes, but without the geometry.
This is my command:
ogr2ogr -update -...