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
3
votes
0answers
24 views

Getting the results of a PostGIS query to a file with ogr2ogr with low memory usage

I have a PostGIS query returning geographies and attributes. The result set is deterministic and ordered (so OFFSET and LIMIT work for getting subsets). The result set of my query would exceed my RAM ...
0
votes
0answers
10 views

Rasterize feature class in geodatabase using gdal.Rasterize (Python API)

I am trying to rasterize a polygon data set (feature class within a file geodatabase) using the GDAL Python API. I am using gdal.Rasterize (Actually, it would be very interesting to know what the ...
2
votes
1answer
40 views

Export PostGIS data from one database to another with multiple geometry fields (ogr2ogr)

I am trying to copy the data from one database to another database. Both the source and target tables have 2 geometry columns -- a polygon field and a point field. There are NOT NULL constraints on ...
0
votes
1answer
39 views

Using gdal.Warp() in Python to clip a raster to a shapefile is producing errors

I have some super simple code that I'm using to clip raster data to US Highways. However, the clip isn't producing pixels for everywhere that the shapefile intersects the raster and I cannot figure ...
0
votes
0answers
7 views

In GDAL are there equivalent vector functions for gpkg files similar to those provided by GetRasterBand?

I am using GDAL (C++) to read raster files into a buffer for example: cplErr = resDS->GetRasterBand(1)->RasterIO(GF_Read, xPixelUL, yPixelUL, pWidth, pHeight, buff3, pWidth, pHeight, GDT_Float32,...
0
votes
0answers
12 views

LIBKML using Python very slow - using OGR to transform Shapefile to KMZ/KML

I am trying to convert a shapefile to a KML (or KMZ) using Python, and OGR and the LIBKML driver. The process appears to hang, with the kml/z created, but sitting at 1kb for 5+ minutes. The input ...
1
vote
1answer
37 views

Rasterize polygons using gdal/ogr python API

My understanding so far is that 'gdal' is used for raster data and 'ogr' for vector data. Given this I have been trying to rasterize a polygon data set (output raster metadata is given by a raster ...
0
votes
0answers
30 views

layer.SetAttributeFilter() does not return correct number of features

I have been using GDAL/OGR's layer.SetAttributeFilter() in a Python code to select a subset of features in a layer and save to an output shapefile. However, I am not getting the result I expect and ...
0
votes
0answers
15 views

OGR to OGR looking for WFS to MSSQL code

I'm trying to get a WFS converting to MSSQL using Ogr2ogr. I have used the following code but get an error of unable to open WFS source. Here is my attempt. Path/UID/Password are all correct. :...
0
votes
0answers
33 views

How to speed up ogr2ogr process on giant geodatabase

I have a geodatabase that has over 193 million polygons. I have a process that gets a small subset of this .gdb based on an inputs' extent, for thousands of inputs, using ogr2ogr. I am looking for ...
0
votes
0answers
56 views

Optimising Cross Join PostGIS Query

I have tried performing the query shown below via ogr2ogr and the gpd.GeoDataFrame.from_postgis() method in geopandas. from osgeo import ogr import psycopg2, os import geopandas as gpd import pandas ...
1
vote
1answer
33 views

ExecuteSQL on GDAL dataset fails when ORDER BY clause contains more than 1 field

using GDAL 3.0.4 on windows. Running an ExecuteSQL command on various datasets (shapefiles, geodatabases, ...) works in almost all cases except when i have an SQL query with an ORDER BY containing ...
0
votes
0answers
25 views

In command ogr2ogr add ogc_fid in output

I am executing the command ogr2ogr -nln "demodata" -lco GEOMETRY=AS_XY -t_srs EPSG:4326 -preserve_fid -f "CSV" "/tmp/demo.csv" "PG:host=localhost dbname=demo user=root password=root schemas=...
0
votes
1answer
29 views

GDAL/OGR python: geometryType change for linear ring?

I found something unexpected when trying to create a simple polygon, following the "cookbook" example in: https://pcjericks.github.io/py-gdalogr-cookbook/geometry.html from osgeo import ogr ring = ...
1
vote
1answer
21 views

OGR/OSR Lon Lat convention

When I project (lon,lat) coordinates I get a different result depending on the version of OGR/OSR. osgeo.version_info sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0) ...
1
vote
0answers
53 views

QGIS : OGR error when editing Geopackage layers : database is locked

I started to draw new polygons in a layer within an existing Geopackage that I previously created. However, after editing several layers, I sometimes (apart that it don't happen when editing one ...
1
vote
1answer
54 views

OGR/Python- Check whether or not points are in a polygon

I have two shapefiles, one points file and one polygon. They are in the same projection (Lat/Long). I would like to run a quick command-line command or a Python script with the OGR module that creates ...
0
votes
0answers
28 views

What should the GeometryField encoding be for a GeoJSON data source in an OGR VRT?

I am trying to produce a color gradient for a temperature map and I am using gdal_grid, specifically: gdal_grid -zfield "temperature" -a invdist:power=2.0:smoothing=0.0 -txe -72.5 -77.0 -tye 38.6 41....
0
votes
0answers
37 views

Merge with ogr2ogr creating multiple feature classes despite consistent -nln flag

I have a Python script that creates hundreds of individual shapefiles and in the end, merges them iteratively to one big geodatabase using ogr2ogr. I want one geodatabase output with a single feature ...
1
vote
0answers
32 views

Avoiding lock issues when running ogr2ogr concurrently

I have a Python script that does some stuff and then updates a big geodatabase with the resulting shapefile. I am running this in parallel so occasionally the ogr2ogr command will fail due to lock ...
1
vote
0answers
37 views

GPX to shapefile using OGR in Python [duplicate]

I am converting a GPX file to shapefile using OGR in Python. After converting it to .shp the time field only show 'date' and it excludes the time part. What could be problem in converting.
1
vote
1answer
118 views

Suppress warnings in Python/OGR

I have a process in Python using OGR via the API and the command line. I am tired of my logs being filled with various warnings (so many that it no longer prints after the first 1000). These happen in ...
1
vote
1answer
67 views

GDAL/OGR Clip Shapefile

I cannot find any solid info on this and its a pretty rudimentry GIS process. I have 2 shapefiles. One shapefiles is a single large polygon. The other is a larger multipolygon. I need to clip the ...
1
vote
1answer
277 views

Adding circle polygon to folium map (using OGR and Python) creates an oval - why?

I am new to OGR and Folium but learning fast. In short, I have an issue which I think might be a projection problem. Basically, I have three circles plotted in folium that work fine. Then I have a ...
0
votes
2answers
53 views

Projecting coordinates into different EPSGs gives inconsistencies

I am using 3 EPSGs: 4326 (WGS84), 3857 (Mercator) and 3035 (EU Copernicus dataset). I am trying to easily convert coordinates from one system to any other. To do so, I wrote a Coordinate class with ...
0
votes
0answers
22 views

Python/OGR layer.DeleteFeature() not working in GDAL v 2.2.2

I am trying to iterate through a feature class and, delete features based on a criteria. I am using GDAL 2.2.2 which according to this answer was supposed to have fixed the problem of datasets not ...
0
votes
0answers
26 views

ogr.driver.Open() not working on second execution

I have the following code. fn = 'C:/temp/file.shp' layerfields = QgsFields() layerfields.append(QgsField('ID', QVariant.Int)) ...
2
votes
1answer
57 views

Optimizing pixel extraction from GeoTiff using Python

I am creating IDF Curves for work using python and 30-minute rainfall rate rasters. There are 24 rasters per day and about two decades worth of data. I basically input lat/lon coordinates and my ...
1
vote
1answer
81 views

OGR Split a vector layer by attributes

With a Python script, I want to split a vector layer by attributes. For each unique value of a define field, I want to create a new layer with a name that contains this attribute in camelCase and with ...
0
votes
1answer
77 views

Create and use index with GDAL/ogr on shapefile

I'm using OGR and VRT to create a new shapefile from two distinct sources (CSV file and shapefile). It works well, but it is very slow. I want to make it more efficient, so I tried indexing my data ...
2
votes
0answers
34 views

Extract Geometry information from NMEA GGA sentence in SQLite database for display in QGIS via a Virtual Layer

I have a SQLite database containing a GGA sentence in one of its fields. I'd like to display this information as a POINT layer. I've looked at OGR Virtual Format solution as suggested here but I ...
1
vote
1answer
73 views

Create an ESRI Shapefile from WKT with OGR

I want to create an ESRI Shapefile layer from a CSV file. In my CSV I have several attributes (text, numeric) and geometry in WKT style. I have a problem with the geometry field wich is truncated to a ...
3
votes
1answer
71 views

Merge geopackages keeping layer structure

I have a bunch of geopackages for each state, and all have the same layer structure (same name and type). I'd like to merge the state level gpkg into a single gpkg, keeping the same layer structure, i....
0
votes
0answers
38 views

How to use OGREnvelope* function to GetExtent() using OGR/GDAL C++ API

#include "gdal/gdal_priv.h" #include "gdal/ogrsf_frmts.h" #include "gdal/ogr_api.h" void ShpfileRead(const char* name) { GDALAllRegister(); GDALDataset *poD1S; poD1S = (GDALDataset *) ...
0
votes
0answers
25 views

Unload QGSVectorLayer from Python script

I have a Python script that processes several country sized OpenStreetMap PBF files at a time. The problem I'm having is that: each time I open and process one of these files, I lose anywhere from ...
2
votes
0answers
20 views

For Spatialite databases in QGIS, why is the provider 'spatialite' sometimes and 'ogr' other times?

I have many spatialite databases that I use across a lot of projects and sometimes the Provider is set to 'spatialite' and sometimes it's set to 'ogr', seemingly arbitrarily. This causes issues when ...
2
votes
1answer
99 views

List of usable ogr-drivers for PyQGIS

When using the following PyQGIS line, I write a layer as a CSV into an output path. QgsVectorFileWriter.writeAsVectorFormat(lyr, outputPath, 'utf-8', lyr.crs(), "CSV", ...
1
vote
1answer
112 views

How do I transfer data from a geopackage to MS SQL server

I am trying to upload a geopackage (created with ogr2ogr though I don't think that matters) to a MS SQL Server 2008 instance. I can't access the instance with ogrinfo all I can get is C:\>...
1
vote
0answers
27 views

How does OGR detect what GEOS version I have?

I'm attempting to solve this error: ERROR 6: GEOS 3.8 or later needed for MakeValid. The version of GDAL I am running is 3.0.4 which was downloaded as a .whl from https://www.lfd.uci.edu/~gohlke/...
4
votes
0answers
31 views

Python osgeo/OGR not returning all features in PBF

I have a PBF file that is a limited export of the Nepal area. I'm trying to pull out all the adminstrative boundaries. If I use osmconvert to turn my PBF file into a OSM file, sure enough I see the ...
2
votes
2answers
78 views

Extracting layers from gdb and merging them?

I have a gdb folder which contains ~3000 multipolygon layers (with very few features on each layer). I would like to take around 100 of those layers and merge them together while adding a field to the ...
0
votes
0answers
31 views

Create vector mbtiles file from Shapely geometry using GDAL/OGR

I am looking for an example of creating vector mbtiles file from Shapely geometry using GDAL/OGR. Like this: from osgeo import ogr from shapely.geometry import Polygon poly = Polygon([(0, 0), (0, 1),...
1
vote
1answer
45 views

How can I get the points where two line shapefiles intersect?

I have two shapefiles that I want to compare and get the points where they cross. I would like to avoid opening QGIS or GRASS since I am trying to automate a process so I have been looking at OGR, ...
2
votes
0answers
49 views

Complex parametrized string to export gpkg in Python [closed]

I'm trying to write a Python script that does a process (in this case a buffer) iteratively. The input layer is always the same but, in each iteration, the name of the output file must change and It ...
1
vote
1answer
45 views

Shapefiles intersection with GDAL Python

I want to compute the area of the intersection for each geometry in two different shapefiles in Python with GDAL/OGR. Here is my sample code: def ogrIntersection(srcShpPath1, srcShpPath2): # ...
1
vote
1answer
20 views

Prevent OGR saving OSM points as features when exporting to GeoPackage

I'm attempting to export data from the points layer imported from an Open Street Maps pbf file to a GeoPackage file. In both the script I write to automate the export as well as when I export using ...
6
votes
0answers
73 views

OGR failing to unpack polygons and respective holes from shapefile

I'm trying to unpack shapefiles in Python (v3.7.4) using the GDAL-OGR library (v2.3.3). Each shapefile has only one feature containing multiple polygons with holes. They cannot be produced differently....
3
votes
1answer
521 views

How can I switch line direction from the Linux commandline?

I want to reverse the line direction for all lines in a shapefile from the Linux commandline (that is to say, using a script). Currently I'm using the SwapVectorDirection QGIS plugin which works well ...
1
vote
1answer
46 views

Creating shapefile layer with OSGeo4W shell

I want to create an new empty shapefile with OSGeo4W shell. Is there a command line like: gdal_create -f "ESRI Shapefile" -wkt "point" -srs "EPSG:31256" -o output.shp
1
vote
1answer
81 views

Setting Default Nodata burn value with GDAL Rasterize Layer

I am trying to rasterize a layer as follows: attr = 'N_CT' tif_driver = gdal.GetDriverByName('MEM') raster = tif_driver.Create(path, x_res, y_res, num_bands, gdal.GDT_UInt16) shp_driver = ogr....

1
2 3 4 5
19