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
0 votes
1 answer
15 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 ...
user avatar
  • 13
1 vote
1 answer
50 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 ...
user avatar
  • 989
0 votes
0 answers
23 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,...
user avatar
  • 205
1 vote
0 answers
11 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, ...
user avatar
0 votes
1 answer
29 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')&...
user avatar
  • 91
0 votes
0 answers
27 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 ...
user avatar
0 votes
0 answers
32 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 ...
user avatar
0 votes
0 answers
15 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 ...
user avatar
1 vote
0 answers
37 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 ...
user avatar
1 vote
0 answers
29 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 ...
user avatar
1 vote
1 answer
39 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'] ...
user avatar
0 votes
1 answer
21 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 ...
user avatar
  • 1,021
1 vote
0 answers
30 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: ...
user avatar
0 votes
0 answers
31 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 *....
user avatar
  • 1,021
1 vote
0 answers
24 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 ...
user avatar
2 votes
2 answers
375 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 ...
user avatar
  • 85
2 votes
4 answers
253 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 ...
user avatar
  • 33
1 vote
1 answer
31 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 ...
user avatar
1 vote
0 answers
85 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 ...
user avatar
2 votes
1 answer
78 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 ...
user avatar
0 votes
1 answer
29 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 ...
user avatar
1 vote
1 answer
36 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&...
user avatar
0 votes
1 answer
41 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 ...
user avatar
  • 53
5 votes
1 answer
121 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, ...
user avatar
  • 1,717
3 votes
1 answer
122 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 ...
user avatar
  • 33
0 votes
1 answer
47 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 ...
user avatar
1 vote
1 answer
93 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 ...
user avatar
  • 31
2 votes
1 answer
46 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: ...
user avatar
0 votes
0 answers
49 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 ...
user avatar
2 votes
0 answers
78 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 ...
user avatar
  • 21
1 vote
1 answer
31 views

ogr2ogr DXF_FEATURE_LIMIT_PER_BLOCK error

I am trying to convert a DXF to GeoJSON using ogr2ogr However, I am getting the below error: Limit of 10000 features for block ____ reached. If you need more, set the DXF_FEATURE_LIMIT_PER_BLOCK ...
user avatar
0 votes
1 answer
96 views

Docker ogr2ogr & ogrinfo .shp shapefile "Unable to open datasource"

I am using current gdal docker image osgeo/gdal:ubuntu-full-3.4.1 to display metadata from a shapefile. After multiple failed attempts of failed installation of GDAL 3.4 on Ubuntu 20.10 I am now using ...
user avatar
1 vote
1 answer
114 views

How to convert from OGR geometries (with M-values) to shapely geometries (without M-values)?

Main question Suppose I have a few OGR geometries, all of them containing M-values. Is there a generic solution that allows me to translate them to Shapely geometries without M-values? Shapely and M-...
user avatar
  • 1,717
1 vote
0 answers
49 views

Using -limit tag with ogr2ogr and -where takes too long

I am running some ogr2ogr commands to extract some data from OSM dataset. Since I don't want to extract all features of some condition because I can't see them all and is takes too long I am trying to ...
user avatar
  • 701
1 vote
1 answer
31 views

Why does OSGEO/OGR add a third dimension to my 2D geometry?

When I instantiate a new wkbPoint geometry and give it only two coordinates, I expect it to be specifically 2D. However, a third coordinate automatically gets added as 0. See my code below: from osgeo ...
user avatar
  • 1,717
1 vote
1 answer
76 views

Geometry transform gives unexpected result (OGR, Python)

Transformation query PostGIS: SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT (16.0317217831498 45.0589613134642)',4326),3857)) Result: POINT(1784643.10543967 5630808.51923201) These ...
user avatar
  • 343
5 votes
3 answers
551 views

How to create variable distance buffers around polygons in Python

I have a shapefile of polygons and I would like to create buffers around the edges of each polygon. However, rather than use a single buffer distance for all of the polygons, I am trying to find a way ...
user avatar
2 votes
1 answer
60 views

OGR create polygon giving four corners from raster pixel position

How do I create a geometry from pixels positions in GeoTiff? ds = gdal.Open("image.tif") myarray = np.array(ds.GetRasterBand(1).ReadAsArray()) shape = ogr.Geometry(ogr.wkbLinearRing) And ...
user avatar
0 votes
0 answers
44 views

OGR Python created polygon from lon and lat instead of pixel position

I got a raster in WGS84 UTM zone 34N (EPSG:32634). And I am creating a polygon that represents the raster extent like this: import ogr import gdal raster = gdal.Open(tif) transform = raster....
user avatar
1 vote
1 answer
34 views

ogrmerge with list of input file names from a text file

How might I feed ogrmerge the list filenames to use as input from a text file? Obvious things like the below do not work; there's no indication from the doc page that it's supposed to. Still this has ...
user avatar
  • 27.5k
1 vote
1 answer
81 views

Can OGR SQL dialect be used with GeoPackage?

I'm using GDAL (3.3.1) Python (3.8.11) bindings to process vector layers and am trying to use OGR SQL dialect to filter the layer, like this: sql = f"SELECT * from {out_lyr.GetName()} WHERE ...
user avatar
  • 1,776
0 votes
1 answer
83 views

osgeo/ogr function that smooths geometry/vertex like qgis/processing toolbox/smooth

In QGIS, I want smooth a shapefile/vector's vertices. I can use QGIS/processing_toolbox/smooth. If I want to programmingly achieve this using osgeo/ogr/gdal, which function should I use?
user avatar
  • 109
3 votes
1 answer
541 views

Opening DGN using Python

I'm trying to open a DGN file with Python. I've tried with OGR: driver = ogr.GetDriverByName("DGN") file = driver.Open("C:\path_to_dgn\example.dgn") which returns a NoneType ...
user avatar
  • 33
0 votes
1 answer
67 views

Creating LineString geometry from Point geometries with Python's OSGEO/OGR library

Is it possible to create a LineString object with Python's osgeo/ogr library starting from multiple Point objects? For example, I know from the Python GDAL/OGR Cookbook that I can create a ...
user avatar
  • 1,717
1 vote
1 answer
56 views

Creating Python OSGEO/OGR geometry with M-values (not using WKT)

I am trying (and failing) to generate M-value geometries (e.g. POINT M, POINT ZM, LINESTRING M, ...) with Python's osgeo/ogr library. Here is what I've tried to far: import ogr # Use OGR specific ...
user avatar
  • 1,717
1 vote
1 answer
97 views

How do you preserve the ID field when using the osgeo/ogr/gdal VectorTranslate function in Python?

When using the Python osgeo/gdal/ogr library, how can I force the feature ID column (e.g., "OBJECTID" or "FID" columns) to be preserved in the output file? I thought I would just ...
user avatar
  • 1,717
5 votes
1 answer
135 views

QGIS Stand alone python script terminating problem

I want to write Python standalone QGIS script to layout export and my code is as follows: import os from qgis.core import ( QgsVectorLayer,QgsProject, QgsWkbTypes,QgsVectorLayerExporter,...
user avatar
1 vote
1 answer
223 views

How can I use the Python osgeo/ogr library to export a feature layer to CSV with geometries coded as WKT?

How can I read in a layer's data using the python osgeo/ogr library and then export the whole attribute table and an extra column with the geometries coded as WKT to a CSV format? I know that this is ...
user avatar
  • 1,717
0 votes
0 answers
8 views

Iterating a OGRMultiPoint to extract long/latt/depth data from "SOUNDG" layer (GDAL/OGR C++)

How are the begin() and end() functions on OGRMultiPoint used: While getting the first point is done by casting to an OGRPoint, how do I get access to the remaining points? Presumably iteration is the ...
user avatar
  • 1
1 vote
0 answers
67 views

Use relative path in VRT with VSIZIP

I'm trying to load a GPKG file into QGIS by a VRT file. The vector is inside a ZIP. So I'm using the vsizip. I would like to use just relative paths. But when I try to load it, the new layer comes ...
user avatar

1
2 3 4 5
21