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
2answers
33 views

Detecting if a point is inside a polygon with Python 3 and OGR

I am working in Python 3.7 using ogr to check if a point is inside a polygon. Here I put the code. The result in geom is not compatible with the tuple list data type used by the point_inside function. ...
0
votes
2answers
27 views

Compare multiple projection strings to shortlist unique projections

I have a list containing multiple projection strings. Each string is unique but there are some string which are same projections despite being different. [ "PROJCS[\"...
0
votes
1answer
35 views

Get input layer extent as new GeoJSON polygon on the command line

Starting from a GeoJSON file containing a country boundary polygon, I would like to obtain a rectangular approximation: another GeoJSON consisting of the bounding box/envelope of the original polygon. ...
0
votes
1answer
36 views

ogr2ogr SHP to MSSQL import leaves geometry column empty

I am trying to import a Shapefile with polygon features into MSSQL database with this command: ogr2ogr -f "MSSQLSpatial" "MSSQL:server=***;uid=***;pwd=***;database=***" "D:\...
2
votes
0answers
15 views

How to use WHERE IN clause with ogr2ogr [duplicate]

I am exporting some tables from PostGIS to a geopackage. My command to do is task is as follows ogr2ogr -append -f GPKG E:\workspace\test.gpkg PG:service=XXXX -where app_einzugsgebiet.hauptgemeinde=...
0
votes
1answer
68 views

ogr.BuildPolygonFromEdges fails on my multiline

Using python ogr, polygon = ogr.BuildPolygonFromEdges(multiline) fails for the following multilinestring: Does anyone know why? It throws the error: RuntimeError: OGR Error: General Error with ...
2
votes
1answer
49 views

OGR2OGR import to SQL from geometry to geography

I'm trying to import a shapefile to SQL Server 2019. This command works: ogr2ogr -f "MSSQLSpatial" "MSSQL:server=[myserver];database=test;tables=CAPZONE;UID=[myuser];PWD=[mypassword];...
1
vote
0answers
33 views

Deleting GDAL created raster

I am simply trying to delete a TIF that I created with GDAL. I have tried, simply, to use shutil which errors with: NotADirectoryError: [WinError 267] The directory name is invalid: 'T:/p003M01p0001/...
0
votes
0answers
11 views

How to create a PGDUMP from LVBAG format using ogr2ogr?

I am trying to figure out how to use this GDAL driver to create a SQL dump, using the ogr2ogr commandline. I have tried the following: ogr2ogr -oo AUTOCORRECT_INVALID_DATA=YES --config PG_USE_COPY=YES ...
2
votes
1answer
36 views

How can a spatial reference system be corrupt per OSR while valid per QGIS?

I have this coordinate reference system defenition: GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM[&...
1
vote
1answer
36 views

Python GDAL/Ogr Weird 3 Axis Output [duplicate]

I have this code: driver = ogr.GetDriverByName('KML') data = driver.Open(kmlFile) layer = data.GetLayer() geom = nextFeature.GetGeometryRef() print(geom.ExportToJson()) I am trying to export any ...
2
votes
0answers
21 views

SIGSEGV when loading vector file with QgsVectorLayer class, yet ogrinfo looks valid?

I have a program set up as part of a QT application written in C++ to overlay data on a KDE Marble map, and am using the C++ API from QGIS to achieve this. I create the vector file as a GeoJSON by ...
0
votes
0answers
35 views

How to interpret what each return means from an OSR function?

I have searched internet for the documentation on what different returns from OSR functions like osr.SpatialReference().IsProjected(), osr.SpatialReference().Validate() means but I couldn't find ...
1
vote
0answers
68 views

OGR error: file location not a directory [closed]

I have an Excel file that I converted to CSV. Then I used MMQGIS to geocode CSV with web service. Then I use the OpenStreetMap as the type of web service. I make sure the to be converted file is going ...
2
votes
1answer
58 views

Merging CSV layers (XYZ files with point coordinates)

I have list of many XYZ files with points without header an space delimited. Example: -877500 -1014000 471.95 -877500 -1013995 472.28 -877500 -1013990 472.61 -877500 -1013985 473.04 -877500 -1013980 ...
0
votes
1answer
25 views

Geometry geografic transformation with OGR, OSR - UTM to Degree

I am trying make a geotransformation from UTM coordinates to decimal degree coordinates, but i have only zeros as result... I must be missing something, i already take a lock on other users codes but ...
-1
votes
1answer
17 views

Should a GDAL vector dataset have a geotransform?

For example: Does a shapefile have a geotransform? The answer is probably: No, a vector dataset does not have a geotransform, because the purpose of a geotransform is to transform between projection ...
0
votes
0answers
29 views

QGIS does not recognize projection of ESRI geodatabase file (.gdb): How to set the projection so that QGIS does regonize it?

I want to load an ESRI geodatabase file into a project in QGIS and I am new to working with databases in QGIS. When I try to do this the layers from the database are loaded without any CRS or it seems ...
4
votes
1answer
80 views

Python - Correct way of closing ogr.DataSource() objects

I learned that I need to close objects that I open, usually using a with open(): statement that does the closing for you after leaving it. With GDAL/OGR, this does not work and objects must be closed ...
4
votes
1answer
85 views

Changing field values on a attribute table using GDAL/OGR (ESRI Shapefile)?

I am trying to create a new column on attribute table of my shapefile. This table must be the FID formatted with 4 (or any number) digits (for instance: 0 = 0000, 1 = 0001, 2 = 0002...) but I just can'...
0
votes
1answer
41 views

OGR Resetting SetAttributeFilter and SetSpatialFilter

This is more of a behavior question about OGR. When I set the spatial and attribute filters like so: self.ogr_layer.SetSpatialFilter(clip_geom) self.ogr_layer.SetAttributeFilter("MyField =...
1
vote
1answer
52 views

How to override shapefile geometry type in OGR

I'm new to ogr. I tried to copy a WFS layer to shapefile using CopyLayer but I get this error. ERROR 6: Geometry type of `Multi Curve' not supported in shapefiles. Type can be overridden with a layer ...
1
vote
1answer
20 views

ogr export gdb to PostGIS doesn't contain geometry for display in GIS [closed]

I'm currently trying to export a .gdb containing polygons to PostGIS which other users will need to display using any software like QGis or ArcGIS. I'm using ogr fom osgeo to export the GDB to PostGIS ...
0
votes
1answer
44 views

OGR - 'NoneType' object has no attribute 'CreateLayer'

I have an error when i wan't to create a Shapefile layer with OGR. When I run my script for the first time, everything all right, layer is well created. But when i run it for the second time ...
1
vote
0answers
54 views

Removing and overwriting layer from interface within Plugin

I wan't to create a shapefile with a QGIS Python plugin. If the same shapefile is already in QGIS Interface, i need to remove it, delete it from the computer, create the new layer and load it. When I'...
0
votes
0answers
21 views

Creating shapefile using GDAL OGR? Script runs but does not create the files

This script runs but does not create the shapefile files. It works, however, if I were to replace the driver for GeoJSON and create a GeoJSON file. Context: I'm working through Chris Garrard's "...
1
vote
0answers
37 views

Creating and writing GeoPackage Lookup Tables

I am writing Python using OGR to create and write a single vector layer in a GeoPackage. Some of the feature attributes need to be foreign keys to several lookup tables. My needs are completely ...
2
votes
1answer
89 views

Geometry buffer updating with ogr2ogr

I am trying to modify a dataset by replacing the geometry of each feature by its buffer. I try to do it directly, in update mode (not very secure I know). Here is what I tried: ogr2ogr -update test....
1
vote
0answers
104 views

Attribute error: 'NoneType' object has no attribute 'GetLayer' geoPDF

I have written some code to export projection information from geoPDF’s. For some reason on some of the files I get the following error and other are fine. AttributeError: 'NoneType' object has no ...
0
votes
0answers
70 views

How to Access/Write to a Shapefile in S3 Bucket using BOTO3 and GDAL

I'm trying to access and make edits to a shapefile that's located in a zip on an S3 bucket. So far I've used /vsizip/vsis3/ to access the zip file that the shapefile in question came in. I've made the ...
0
votes
1answer
38 views

Where is date information in OpenStreetMap data files?

I would like to access temporal information from OSM datafiles (not the changeset file) Files *.osm.pbf downloaded from the GeoFabrik website or another OSM mirror do not show the following ...
1
vote
0answers
27 views

Generate essential grid covering polygon with OGR & Python

I'm trying to come up with a method to recreate the type of grid shown below. The grid is using a custom projection measured in meters. each cell is 256 x 256 meters. Ideally I'd like to easily use ...
0
votes
0answers
44 views

How can I snap irregular GPS point data to regular points of a route?

I have irregular GPS points in several shapefiles with meteorological parameters of a mobile measurement campaign. In order to compare the different shapefiles I would like to snap the irregular GPS ...
0
votes
2answers
151 views

Calculating area of a lat,lon polygon in some useful units

How do I tell the default geo spatial reference system? I have this code: wkt = "POLYGON ((lon1 lat1, lon2 lat2, lon3 lat3))" poly = ogr.CreateGeometryFromWkt(wkt) print "Area = %d"...
1
vote
0answers
34 views

ogr2ogr: casting field to string

I am attempting a simple data extraction from an Oracle database to a CSV file using ogr2ogr.exe (the version packaged with QGIS 3.8 i.e. ..QGIS_3.8\bin\ogr2ogr.exe ) I have a field ("Mapsheet&...
0
votes
0answers
100 views

OGR Geometries Error When Writing to Disk: 'Incompatible geometry for operation'

I am working on a piece of code that does a pretty complex computation using GPKG layer feature areas, I then calculate several new fields . Finally, when I try and write the results back to disk, I ...
2
votes
1answer
97 views

Find out points outside the polygon

I have a shapefile with geometries of different regions. Also I have a list of coordinate points(field_lonlat), I want to consider only those points of the list which are outside the polygon ...
1
vote
1answer
17 views

Find sublines, given initial and final offsets, via the command line

I have a CSV file that looks essentially like this: id,id_wkt,start,end,wkt 11,11,0,43,"LINESTRING(3.3623676 51.3132714,3.3626663 51.3130068,3.363068 51.3126811,3.3636323 51.3122504,3.3640754 51....
2
votes
1answer
115 views

Buffering a polygon to match an area

I have a large polygon (A) with a specific area. I also have another polygon (B) with area less than polygon A. I want to buffer the polygon B so that its area becomes equal to the area of A. from ...
1
vote
1answer
30 views

SetAttributeFilter Issue [closed]

I am following the book "Geoprocessing with Python" and I have encountered an issue with my code: from osgeo import ogr shp_ds = ogr.Open('path/to/data') volcano_lyr = shp_ds.GetLayer('...
1
vote
0answers
32 views

Determine the feature dataset of a layer in an Esri file geodatabase

I have an Esri file geodatabase with a single feature dataset. Using ogr and python ds = ogr.Open('myfile.gdb') for i in range(ds.GetLayerCount()): layer = ds.GetLayerByIndex(i) I can iterate ...
3
votes
0answers
47 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
80 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
196 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
127 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
17 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
53 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
185 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
64 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
19 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. :...

1
2 3 4 5
20