Skip to main content

Questions tagged [ogr2ogr]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

use ogr2ogr shp to s57 error

I have used ogr2ogr -f "S57" 12345.000 12345.shp -skipfailures --Debug ON, but it fails. The console show: GDAL: Proxy driver FileGDB not registered due to ogr_FileGDB.dll not being found ...
user251467's user avatar
1 vote
1 answer
28 views

gpkg filename to add PostGIS table field

Is there a way in ogr2ogr to add gpkg filename to a PostGIS table existing field (filename)? during append? ogr2ogr -f "PostgreSQL" PG:"host='ip' port='port' user='user' dbname='db' ...
Tamas Kosa's user avatar
  • 1,509
0 votes
0 answers
16 views

OGR_STYLE Label 'anchor position' not applying in MapInfo Tab file

I've tried creating a label feature in MapInfo using an OGR_STYLE column, but the anchor position (p:12) doesnt seem to be being applied to the label. e.g. LABEL(f:"Arial, Helvetica", c:#...
Prosper's user avatar
  • 115
1 vote
1 answer
30 views

How to create one buffer around all the points using ogr2ogr?

I know how to make a buffer around each point, $ ogr2ogr oom.csv a1.houses.csv -lco GEOMETRY=AS_WKT -dialect SQLITE -sql \ "SELECT ST_Buffer(GEOMETRY,.01,1) AS WKT FROM 'a1.houses'" $ cat ...
Dan Jacobson's user avatar
0 votes
1 answer
28 views

ogr2ogr from PostgreSQL-Installer on Windows without PostgreSQL-Driver

I have a local installation of PostgreSQL 16 on a windows-Computer from EBD (https://www.enterprisedb.com/downloads/postgres-postgresql-downloads). I am struggling with the ogr2ogr tool when exporting ...
leole's user avatar
  • 317
0 votes
2 answers
25 views

How to use ogr2ogr -clipdstsql?

This works (A), $ ogrinfo -dialect SQLITE -sql "SELECT ST_Buffer(ST_GeomFromText('POLYGON ((120.81313 24.18337 ... Layer name: SELECT OGRFeature(SELECT):0 POLYGON ((120.702569638856 24....
Dan Jacobson's user avatar
2 votes
1 answer
48 views

Splitting SHP file based on property starting with an underscore

I found a rather annoying "feature", when trying to split a SHP file based on values of a property, which has a name starting with and underscore (like _property). The problem occurred when ...
pawel_kw's user avatar
0 votes
0 answers
26 views

How to clip a hole with ogr2ogr? [duplicate]

ogr2ogr has a rich set of clip options, e.g., -clipsrc [<xmin> <ymin> <xmax> <ymax>]| WKT|<datasource>|spat_extent But how can I clip the same sized hole instead?
Dan Jacobson's user avatar
1 vote
1 answer
60 views

How to use ogr2ogr -segmentize on a CSV file?

Here each line only has two nodes. $ cat file.csv WKT,ID,Name "LINESTRING (-900 -1450,-900 100)",0,900W "LINESTRING (-800 -1450,-800 100)",1,800W How can I use ogr2ogr -segmentize ...
Dan Jacobson's user avatar
0 votes
0 answers
29 views

QGIS How to Transformation ITRF2020(EPSG:9989) Dynamic(Current Epoch) to Nad83(csrs)v7(EPSG:22717) Fixed

Background: QGIS version Maidenhead 3.36.3 QField version Congo 3.2.2 I have a QGIS project with a project CRS EPSG:22717. I have 2 GPKG layers. The first has an assigned CRS EPSG:9989 The second has ...
Mark's user avatar
  • 1
0 votes
2 answers
65 views

Ogr2ogr: How do I filter a .SHP based on multiple attribute values

I'm attempting to convert (to GeoJSON) & filter a .shp file by the value of multiple attributes. This example, using a single attribute (ID) value, works as expected but I'm confused by the syntax ...
DaveF's user avatar
  • 13
1 vote
1 answer
23 views

GDAL org2ogr ESRIJSON Feature Paging

I'm trying to load some data from an Esri Feature Server URL into PostGIS, using ogr2ogr, but seem to be facing some issues with paging. The below code should in theory load all the Statutory Main ...
Tim R's user avatar
  • 33
1 vote
1 answer
42 views

GDAL ogr2ogr ESRIJSON to PG Date Formatting

I'm trying to load some data from an Esri Feature Server URL into PostGIS, using ogr2ogr but seem to be facing some issues with the date formats. The below code should in theory load all the World ...
Tim R's user avatar
  • 33
1 vote
1 answer
48 views

GDAL convertformat not working on OSM data in QGIS 3.34.5

In earlier versions of QGIS I have used the PyQGIS code below to add OSM data to an existing GeoPackage, as a new layer (osm_lines). However, in my current version (3.34.5), the process is failing. My ...
Tom Brennan's user avatar
  • 5,329
1 vote
0 answers
34 views

Import shapefile using ogr2ogr with a subselect to fill a constraint fails to "cannot open datasource"

I try to import various shapefiles into a postgis database. The shapefiles have some foreign keys referencing other existing (and already successfully imported) tables. ogr2ogr -f "$($json....
semTex's user avatar
  • 111
1 vote
2 answers
53 views

Invalid GIS data provided when importing .gdb file into MySQL using ogr2ogr

I'm using ogr2ogr to import a GDB file into MySQL, and I get this error : ERROR 1: MySQL error message:Invalid GIS data provided to function st_geomfromtext. Description: INSERT INTO `test_table` (`...
Marshall C's user avatar
0 votes
0 answers
35 views

Small Offset in QGIS Reprojection from WGS84 to ED50

I have a .shp in QGIS in EPSG:32637 (WGS84/UTM Zone 37N) and I want to reproject it to ED50, which is in this case EPSG:23037. When I do it manually in in QGIS, the reprojection works fine and both ...
hector's user avatar
  • 1
2 votes
1 answer
145 views

How to tell ogr2ogr/GDAL not to correct any geometry?

I need to import geometries as they are (even invalid) into PostGIS. I use ogr2ogr in a Python script to import the shapefiles. I was able to avoid most corrections removing the -makevalid option and ...
Marc's user avatar
  • 75
0 votes
0 answers
35 views

Remove polygons using clipping in an ogr2ogr command

With help from this forum I developed an ogr2ogr command to transform and reproject a gml file holding cadastral parcel polygons. ogr2ogr -lco COORDINATE_PRECISION=8 -f "GeoJSON" parcel....
Sebastiaan's user avatar
4 votes
1 answer
205 views

How can I use ogr2ogr to left join a CSV to a GPKG file and produce a GeoJSON output in a scalable way?

I have a large GPKG and a CSV file, and I'd like to (left) join the CSV to the GPKG on one of the columns. A visualisation of what I'm trying to achieve: Reproducible example We can create an example ...
zabop's user avatar
  • 2,224
3 votes
1 answer
222 views

How to fix "failed to prepare SQL" error when creating GPKG file from OSM extracts using ogr2ogr?

I downloaded an OpenStreetMap extract for Europe, to a file latest.osm.pbf: curl https://ftp5.gwdg.de/pub/misc/openstreetmap/download.geofabrik.de/europe-latest.osm.pbf \ -o latest.osm.pbf I would ...
zabop's user avatar
  • 2,224
1 vote
1 answer
49 views

Ogr2ogr Select statement to define new geometry out of given coordinates

I would like to extract and alter place label coordinates from a GML file with cadastral parcel information using ogr2ogr. See part of the GML file at the end of this question. Besides the given place ...
Sebastiaan's user avatar
0 votes
1 answer
63 views

How to select attributes with ogr2ogr

I would like to convert a GML file with cadastral parcels to GeoJSON format using ogr2ogr. See also attached extract of the GML file at the end of this question. Additional requirements: Convert ...
Sebastiaan's user avatar
0 votes
0 answers
74 views

Retain GlobalIDs during Esri gdb export/import

I'm using ogr2ogr (OpenFileGDB) to convert an Esri gdb into a SQLite file, where I perform some edits and then convert it back to gdb. The original Esri gdb data have GlobalID fields which is turned ...
Nimo's user avatar
  • 113
0 votes
1 answer
29 views

ogr2ogr list all table error

I don't understand the problem when I use this command : $ ogr2ogr -f "GPKG" "/.../..../.../.../.../gabarits gpkg/aep.gpkg" PG:"host='localhost' user='...' password='...' ...
pasqal's user avatar
  • 538
0 votes
1 answer
51 views

DXF to GeoJSON conversion gets coordinates completely wrong?

I am using GDAL and the ogr2ogr tool in order to convert a file from a DXF to GeoJSON but at the same time convert the coordinates to another CRS, from Sweref 99TM to WGS84. The issue I am facing is ...
Ms01's user avatar
  • 103
0 votes
1 answer
40 views

R osm_extract package not handling railway tag properly

I am working with files from OpenStreetMaps obtained from GeoFabrik in the .osm.pbf format. My goal is to use the osmextract package from R to filter the files to only include certain tags. The ...
Esra's user avatar
  • 3
0 votes
0 answers
20 views

Embedded GML in XML to GeoJSON with ogr2ogr

I have an XML file that contains GML parts in it. I tried to use ogr2ogr without success to convert it to GeoJSON. I lose most of properties from the upper XML node. The associated schema for the ...
greentea's user avatar
0 votes
1 answer
76 views

GDAL/OGR import file GDB to a specific PostgreSQL schema

I'm trying to import a dataset (file GDB) into a PostgreSQL (16) + PostGIS (3.4) database using GDAL 3.6.3 (released 2023/03/07) without any kind of success: ogr2ogr -f PostgreSQL "PG:${PG_URI}&...
swiss_knight's user avatar
  • 10.5k
1 vote
1 answer
58 views

KMZ bbox to GPKG

Using OGR/GDAL programs, I would need to get the BBOX out of a KMZ file and import this BBOX into a GPKG. I can convert my KMZ into a GPKG using ogr2ogr, however I don't need to import all my KMZ ...
user11681321's user avatar
2 votes
1 answer
122 views

How do I modify S57 data converted using ogr2ogr so that it correctly exports on qgis2web?

I have some unencrypted ENC charts with file extension .000 (S57 data). Using the process and S52 styles at https://www.sigterritoires.fr/index.php/affichage-des-cartes-marines-s57-dans-qgis/ I have ...
James Davies's user avatar
0 votes
1 answer
99 views

Convert multiple .xml files in one dir to geopackages into another dir with ogr2ogr

Update: I did find the referenced stack discussion but the difference here is: my question is referring to transform .XML to geopackage (not .shape to map info) I would like to include the ...
i.i.k.'s user avatar
  • 1,753
1 vote
2 answers
79 views

ogr2ogr command with python os.system() not working. Why?

I have 4126 GML-files as.xml, containing building polygons. I want to use ogr2ogr to transform them to geopackages. The following command works on one layer when I run it in the OS4Geo Shell shipped ...
i.i.k.'s user avatar
  • 1,753
5 votes
1 answer
55 views

Preserving parcel labels when importing WFS data with GDAL

I'm currently working on a project where I need to import geographic data from a WFS server using GDAL (ogr2ogr) into a GeoPackage format. My objective is to preserve the data exactly as it is, ...
tobmoor's user avatar
  • 51
0 votes
2 answers
116 views

Import of GeoJSON Multi Polygon into PostgreSQL does not work with GDAL ogr2ogr anymore

Original Post I imported this Multi Polygon ./apps/ogrinfo -so -al ~/Downloads/osm-boundaries/germany/OSMB-5cf5ed195895ffb3c65abc341dc8138bb5c6cedf.geojson/OSMB-...
dancesWithCycles's user avatar
0 votes
0 answers
20 views

Uploading mbtile to PostgreSQL via ogr2ogr results in tile boundaries

I have a large .mbtile file (all census tracts in the United States) that I would like to store in PostgreSQL. I am using ogr2ogr to upload the file to a table with the following command: ogr2ogr -f ...
Paige's user avatar
  • 1
4 votes
1 answer
124 views

ogr2ogr: Unable to import shapefile with '-lco RFC7946=YES' parameter to the PostGIS db

I'm trying to convert multipolygon to in the right-hand format so that Leaflet can use it on the front end. ogr2ogr -nln [target_table] -nlt PROMOTE_TO_MULTI -lco GEOMETRY_NAME=geom -lco FID=gid -lco ...
matsukan's user avatar
1 vote
1 answer
70 views

How to use the 'sqlite' dialect in ogr2ogr queries when one of the GeoJSON property fields is "id"

I have an example GeoJSON, and I would like to use it as input to an ogr2ogr command. I aim to generate a new file with positive integer feature ids, as described here. The example GeoJSON, src....
zabop's user avatar
  • 2,224
1 vote
0 answers
53 views

How to find the relation between track and track points after importing GPX data with ogr2ogr?

I've imported the gpx file into postgres db with postgis enabled using ogr2ogr: ogr2ogr -f "PostgreSQL" PG:"host=xxx user=xxx password=xxx dbname=xxx" "test.gpx" As ...
Mateusz Witkowski's user avatar
3 votes
1 answer
128 views

QGIS 3.28/GDAL Unable to export ESRI file geodatabase layer to PostgreSQL

In the past, using the OSGEO4W Shell installed as part of QGIS, I was able to run an ogr2ogr command to transfer a feature layer from an ESRI File Geodatabase to a table in PostgreSQL. However, after ...
Mike Smith's user avatar
2 votes
1 answer
138 views

Why can ogr2ogr upload data to a not previously existing table faster than to an existing empty one?

Recently I observed that it takes much less time for ogr2ogr to upload data to a PostGIS database if I do not create the destination table first. I would like to understand why this happens. Below is ...
zabop's user avatar
  • 2,224
1 vote
0 answers
43 views

ogr2ogr MSSQL to gpkg encoding issue

I am trying to write data from SQL server to geopackage but I have met some encoding issues. Warning 1: Value of field 'IDENTIFICATION' is not a valid UTF-8 string. I dont understand where in the ...
geogrow's user avatar
  • 1,693
1 vote
1 answer
62 views

Convert Multi-layered GML file to GeoJSON

I have the GreenSpace GML file from https://osdatahub.os.uk/ When using ogr2ogr with this command: -f GeoJSON -lco RFC7946=YES OSOpenGreenspace.geojson OSOpenGreenspace.gml I am given this Error by ...
GentleCynic's user avatar
0 votes
1 answer
51 views

Converting GML to GeoJSON - offset is out of bounds

I need to convert a GML file to GeoJSON from this website (https://use-land-property-data.service.gov.uk/datasets/inspire/download) and store it in my MongoDB database. I have read a few posts on here ...
GentleCynic's user avatar
4 votes
1 answer
124 views

How to use ogr2ogr's spat_extent keyword to clip a layer of a GPKG file?

I am trying to clip geometries within a GPKG file using a bounding box. I write an L-shaped line to a file: import geopandas as gpd import shapely.geometry l = shapely.geometry.LineString([[0,2],[0,-...
zabop's user avatar
  • 2,224
2 votes
0 answers
89 views

How to use ogr2ogr to download WFS data congaining special characters (such as \x01)?

Problem I am interested in the ms:C_GAZ layer of this WFS endpoint. QGIS can connect to this the endpoint and visualise its data without any error (I recommend zooming in heavily to a big city to ...
zabop's user avatar
  • 2,224
0 votes
1 answer
39 views

ogr2ogr -where: match features from OSM PBF with unset "seasonal" field

I have an .osm.pbf file from Geofabrik and want to extract all lakes that are not seasonal or intermittent to an SHP file, using ogr2ogr. I am currently using the following command: ogr2ogr -where &...
TheEagle's user avatar
  • 115
0 votes
0 answers
57 views

ogr2ogr exporting from MSSQL slow -- relatively

So when I pull the same stored procedure on my machine in SQL Server Management, we get 600+ megabits for about 100 seconds. Keep in mind this SQL Server has plenty of RAM, Cores, etc, and 20gig ...
user3798047's user avatar
0 votes
0 answers
31 views

How to get SRID from .prj file in PHP using OGR2OGR in PHP

I'm writing a PHP script that uses the OGR2OGR command to open a .prj file and get its SRID. I'm using the following code: $prjPath=Storage::path(filename); $output = shell_exec("ogrinfo -al -so $...
Maryam Atabati's user avatar
0 votes
0 answers
100 views

ogr2ogr MSSQL to geopackage encoding

I'm exporting data from a MSSQL server to geopackage. "C:\OSGeo4W\bin\ogr2ogr.exe" -f "GPKG" "C:\folder\tables.gpkg" "MSSQL:server=theserver;database=thedb;driver=...
Bera's user avatar
  • 74.8k

1
2 3 4 5
24