Questions tagged [ogr]
The OGR Simple Features Library is a C++ open source library (and command line tools) providing access to vector file formats.
1,106
questions
0
votes
0
answers
33
views
Can vector layers using memory data provider render QgsPalLayerSettings label?
I have a memory vector layer created from a GeoJSON feature:
feature = {
"type": "Feature",
"properties": data,
"geometry&...
3
votes
1
answer
476
views
A faster method for converting meters to degrees
I have this algorithm, written in C++, that converts meters to degrees using OGR and GDAL.
OGRSpatialReference source, target;
OGRCoordinateTransformation* transform;
const char* projection = geotiff-&...
0
votes
0
answers
44
views
Delete duplicate vectors from command line
I have one vector layer called "trails" and another called "roads."
There are vectors with identical geometry, and I want to delete any vectors in the trails layer with identical ...
1
vote
1
answer
14
views
"RuntimeError: XS: No such file or directory" error while specifying the table when using the GeoPackage source dataset in ogrmerge
I am trying to merge specific tables of multiple GPKGs using ogrmerge. How to specify the table to use when in the source dataset name. When using ogrinfo we can do the following to work with XS table ...
1
vote
0
answers
53
views
Issues with GDAL installation - ogr not available?
I am attempting to install GDAL on my Windows 10 machine. I have previously done this successfully using the wheels from Gohlke's now deprecated site so I am learning a new way to do an old thing. ...
0
votes
0
answers
19
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:#...
1
vote
1
answer
38
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 ...
0
votes
0
answers
15
views
gdal ogr transform c++ swaps axis order x to y [duplicate]
This is example
#include "gdal/gdal.h"
#include "gdal/ogr_spatialref.h"
#include <iostream>
void TransformBounds(double xmin, double ymin, double xmax, double ymax,
...
3
votes
1
answer
51
views
Is it possible to get features by the WFS vector driver in a coordinate system that is not the default srs regarding the WFS capabilities?
We currently experiment with the gdal java bindings to receive data from a WFS service.
Regarding the WFS specification a FeatureType must define its default coordinate system (Tag DefaultCRS).
We ...
2
votes
1
answer
73
views
Error in dissolving shapefile with ogr2ogr
I am trying to dissolve a shapefile having polygon geometries. I want to dissolve the shapefile which will create a single multi-polygon geometry.
ogr2ogr -dialect sqlite -sql SELECT ST_Union(geometry)...
1
vote
1
answer
62
views
Writing to FlatGeoBuf using Python OGR results in "ERROR 1: ICreateFeature: Mismatched geometry type"
When I try to create even very basic point geometries using OGR's FlatGeoBuf driver in Python, I keep getting this error: "ERROR 1: ICreateFeature: Mismatched geometry type"
Here is a ...
2
votes
1
answer
96
views
Specify layer when using a geopackage in ogr2ogr
I want to clip a vector-layer by another layer with ogr2ogr as explained here.
I always struggle to find out how to refer to a layer in ogr2ogr for input and output. Does anyone have a quick tip?
0
votes
1
answer
48
views
Read only the structure of a geopackage using GDAL/OGR?
I'm trying to figure out if it's possible to only show the structure (layer names, field names and types, constraints, etc) of a GeoPackage which has no data record using GDAL/OGR (ogrinfo).
Is it ...
0
votes
0
answers
72
views
MaxRev.Gdal.Core - OSGeo.OGR driver.createdatasource fails with System.NullReferenceException
I try to create a new GeoPackage file and write some point data into it. But my code already fails, when I try to create the new GeoPackage file.
I try to create this file within an unix/C# ...
3
votes
2
answers
195
views
How to extract the integer-based geometry type code from an OGR feature
Main question
Using OGR in Python, how can I extract the integer-based geometry type code for a specific feature?
I know how to do this when dealing with a whole layer. For example, reading a layer ...
2
votes
2
answers
100
views
How to set a 'dataset open option' in ogr on a file geodatabase?
In the documentation for the GDAL/OGR OpenFileGDB driver, there is a Dataset open option called LIST_ALL_TABLES. Using python, how exactly do I set that?
3
votes
2
answers
75
views
Let ogr/GDAL automatically choose Driver based on file extension
I inherited some code for a QGIS Python plugin which uses the ogr module. For each usage of ESRI Shapefiles is hardcoded due to the loading of the respective driver (ogr.GetDriverByName("ESRI ...
1
vote
0
answers
85
views
How to combine ODA File Converter with OGR (GDAL) so that dwg is a format option
I have downloaded ogr/gdal with QGIS 3.34.1 and I have downloaded the ODA file converter from https://www.opendesign.com/guestfiles/oda_file_converter
However, I am not sure how to combine the two so ...
1
vote
1
answer
70
views
How to assign a layer to a group in GDB datasets using gdal python
I'm currently working with ESRI GDB datasets and I can easily open hierarchical geodatabases and walk the tree using the API that gdal provides.
root_group = ds.GetRootGroup()
for g in root_group....
0
votes
1
answer
44
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 &...
1
vote
1
answer
93
views
GDAL add custom fields to GPX files using the command line (batch)
Using the GDAL/OGR command line, how could one add some fields to a GPX file ?
I simply need to add the gpx filename to its content, e.g. in a new field called datasource in each (there are several ...
0
votes
0
answers
24
views
Ogr AddPointZM does not work. Cannot create any geometry with ZM values
I am trying to create LineStringZM using ogr java bindings. My code is below:
private Geometry prepareLineString(Layer ly) {
var result = new Geometry(ogr.wkbLineStringZM);
for (int i = 0; i ...
1
vote
0
answers
127
views
How to extract layers from a mpkx file?
I would like to use the World Terrestrial Ecosystems data published by the USGS. It is made available in the form of a compressed file in the mpkx format. I expect this file to contain one or more ...
0
votes
0
answers
55
views
Exporting records with more than 250 characters in a field to GML
I am trying to export OSM vectors to the GML format like:
v.out.ogr input=network output=network.gml format=GML
I get an error that the field a_other_tags has more than 250 characters:
ERROR 1: ...
1
vote
0
answers
73
views
OGR_STYLE label style line breaks
I am trying to create a GeoSpatial PDF using gdal_translate.
Using the vrt file i am able to generate OGRFeatures having STYLE
OGRFeature():23
OGR_STYLE (String) = SYMBOL(id:"icn_cabinet_external....
0
votes
0
answers
208
views
Read KML file with GDAL/OGR and access all its attributes
I have a KML file and I'm trying to access a specific attribute named "styleUrl".
A feature of this KML looks like this:
<Placemark>
<name/>
<styleUrl>BoundaryStyle</...
0
votes
0
answers
43
views
Python OGR error when intesecting line by polygon
When I try to find the intersection of a line gdb layer with a polygon layer I get the following error: Can only insert a LineString/MultiLineString/CircularString/CompoundCurve/MultiCurve in a ...
1
vote
1
answer
65
views
Does GDAL have an error with calling multiple functions on the same line of code?
I typed this code on Python interpreter but the Python shell restart on the last line:
from osgeo import ogr
shp_ds = ogr.Open(r'C:/Users/admin/countries.shp')
lyr = shp_ds.GetLayer(0)
#python shell ...
0
votes
1
answer
150
views
Python OGR: NoneType Error only when writing to OpenFileGDB, reading works fine
I have a peculiar situation when trying to write to a .gdb using OGR. I get a NoneType error following any OGR function after ogr.Open() when I specify the data source as writable. From previous ...
1
vote
1
answer
281
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
454
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 ...
2
votes
1
answer
475
views
In QGIS Georeferencer: Mysterious OGR Driver Error: not found OGR
I have been georeferencing Vector files (gpkg and shp) in the new Georeferencer in QGIS 3.30.1. The files are pretty large, have multiple million features and a size of roughly 2-3gb.
I have ...
0
votes
2
answers
144
views
Exporting polygon as DXF using PyQGIS
I am working on a script to export my dissolved polygon into Dxf but I get an error.
Could somebody teach me how to do this?
Here is my code:
from qgis import processing
from datetime import datetime, ...
2
votes
1
answer
275
views
WFS in PostGIS OGR FDW results in "ERROR 1: No schema information loaded."
I am trying to add the WFS data of a german state to PostGIS using the PostgreSQL OGR Foreign Data Wrapper:
CREATE SERVER server_mv
FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
datasource 'WFS:https://www....
0
votes
0
answers
104
views
Working with NHDPlus data in GDB file format using GeoPandas
I am trying to work with the NHDPlus High Resolution dataset from the USGS. Looking at the documentation, there should be all sorts of data table available as well as mapping layers but the only thing ...
2
votes
3
answers
526
views
How to extract geometries with M-values from a feature layer in Python?
Problem statement
I am aware that geopandas (due to the limitations of shapely and pygeos) does not read geometries with M-values - when reading a layer that has them, geopandas now just drops those ...
3
votes
0
answers
353
views
How to create Block References in dxf files using GDAL?
I need to use GDAL to create dxf files in AutoCAD. I have already implemented the creation of point-line geometry layers and label layers, but now the creation of Block References keeps failing. In ...
0
votes
1
answer
101
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:&...
1
vote
0
answers
57
views
Using Python OGR to reproject SQL Spatial Data
I currently have a heap of GDAL scripts that reproject from one SQL feature class into a new SQL feature class, but I want to convert these into Python scripts using the GDAL library, to clean up my ...
2
votes
1
answer
70
views
ogrinfo / ogr2ogr : sql values with accents
I'm trying to access data that is stored in a MSSQL spatial database and it seems to me that OGR is having some problems with accents. I'm not sure if maybe there is an encoding parameter or something ...
0
votes
0
answers
67
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 ...
1
vote
0
answers
191
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 &...
0
votes
0
answers
225
views
When ogr2ogr hits rasters in a file geodatabase
I would like to use ogr2ogr.py to batch convert feature classes and tables in a collection of ESRI file geodatabases into geopackages, but some of these gdbs have rasters in them, apparently in SDE ...
0
votes
1
answer
236
views
Incorrect coordinate translation using GDAL.NET compared to gdaltransform and epsg.io
I am working on a project to convert between one coordinate system, provided by an EPSG code, and EPSG:4326 or EPSG:4979 (WGS84 CS to include heights above ellipsoid).
Testing the following ...
0
votes
0
answers
766
views
GeoPandas fails silently when reading GeoJSONs
I have a file example.geojson. This file has 68 features (jq '.features | length' example.geojson returns 68).
If I try to load this file to a GeoPandas dataframe (gpd.read_file docs), I can choose ...
0
votes
0
answers
28
views
Intersection between shapefiles using gdal [duplicate]
From three .tif files I got the relative associated .shp files through gdaltindex.
Now, I'd like to create a new .shp file given by the intersection of the three shp. files previously obtained.
How ...
2
votes
0
answers
55
views
Is any GIS processing in Python bound to be single threaded due to the GIL?
I'm processing a really complex geometry using Python and ogr, which is taking forever to compute.
Looking at the CPU usage, I've noticed that it never exceeds 100% (more than 100% signals that the ...
0
votes
1
answer
129
views
Install and run GDBee file geodatabase SQL tool
GDBee is a Python tool for querying file geodatabases using SQL (outside of ArcGIS): https://github.com/AlexArcPy/GDBee
I want to install and run GDBee in Windows 10 (64-bit). As a novice, here's what ...
2
votes
1
answer
131
views
Working with CIRCULARSTRING in OGR's sqlite dialect
ogrinfo ":memory:" -dialect sqlite -sql "SELECT ST_GeomFromText('Point(1 2)')" gives me a dataset with a geometry column:
INFO: Open of `:memory:'
using driver `SQLite' ...
0
votes
1
answer
202
views
Export shapefile to MapInfo file using Python OGR
I'm trying to save/copy a shapefile to a .tab format with Python OGR.
Every attempts give me the following error:
RuntimeError: CreateFeature() failed: cannot re-write already existing
feature 1
...