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

learn more… | top users | synonyms

2
votes
1answer
348 views

need help for script checking topology using ogr in python

My main goal is to create a new feature indicating if the line features intersect each other as well as if they are not connected to a feature. My problem is how to identify the intersecting and not ...
0
votes
2answers
101 views

OGR GetX() returns always zero

I am trying to get the first x-coordinates of a polygon. However I only get zero in return. What could cause that? import os, sys, gdal, ogr from gdalconst import * driver = ...
2
votes
1answer
222 views

Convex Quadrilateral Polygons subdivision in equal parts using Python / OGR

Consider an irregular polygon (P) which has four vertices. I would like to subdivide P into smaller polygons as shown here http://i.stack.imgur.com/4SKhB.jpg In the old days I was using ArcGIS 9.3 ...
2
votes
1answer
231 views

OGR CreateLayer returns TypeError

I'm trying to create a shapefile layer based on the spatial projection of an already existing raster. (Ultimately, this will be used in gdal.Polygonize to get a shape from my raster data.) However, I ...
3
votes
1answer
292 views

Python - OGR: Distance different than in ArcGIS

I want to determine the shortest distance between a point and a line. I use the following Python script to do so. If I compare the result of the script with the result of ArcMap's Near Analysis, I get ...
4
votes
1answer
341 views

OGR Info - Check for spatial index?

If we want to get information about a vector layer (shapefile for example) we could use ogrinfo: ogrinfo -so myshapefile.shp mylayer This returns a lot of pertinent information about the shapefile. ...
2
votes
0answers
92 views

Custom python datasource to QGIS

I'm working on a homebrew spatial feature data format, and using Python to write it's API. It occoured to me that use some tool like QGIS to display my data would be very nice to have, for debug/test ...
2
votes
1answer
2k views

Installing GDAL with Java Bindings (gdal.jar) on Ubuntu 12.10

I am trying to build a postgis importer for mutliple shapefiles. After geotools took orders of magnitude longer than shp2pgsql to import my data, I decided to attempt to use the java bindings to GDAL ...
2
votes
1answer
58 views

QGIS QgsOgrProvider library

I asked a question here: http://stackoverflow.com/questions/14790463/qgis-copy-layer-in-c-plugin and I was suggested to find the library which provides QgsOgrProvider::createEmptyLayer() function. Can ...
2
votes
1answer
374 views

How to debug ogr2ogr ERROR 1: Did not get at least 2 values or invalid number of set of coordinates?

I'm trying to convert a government data contour GML (http://geo.data.linz.gv.at/katalog/geodata/hoehenschichten/2011/1m-Hoehenschichten.gml) to Shapefile. It seems like it was created by FME: ...
4
votes
1answer
228 views

How to use -lco options in gdal_contour?

I'm trying to create contours from geotiff raster with gdal_contour. My output format is Postgresql and I would like to ovewrite the existing table. When I do: gdal_contour -a 1 -f PostgreSQL -i 50 ...
4
votes
3answers
1k views

Python OGR: convert a point geometry into polygon

I'm writing a routine for creating the convex hull envelop around shapefiles of islands. I could read the data, extract polygons vertices into a geometry and then compute the convex hull. Now I need ...
3
votes
1answer
165 views

shapefile batch clip and merge combined

I have two shapefiles, one is polyline, the other polygon. For each polygon I would like to clip the polyline vectors inside. Using arcpy I already found part of a possible solution: ...
2
votes
1answer
84 views

How to interpret the OSGeo4w software version under Advanced Install option?

When choosing to install QGIS Desktop using the OSGeo4w advanced install option, I noticed that there are what looks like ambiguous software versions to choose. For example, currently QGIS Desktop ...
1
vote
1answer
87 views

SHAPE FILE to TIGER with OGR

How do I convert SHAPE FILE to TIGER using GDAL (OGR). I try but throw following error:(layer number)is not a known TIGER/Line layer.
3
votes
3answers
142 views

OGR: Meaning of “2.5D extension as per 99-402”

I'm looking at the enum defs in ogr_core.h. I see a bunch with comments that read: 2.5D extension as per 99-402. What in the world does that mean? Presumably it's referencing a spec or RFC? ...
3
votes
1answer
503 views

Simplify polygon in OGR

We use ArcObjects pretty heavily and simplify polygons using something similar to the ITopologicalOperation::Simplify(void). No tolerance is passed in as the parameter (it uses the XY tolerance of ...
13
votes
1answer
3k views

How do I get the pixel value of a GDAL raster under an OGR point without NumPy?

I am working on a computational model of the abundance of wild pollinators across a landscape. The model itself is complete, and I am now struggling with a post-processing step. I have my GDAL ...
5
votes
1answer
147 views

GDAL/OGR Determine if dataset is raster or vector

I am writing a script using the GDAL/OGR Python bindings and it is possible that the user may provide a raster dataset or a vector dataset as input. If the user provides a vector dataset, the script ...
2
votes
2answers
2k views

How do you open shapefiles with ogr2ogr

I'm following along the D3 tutorial, and on this line: ogr2ogr \ -f GeoJSON \ -where "adm0_a3 IN ('GBR', 'IRL')" \ subunits.json \ ne_10m_admin_0_map_subunits.shp run into the following ...
4
votes
1answer
458 views

Efficient computation of nearest distance for each point to closest polygon

I'm looking for a more efficient way to compute the nearest distance between features from 2 layers, in this example for each point the nearest distance to the closest polygon. Is there a more ...
4
votes
2answers
347 views

How do I Capture GDAL projection and create matching output (OGR or GDAL) shape files?

Working in C++, using GDAL and OGR: Depending on what the user has supplied for image input, I need to output point (or other) shape files in the same projection as the input raster images. The ...
4
votes
2answers
403 views

how to cast integer to float in an ogrinfo sql statement?

I have a shapefile for which I would like to add the values in a column. As the sum exceed the capacity of an integer, I need to cast values to a float. I tried the following: ogrinfo -sql "SELECT ...
2
votes
2answers
855 views

OSR Python testSR.ImportFromEPSG(4326) returns empty spatial reference

This is empty using Python .ImportFromEPSG(4326): import osr #this fails: testSR = osr.SpatialReference() testSR.ImportFromEPSG(4326) print testSR.ExportToPrettyWkt() #why did the import from EPSG ...
2
votes
1answer
398 views

How to bulk delete shapefile columns?

I have shape-file with next attribute table: - name of features, unique number for each feature of layer I must split shape-file by NAME field, but in result in attribute tables of layers should be ...
0
votes
1answer
662 views

Why do I get an OGR error when attempting to save an edited Shapefile?

I often get an ogr error when I try to save a shapefile after working on it in Qgis ( adding features, removing, modifying attributes.. ) The error says : "OGR ERROR : Attempt to delete shape with ...
1
vote
0answers
365 views

OGR-Driver GML axis order handling (GDAL, QGIS)

By default the OGR-Driver will swap the axis order to longitude, latitude for geographic coordinate systems. "Since OGR 1.8.0, the GML driver has coordinate system support. This is only reported ...
5
votes
2answers
1k views

Why does this simple Python OGR code create an empty polygon?

Please excuse my ignorance...I am new to Python OGR. I am trying to create a simple square polygon and fail...this produces an empty polygon. Where did I go wrong? from osgeo import ogr driver = ...
6
votes
1answer
288 views

How to detect a GDAL/OGR 'Warning'?

When I run a batch script using a GDAL/OGR program, I can detect if an error occured by checking ERRORLEVEL for the value 1. When using GDAL/OGR in python or .NET, I get an exception when an error ...
5
votes
2answers
1k views

How to create a shapefile consisting of 2 lines using Python OGR?

How would you create a shapefile consisting of 2 lines using Python OGR? First line is no problem, but how do you reuse MyLine and Feature objects to create the second line? Ultimately this will ...
2
votes
2answers
230 views

Why are the output point shapefile PRJ files empty?

I have tried evry thing I could find (using C++) to create a new .prj file for an output point shape file using OGR. While I get no compilation or execution errors and ArcMap accepts the file as a ...
6
votes
1answer
505 views

Geometry errors when importing data from ESRI file geodatabase to PostGIS

When I run the following command to import by data from an ESRI fgdb to postgis... ogr2ogr -f "PostgreSQL" -a_srs "EPSG:28355" -t_srs "EPSG:3857" PG:"dbname=tp_test user=postgres port=54321 ...
3
votes
3answers
704 views

DXF to georeferenced SHP

I know how to set projection and georeference bounds of scanned TIFF file, by using gdal, but I don't know how to do the same for vector file. For example I georeferenced TIFF file by using this ...
4
votes
3answers
406 views

ogrinfo bash script failure

I need to recursively document a bunch of Shapefiles using orginfo in many directories. For example, $ tree -P *.shp . ├── acfish2s │   └── acfish2.shp ├── airports │   ├── airport_runways.shp │   ...
8
votes
2answers
1k views

How to buffer a vector shapefile using ogr python?

I am trying to learn how to use ogr in python using the country and populated places datasets from http://www.naturalearthdata.com/downloads/50m-cultural-vectors/. I am attempting to use filters and ...
2
votes
0answers
145 views

Ogr: How to add layer description to dgn?

I have created a dgn-file using Ogr, but can't find a way to fill out the description for this layer programatically. (something like _dgnLayer.Description = "Highways") opts.Add("SEED=" + ...
7
votes
2answers
3k views

Generating GeoJSON with Python

Hi I want to programatically create a GeoJSON file using polygons from a shapefile but adding attributes from my own application. This is easily done for a shapefile: def ...
6
votes
2answers
470 views

Read an ArcGIS Feature dataset using GDAL

I am new to GDAL in Python and would like to use it to create a list of populated layers in a ArcGIS mdb Feature datasets. I have the code below that provides a list of all the populated layers but ...
2
votes
1answer
221 views

Ogr2Ogr: Failed to create GPX file output.gpx

When i try to export an shapefile to gpx using ogr2ogr. ogr2ogr -f GPX output.gpx D:\mypaste\input.shp -sql "SELECT Id AS name FROM layername" It gives me the following error "Failed to create GPX ...
4
votes
2answers
607 views

How to programmatically create exports from PostGIS database into different file formats (e.g. shapefile, dxf, dgn,…)?

Is there a kind of wrapper/library written in python which would enable me to programatically create exports from postgis database into different file formats (most common being, shapefile, dxf, ...
4
votes
1answer
5k views

Convert Shapefile to MySql

I have used Grass GIS imported a .shp file; I now want to export this file to MySQL. I understood that MySQL will contain the function of all three the files necessary in a Shape file system (.shp - ...
5
votes
1answer
449 views

Slow FileGDB Performance in GDAL

I am attempting to write many ASPRS LAS point files into an ESRI File Geodatabase using my compilation of GDAL 1.9.2. The FileGDB driver for GDAL/OGR appears to be incredibly slow when writing large ...
3
votes
2answers
538 views

Why does Ogr2Ogr Postgres import fail?

I have a lot of S57 files that need to be imported to PostgresDB. The process takes over 2 hours. In order to improve performance, I have tried using PG_USE_COPY to use copy instead of DB inserts. I ...
4
votes
1answer
330 views

How to use the OGR/GDAL configure options in QGIS python environment

I’m looking for a solution how to use the OGR/GDAL configure options (--config) in the qgis python environment. http://trac.osgeo.org/gdal/wiki/ConfigOptions Setting special configure options is ...
3
votes
1answer
364 views

Latest version of ogr2ogr fails with Layer Creation

I am able to successfully run ogr2ogr to add S57 data to PostgresDB. The version I use is GDAL 1.7.0b2, FWTools 2.4.7 and release date 2010/01/19 I upgraded my version to GDAL 1.9.1 and release date ...
5
votes
1answer
1k views

OGR Shapefile to CSV: Using Python to get WKT for multipart Polys.

Using ogr2ogr and python, I'm running into a wall with trying to create a csv with WKTs for a shapefile that contains multipart polygons. Currently this is this code I'm using (found it on interweb): ...
4
votes
2answers
1k views

Shape-file encoding problem in QGIS 1.9.0 (built with GDAL 1.9.2)

I have googled a lot but failed to find the answer. My configuration is: Ubuntu 11.10 Quantum GIS - 1.9.0-Master 'Master' (caae7b7) GDAL 1.9.2, released 2012/10/08 Shape-files refuse to open in ...
5
votes
1answer
401 views

GDAL.RasterizeLayer not ported to the C# bindings?

I am trying to use the OSGeo.GDAL.Gdal.RasterizeLayer(…) from GDAL 1.9.2 and it requires some SWIGTYPE parameters: OSGeo.GDAL.Gdal.RasterizeLayer( OSGeo.GDAL.Dataset dataset, int bands, ...
3
votes
1answer
207 views

msWFSGetFeature(): WFS server error. FLTApplyFilterToLayer() failed

I have the following code that generates a map with a couple of layers. var PIDS = ...
1
vote
2answers
361 views

How to use -where SQL in an ogr2ogr loop in GDAL/OGR (bash)?

I'm using the following code: while read line; do for att in $line; do ogr2ogr -where "newcode='$att'" -f "ESRI Shapefile" $OUTPUT/$att.shp $INDATA done done < $SCRIPT/newcodes.txt The text file ...