Questions tagged [ogr]

The OGR Simple Features Library is a C++ open source library (and command line tools) providing access to vector file formats.

Filter by
Sorted by
Tagged with
1 vote
2 answers
33 views

Loading a ogr data object into a geodataframe

I have been experimenting with ways to work with large datasets in python and I started using ogr method of loading a layer with an sql query to speed up data access as oppose to loading the entire ...
  • 1,243
0 votes
1 answer
14 views

OGR Python API FlatGeobuf edits are not persisted

I'm using GDAL 3.5.1 OGR's Python bindings (on MacOS) to create features within a FlatGeobuf file but my changes are not being persisted. Relevant Code: data_path = "/Users/user/data/trails.fgb&...
  • 3,594
0 votes
1 answer
42 views

ogr2ogr auto conversion of text to date type

I have a question regarding ogr2ogr's auto-conversion of text fields to date fields, specifically in the case of additional text following the date. input.geojson file: { "type": &...
  • 9
0 votes
2 answers
18 views

GDAL Script Failing since GDA2020 Shift - unable to find EPSG 7855

I have a series of ogr2ogr scripts that run daily on our Intramaps server. Since shifting our GIS data to GDA2020 I notice these scripts fail with ERROR 6: EPSG PCS/GCS code 7855 not found in EPSG ...
  • 103
0 votes
1 answer
16 views

How to commit in batches using OGR in Python

When working with OGR in Python you have to set your target_layer and target_datasource to None in order to commit the features to the database. But I'm handling a large dataset of 2,7 million records....
0 votes
0 answers
43 views

GDAL OGR OCI driver takes unreasonable long time to load from oracle database

For quite some time I'm trying to get OCI to work with GDAL. I created a docker image with the driver installed and I use the python api to do the work. When I try to load and print just 20000 records ...
1 vote
1 answer
24 views

What could go wrong when merging multiple GeoJSONs?

Attempt I - ogrmerge I have a few GeoJSONs in a directory called jordsmonnfiles. I want to get one GeoJSON file with the features from the files matching the pattern jordsmonnfiles/jordsmonn_*JK1....
  • 262
2 votes
1 answer
37 views

Properly closing GeoPackage after opening by OGR so as to delete it later

I am creating a program that downloads a GeoPackage from online, opens it, makes a copy of the first layer as a shapefile, and then (hopefully) deletes the GeoPackage. However, I'm not able to delete ...
  • 688
0 votes
0 answers
44 views

GDAL Appending Shapefile to SQL Error: Ogr2ogr ERROR 1: MSSQL extents query returned a NULL value

I have an OGR2OGR script to append a shapefile to an existing SQL table, but I get the error 'Ogr2ogr ERROR 1: MSSQL extents query returned a NULL value'. I have seen discussions with various ...
  • 103
2 votes
1 answer
89 views

ogrinfo missing DLL error

When trying to execute "ogrinfo" command the following message appears: the code execution cannot proceed because gssapi64.dll was not found. Reinstalling the program may fix this issue. I ...
  • 29
1 vote
0 answers
19 views

Handling Self Intersecting SQL Geometries with OGR

Is there a way to validate/fix self intersecting SQL geometries when pushing a SQL table into a new SQL database using OGR? This is MSSQL. I want to avoid having to manually fix potentially many badly ...
  • 103
0 votes
1 answer
88 views

Calculating area (square meters) of WKT polygons with CRS of 4326 [duplicate]

I use python 3 (QGIS libs). At some point of my developing system I need calculate the area of a few polygons. I don't need a code, just a hint. Currently I generate the shapefiles, after that I ...
1 vote
1 answer
33 views

How to use ogr2ogr to reproject shapefile in Python

I am trying to reproject the coordinate system of a shapefile. I know I can do it in the OSGEO4W window as ogr2ogr -s_srs EPSG:27700 -t_srs EPSG:3857 C:/test/input.shp C:/test/output.tif However, I ...
0 votes
0 answers
26 views

OGR SQL Empty Output

I have a Powershell script that loops through a database and outputs the spatial tables into another database in GDA2020 datum. I see one particular table is outputting but is empty. This table should ...
  • 103
0 votes
0 answers
22 views

ogr2ogr's sql works with small number of inputs to filter geopackage, but doesn't with large input

I have a .txt file that has all the features I want to select. It looks like this in the small version: ('100mN25991E46719','100mN25993E46718','100mN26000E46712','100mN26002E46691','100mN26003E46700','...
  • 717
2 votes
1 answer
48 views

Use ogrinfo to get names from column and count rows of large(ish) geopackage

I think this is a really silly question, yet I can't solve it quickly now: I want to work with this rather large geopackage: https://data.statistik.gv.at/data/...
  • 717
1 vote
1 answer
51 views

Reading a MapInfo TAB File with .accdb (Microsoft Access)

I have a MapInfo TAB consisting of 5 files: .tab, .map, .id, .aid, .accdb The attributes seem to be stored in the .accdb Microsoft Access database file. Using GDAL 3.5.0 on Windows 10 installed via ...
  • 8,779
0 votes
1 answer
36 views

Unable to define a local projection with no units in a GeoTIFF file using GDAL

I am unable to define a local projection with no units for a GeoTIFF file using GDAL. Here is a sample of what I'm trying to do in Python: python >>> from osgeo import gdal >>> gd = ...
  • 431
0 votes
0 answers
61 views

GDAL Inverse Coordinate Translation

I have data in WGS84 and when I translate it to ED50 it doesn't appear in the correct place using GDAL and C#. I use CoordinateTransformationOptions.SetOperation using c# to set the specific ...
0 votes
0 answers
83 views

Java - Mac OS - GDAL/OGR missing libraries

I'm trying to read/access a geodatabase (.gdb folder) for extracting some data. I can access the database from terminal using >ogrinfo test.gdb.zip and as result i get using driver `OpenFileGDB' ...
0 votes
1 answer
41 views

Updating/Setting Field on GML file not working

I'm currently attempting to add a new field to each feature in a file, however, the file is not getting changed. I've tried using driver.Open(file_path, 1) and driver.Open(file_path, update=1), but ...
  • 33
1 vote
1 answer
62 views

Getting base Line of PostGIS skeleton

I'm interested in using OGR/GDAL, PostGIS, or QGIS in order to achieve the following: Working from the PostGIS docs, how would one further simplify this line to the middle line? I've tried utilizing ...
  • 1,071
0 votes
0 answers
48 views

OSGeo4W / ogr2ogr gives "Unable to create or change a table without a primary key" error with MySQL 8.0

I'm trying to use OSGeo4W Shell to populate my MySQL DB with data from a shapefile and am having some difficulty. Here's the command I'm using: ogr2ogr -f MySQL MySQL:maps,host=localhost,user=root,...
  • 207
1 vote
1 answer
26 views

Geotools + OGR: FeatureIterator.next() blocks the execution

I am using geotools to read through some vector files in my gis project. I am trying to read FileGeoDatabase files as well as DXF and DWG. The thing is, I am able to create the Metadata for the files, ...
0 votes
1 answer
116 views

GDAL loop through gpkg layers

I've a gpkg with several vector layers inside, i'd like to build a spatial index for each I'm using very simple gdal/sql process: ogrinfo -SQL "SELECT CreateSpatialIndex('gis_layer_01', 'geom')&...
  • 91
0 votes
0 answers
75 views

Obtain CRS compliant WKT from GeoPackage with ogrinfo

I would like to obtain the WKT for a few geometries stored in a GeoPackage file with orginfo. That is the function of the -al parameter. However, when applied directly to the file in question it ...
0 votes
0 answers
89 views

How to import shapefile into MySQL with Python

Let's see if you could help me with this: I try to upload a gpkg (geo-referenced) file (table) to a MariadB server (MySQL). Not in PostgreSQL, Mariadb-(MySQL) If I import from an OSGeo4W in the ...
0 votes
0 answers
18 views

Determine best cell size for vector dataset based on provided info from ogrinfo

I have been using ogrinfo to obtain information regarding my Bathymetry dataset shapefile with the results as follows: Layer name: TEST Metadata: DBF_DATE_LAST_UPDATE=2022-03-30 Geometry: 3D Point ...
1 vote
0 answers
122 views

How to use ogrinfo in a Python script

I've been using OGR/GDAL in its command window to obtain information regarding a vector file with this command ogrinfo -so -al d:/vector_file.shp I'm now trying to do the equivalent of this feature ...
1 vote
0 answers
36 views

Find best cell size to use for rasterization from a shapefile

I've been using GDAL/OGR so far to gather information about my shapefile ogrinfo -so c:/shapefile.shp Using information such as the extents, I can incorporate this into my next command of gdal_grid ...
1 vote
1 answer
43 views

Save certain ogrinfo results to variable in Python [closed]

I am using ogrinfo in Python to obtain information about a shapefile. My code is as follows: from subprocess import Popen, PIPE args = ['ogrinfo', '-ro', '-so', '-al', 'C:/test/test_shapefile.shp'] ...
0 votes
1 answer
36 views

How can I use the <src_datasource> parameter from gdal_rasterize?

I'm using the following command to generate a TIFF file from a shapefile: gdal_rasterize -burn 255 -burn 0 -burn 0 -ot Byte -tr 0.0000169959 0.0000169959 -l layer_name input.shp output.tif It works ...
  • 1,041
1 vote
0 answers
43 views

In QGIS how do the providers 'spatialite' and 'ogr' influence loading, editing and processing sqlite/spatialite layers?

Referencing this older post it seems to me, that indeed the provider is dependent on how the file was loaded: -> ogr: Loading via Vector (Data Source Manager) or drag & drop -> spatialite: ...
0 votes
0 answers
60 views

Merging multiple SpatiaLite databases into a single one with ogrmerge.py

I have a folder with multiple SpatiaLite databases. I'd like to use ogrmerge.py to merge them into a single database... But if I use the command: ogrmerge.py -f SQLite -single -o output.sqlite *....
  • 1,041
1 vote
0 answers
43 views

gdal.RasterizeLayer() not outputting a proper geotiff file

I am trying to rasterize a geodataframe of a vector by burning the attribute values onto a template raster. I can't however get my function to output a proper .tiff file. rather it outputs a regular ...
2 votes
2 answers
2k views

Feature creation error (OGR error: Coordinates with non-finite values are not allowed)

I ran into this error when I wanted to edit a shapefile (I was using the editor and mainly dealing with changing polygons - cutting, etc.- ) and then wanted to save the edits. The error message reads ...
  • 95
2 votes
4 answers
716 views

Converting OGR geometry as WKT of polygon from float to integer in the WKT string

(This is a repost into this community of my original question posted on SO, because there has been no answer so far. Hopefully in this community more luck. I'll ask for the other one to be closed.) I ...
  • 33
1 vote
1 answer
53 views

OGR_G_ForceToPolygon() doesn't produce polygon - GDAL C API

Using the C APIs for GDAL 2.2.2 (within Swift app) I have a very simple OGRGeometryRefH that is a wkbLineString. I'm creating the wkbLineString and attempting to convert it to a wkbPolygon geometry by ...
1 vote
1 answer
375 views

C# transform coordinates using specific transform code using GDAL

I have an application that can import / export geospatial data to / from an ESRI SDE Database (SQLServer). The data is transformed to WGS84 before it is inserted into the DB and again from WGS84 to ...
2 votes
1 answer
214 views

Using ogr2ogr in Python scripts

I have been trying to figure out how to execute ogr2ogr to convert files in Python script. I got it to work in Jupyter notebook within ArcGIS Pro and in the terminal but not in Python scripts. Here's ...
0 votes
1 answer
50 views

Why is script calculating Ellipsoidal area instead of cartesian area?

I have this two shapefiles (https://drive.google.com/file/d/1a83sh-V46uaoUFwPXEtoZnD_XUBGG9X9/view?usp=sharing). The original one is in 4326 reference system. The second one is the result of qgis ...
1 vote
1 answer
52 views

UMN MapServer PostGIS vector layer Background transparent

How to set background transparent in UMN Mapserver mapfile for the layer coming from postgis. executed map file is MAP PROJECTION "init=epsg:4326" END NAME "layername&...
0 votes
1 answer
82 views

How to obtain the SRID of a GDB layer using ogr_layer_SRID with ogrinfo?

I would like to use ogrinfo.exe through a command line to query the SRID of a layer (e.g., polygon layer) inside an ESRI GDB. Similarly to SpatialReference.GetAuthorityCode() when using GDAL Python ...
  • 53
5 votes
1 answer
233 views

Error while transforming/reprojecting geometry using OSGEO/OGR/OSR: "RuntimeError: OGR Error: General Error"

I tried transforming a point from WGS84 (EPSG:4326) to NAD83 / Texas State Mapping System (EPSG:3081) and got a non-descript RuntimeError error. Here's a reproducible example: from osgeo import ogr, ...
  • 1,807
3 votes
1 answer
189 views

Change to field name of gpkg layer not retained using ogr

I am trying to update the names of the fields in a gpkg layer using the ogr Python package. I have gotten most of the way using this answer to another question on the subject using SetName on the ...
  • 33
0 votes
1 answer
62 views

Compress output file and set default value when rasterizing ogr layer with GDAL

I am trying to rasterize a polygon layer currently as a feature class in a file geodatabase using OGR/GDAL (Python script). So far I have managed to do the rasterization with the output tif file ...
1 vote
1 answer
243 views

ogr.CoordinateTransformation appears to be inverting xy coordinates

My problem exists with Polygons, but I created the following as an example using points to simplify my problem. My issue is when transforming geometry from EPSG:26913 to EPSG:4326 the output of x and ...
  • 31
2 votes
1 answer
68 views

Is it possible convert 3 shapefiles to 1 GPX file?

I ran into problem converting shapefiles to a GPX file. I used below code using ogr2ogr. ogr2ogr -f gpx i.gpx i.shp it works well, but I'd like to convert three shapefiles to one GPX file like this: ...
0 votes
0 answers
116 views

Storing Metadata in GeoPackage using GeoPandas or Fiona

I would like to store some metadata in a GeoPackage file. The metadata would be relevant to the entire file, not just to each individual geometry. An example might be assigning license text or ...
2 votes
0 answers
154 views

How to query a file geodatabase using GDAL/OGR C# for records with an invalid geometry

Presently, I have a snippet of code that works well when iterating over a file geodatabase. The problem I'm currently having is that, on occasion, a geometry is supplied that is invalid, such as a ...
  • 21

1
2 3 4 5
22