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

Deleting features with Null value in attribute field

I have polygonized a single band raster and created an area field. I want to keep the 10 largest polygons by area and delete the rest. The following script computes the area for all polygons and sorts ...
1
vote
1answer
34 views

Sort and create attribute field to the shapefile

I am creating a shapefile layer and adding an 'Area' attribute field using the following script: # Create shapefile layer drv = ogr.GetDriverByName("ESRI Shapefile") dst_ds = drv.CreateDataSource(...
2
votes
0answers
45 views

Determine which points in a CSV are within a shapefile polygon using GDAL / OGR in Python [closed]

I have a csv file containing columns with latitude, longitude and some values, and a shapefile with a few polygons. Some of my points/rows in the CSV are within, and some outside the shapefile ...
2
votes
0answers
26 views

Reprojecting a shapefile Error

I am trying to write a function to reproject a vector file , by taking the original shapefile as input and giving out the name of the reprojected layer . Though when I call this function I get an ...
0
votes
0answers
13 views

How to use OGR layer creation options for QGIS Processing algorithm outputs

When saving outputs from Processing algorithms, is it possible to use OGR's layer creation options à la ogr2ogr? In my case, I'm trying to save .geojson outputs from the Refactor Fields tool with the ...
3
votes
0answers
40 views

Multi-part geometries do not themselves provide the array interface

So initially I had multiple perpendicular lines along a coastline. Next I clipped these lines based on polygons along the coastline,such as the follwing. I am trying to use this resulting shapefile ...
1
vote
0answers
16 views

GPX driver not working with vsicurl

I want to access a couple of GPX files online to extract the tracks and waypoints for some feature classes. When I download the files, ogrinfo (version 2.4.1 on a Mac)works fine. ogrinfo /Users/...
1
vote
1answer
41 views

How to filter date values using OGR 2.4.0?

I am trying to replicate a working Oracle SQL query into ogr2ogr, but having issues with a date field where clause. My query is: select BLOCK_STATUS_DATE, GEOMETRY from WHSE_FOREST_TENURE....
1
vote
1answer
34 views

GDAL Warp cutline invalid

I'm attempting to crop a raster with gdal warp using python bindings, the code works fine as I use it to crop a raster approximately 3k times, of which a couple fail with the following error and ...
3
votes
0answers
64 views

Setting DXF colors via Fiona

One might expect that the "Color" CAD field would control this, but the driver doesn't allow it to be set. schema = {'Layer': 'str', 'Color': 'int'} with fiona.open(path, 'w', 'DXF', schema=schema) ...
0
votes
1answer
34 views

Return all results from join of non-spatial CSV to spatial data using ogr2ogr and SQLite dialect

I am attempting to carry out a simple join of a non-spatial CSV to a GeoJSON data source using ogr2ogr an its built-in SQL capabilities. I would like to use the SQLite dialect to carry out the join. ...
1
vote
1answer
32 views

Set metadata for a shapefile (GDAL/OGR Python bindings)

I'd like to set a metadata value within a shapefile using Python bindings. I'm using the SetMetaData() / GetMetaData() methods within GDAL (gdal.org/python/osgeo.ogr.MajorObject-class.html). I've had ...
4
votes
1answer
64 views

Join non-spatial CSV to GeoJSON data source using ogr2ogr and SQLite dialect

I am attempting to do a simple join of a non-spatial CSV file to a GeoJSON data source using the built-in SQL capabilities in ogr2ogr. I have successfully managed to do this using the OGR SQL dialect ...
1
vote
0answers
31 views

ESRI FIleGDB API dll failure: ogr2ogr can't recognize File GDB as driver type

I have been trying this for a day or two now, and I have followed the instructions listed here: How to add support for FileGDB (Esri file gdb API) driver in fiona but for the life of me I can't ...
1
vote
0answers
34 views

Invalid SRID in PostGIS when importing data by ogr2ogr

I am using PostgreSQL 12 with PostGIS 3.0.0 and GDAL 3.0.0 to copy data in it. The command I am using is: ogr2ogr -f "PostgreSQL" PG:"host=127.0.0.1 dbname=db user=user port=5432 password=1" "file....
0
votes
0answers
44 views

Disabling OGR_GPKG_FOREIGN_KEY_CHECK option in QGIS

I am trying to load a bunch of vectors and rasters in a geopackage file. I was able to load few vectors but then all of a sudden the following warning popped up preventing me to load any more vectors: ...
1
vote
1answer
38 views

Create a point from a lat/long list using GDAL

I have a shapefile with a bunch of wildfire perimeter data, and a dataframe with lat and long columns about the lat and long of fire origin points. The information is not connected except by date, so ...
0
votes
0answers
26 views

Simplifying complex/overlapping polygon using GDAL/OGR

Is there a GDAL/ogr implementation of this paper? http://www.cis.southalabama.edu/~hain/general/Theses/Subramaniam_thesis.pdf It outlines a really nice way to clean up potentially overlapping ...
2
votes
1answer
49 views

ogr2ogr: 'ERROR 1: Wrong field type for ID' with primary key

I have a shapefile with the following structure: I'm trying using ogr2ogr to import the above shapefile inside my PostGIS database with the following code: ogr2ogr -append -f "PostgreSQL" PG:"host=...
1
vote
0answers
27 views

Improve OGR SQL query for polygon intersection using WKT geometry

I want calculate the intersected area between a shapefile and WKT geometry. My target big layer: a.shp My query small layer: 'POLYGON((1150046 1264030, 1160100 1263793, 1160079 1260606, 1150218 ...
1
vote
0answers
32 views

Union multiple layers with OGRVRTUnionLayer

I'm trying to union overlay layers using OGRVRTUnionLayers. However, it keeps the new records on new rows as opposed to appending the data to the same row (So you would expect to get back all data but ...
0
votes
1answer
21 views

Query polygons using ogrinfo but not generate a new layer

I want to list the polygons in my layer A that intersects other polygon B, using ogr. The desired result is similar to "Select by location" tool in QGIS or ArcGIS Desktop, where I expect an index of ...
0
votes
1answer
65 views

Loading color table (.csv) file to interpret raster data using C#?

I have a raster (GeoTIFF .tif file) that is stored in three bands (Red, Green, Blue), with each band's data type as a byte. I have a separate color table in the form of a .csv file, that stores a ...
0
votes
0answers
46 views

Clip two shapefiles in Python using only OGR results in error Segmentation fault (core dumped)

Is it possible to clip two polygon shapefiles using only the ogr library? It has to be a native Python solution, so subprocess.call(['ogr2ogr', '-clipsrc', ...] ) is not what I'm looking for. ...
1
vote
0answers
43 views

How can I easily determine the precision of an OGR geometry?

I'm writing a python tool to update some river catchment boundaries and keep running into geometry errors, such as WARNING: TopologyException: Input geom 1 is invalid: Self-intersection at or near ...
0
votes
1answer
17 views

OGR Merge split part of basename

ogrmerge.py -single -o merged3.shp *.shp -src_layer_field_content {DS_BASENAME} let's me painless merge several shapefiles into one and adds a new field with the basename of the shapefile. Is it ...
0
votes
1answer
82 views

Getting string attribute from a shapefile with GDAL Feature.GetFieldAsString(name) returns incomplete value

I read a shapefile (zipped) with GDAL library in C#. Shapefile contains .cpg file with "UTF-8" encoding specified. When I call Feature.GetFieldAsString(attributeName) some of the attribute values get ...
0
votes
0answers
39 views

Error while performing an intersection of a point and a multipolygon

I'm willing to build a tiny service that given a point location, it searches within a multipolygon, which polygon object it is intersecting. My current development is defined as this: from osgeo ...
2
votes
0answers
28 views

GDAL osgeo for python treating Z dimension differently

I have a space defined by a polyhedral surface, and I would like to check if a point is inside this space, and I would like to do this in python with gdal. After trying the default installation of ...
3
votes
1answer
88 views

Accessing OGR driver options using OGR/GDAL in Python?

Using OGR in Python, I am attempting to modify the driver settings for S57. I am able to read the meta data from the driver as follows: import ogr driver = ogr.GetDriverByName("S57") driver....
2
votes
0answers
69 views

Applying filter on the geometry for a given feature?

I have multiple layers, with multiple features, where I am interested in extracting information from a given feature within a rectangle. I am able to achieve this using the following filter, ...
3
votes
1answer
44 views

Find duplicate point geometries in a shapefile [closed]

How to find a duplicate point geometries in point shapefile (around one lakh geometries) using Python OGR/GDAL
2
votes
1answer
59 views

Making polygon shapefile from unsorted point shapefile?

I have a point Shapefile with unsorted feature ID's (FID). I want to convert the same point file into polygon Shapefile by using python gdal/ogr. I got the help from link1 and link2. I'm able to make ...
1
vote
1answer
51 views

Cast 3D geometry as 2D for ogr2ogr GeoJSON

I'm trying to take a shapefile that can be downloaded here (specifically the shapefile titled PVS_19_v1_vtd_21031.shp), convert it from EPSG:4269 to EPSG:3857, and output the GeoJSON into CSV with ...
3
votes
2answers
534 views

How to rasterize individual feature (polygon) from shapefile using GDAL/OGR in Python?

I would like to convert the individual records (polygons/features) of a shapefile to raster using GDAL/OGR. Here is the example shape and the mask raster. Rasterizing the full layer with all records (...
1
vote
1answer
116 views

Extract data from osm.pbf with GDAL

I tried osmosis, osm2pgsql, osmfilter, and probably most of OSM related tools in order to extract polygon rivers and water bodies. Among the tools, OGR is intuitive and returns good results so far ...
1
vote
1answer
125 views

Cannot access LibKML driver using OGR in Python

I am trying to read a kmz file using OGR in Python. I believe the standard driver for reading .kmz files is LibKML (Can ogr2ogr read .kmz files? How?), but I am only getting None when I am building ...
2
votes
1answer
53 views

Unclosed linestring to polygon works with QGIS but not with PostGIS

Just like the title, I am extracting OSM riverbank and a lot of riverbanks in OSM is in 'unclosed' linestring. This is the original river shape i extracted from OSM In order to polygonize the ...
2
votes
1answer
110 views

GDAL Warp Memory Datasource as Cutline

I am attempting to use a memory vector to crop a raster using GDAL warp but I get the following error: ERROR 1: Cannot open <osgeo.ogr.DataSource; proxy of <Swig Object of type '...
0
votes
0answers
32 views

Possible to import current version (v2) of the SQL Server Spatial binary format with QGIS/GDAL?

I'm running QGIS 3.4.3 on a Windows 10 machine and when loading vector layers from our MS SQL Server version 12 everything seems to be working great. No problems connecting or visualizing the data. ...
3
votes
1answer
102 views

How to change the field value of a specific feature in a Shapefile using GDAL/OGR?

I am trying to change the field value of a shapefile, but only in some specific features. However the code I have changes the value for all features in the shapefile. Is there any way of accessing the ...
1
vote
1answer
67 views

Finding GDAL Build Format List?

I am building GDAL from source to limit the list of supported drivers however I cannot find a definitive list of formats and their appropriate shorthand names to use in my ./configure list to set them ...
2
votes
1answer
49 views

ogr2ogr cannot append of truncate PostGIS table

I am reading in GML data to a specified PostGIS schema. This is part of an automated job so and the db table might include views so I don't want to drop the table each time the script is run. EDIT: ...
0
votes
0answers
29 views

Error with Datetime fields when loading Tab file to SQL Server using OGR2OGR

I have a MapInfo Tab file that needs to be loaded to a MSSQL Server DDBB in a scheduled basis and I want to use OGR for this task. The tab is going to be appended in an existing DDBB table that has ...
2
votes
2answers
145 views

OGR: Load layer with sql statement and write to new data set

I am having difficulties after loading a shapefile with a sql statement with ogr. The layer and its features seem to be correctly loaded. Still I am not able to write them into a new shapefile or pass ...
1
vote
0answers
34 views

Select features of a shape which are not in another shape

I have a shape with some features (let's say 100) and a second shape with some of this features (50) buffered (5 meters inside buffer). I want to select and write in a new shape every feature of the ...
0
votes
0answers
34 views

Export OGR feature style data from QGIS for use in GeoPDF

I have a fully formated map in QGIS from which I wish to make a GeoPDF. I followed this and this tutorial and generated a simple version of my map without much problems. I am however looking for an ...
2
votes
1answer
53 views

GDAL SQLite geometry error

I am having the following issue writing points to a SQLite file using ogr with SPATIALITE enabed: ERROR 1: Cannot insert feature with geometry of type POINTZ in column GEOMETRY. Type POINT expected ...
0
votes
1answer
41 views

gdal FlattenTo2D makes geom null

I have a df that has geoms as ogr geom in 3D. I was trying to convert to 2D but it empties out the geom. ipdb> df['default_geom'][0] <osgeo.ogr.Geometry; proxy of <Swig Object of ...
0
votes
0answers
28 views

What is the geom_type at CreateLayer() in ogr for xyz-GeoJSON?

My GeoJSON-File is a Multipolygon which creates several triangles with a X, Y and Z coordinate. Z determines the height of the specified point for X/Y. If i try to render my GeoJSON into a shapefile ...