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

3
votes
3answers
136 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
472 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 ...
12
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
143 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
405 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
336 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
368 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
762 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
362 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
581 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
332 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
276 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
221 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
474 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
668 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
370 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
136 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 ...
5
votes
2answers
441 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
211 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
578 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
4k 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
421 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
498 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
311 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
340 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
361 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
193 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
335 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 ...
3
votes
2answers
928 views

How to Open a File Geodatabase with ogr? [duplicate]

Possible Duplicate: How to access feature classes in File Geodatabases with python and gdal? I have installed: python-2.7.msi GDAL-1.9.1.win32-py2.7.exe import ogr driver = ...
0
votes
1answer
996 views

How current is GDAL in Java

I have used the ogr2ogr to import various formats to Postgres and have used GDAL utilities. Is there a complete Java port for these tools? Or are they simply wrappers calling JNI to C++ code? I have ...
4
votes
1answer
929 views

How to programatically populate a shapefile field with polygon areas in OGR?

I'm trying to programatically populate a shp field with polygon areas: import sys import ogr ds = ogr.Open( 'tttttttttt.shp', update = 1 ) if ds is None: print "Open failed./n" sys.exit( 1 ...
2
votes
1answer
920 views

Opening .lyr file via rgdal/OGR

According to this answer I can read in a .lyr file via OGR as long as it was made with ArcGIS version 10. I have such a file (from the ArcGIS Maps & Data page) but I can't quite make R's readOGR ...
1
vote
1answer
371 views

ogr: how to use epsg database for RD New projection?

I'm trying to assign this EPSG projection to my newly created shapefiles using ogr. The OGR Projections Tutorial says: ...any geographic coordinate system in the EPSG database can be set by it's ...
2
votes
2answers
591 views

Updating polygon geometry: deleting inner rings with python

I've searched, but can't find clear explanations how can I simply delete inner rings from existing polygons with python or extract outter rings and overwrite the geometry. Seems GDAL/OGR should be the ...
3
votes
3answers
664 views

How to merge a large amount of polygon-features in a script?

We have a very large shapefile with over 30000 features and want to merge it with a script on a server. Currently we try it with QGIS, but the processing takes way too much time. Is there a way to do ...
2
votes
1answer
158 views

Why does ogr's CreateLayer() return None?

Why does ogr's driver method CreateLayer return None? I'm using python 2.7 with gdal 1.9.1. path = r'D:\_tempAuto' out_shp = '%s\test_OGR.shp' % (path,) driver = ogr.GetDriverByName('ESRI ...
3
votes
2answers
1k views

Is there a way to get at C's OGRLayer.Intersection() or OGRLayer.Clip() in Python?

I am working with OGR in Python and noticed that the C libraries have useful Intersection() and Clip() functions as part of the Layer class. Is there any way to get at these functions in Python? I ...
9
votes
2answers
1k views

Processing SQLite files using ArcGIS Desktop?

I'm using qgis and grass for my work. I've produced a shapefile which is over 100mbs (s a result of some statistical analysis). If i convert it to sqlite format (spatially enabled) the data shrinks ...
2
votes
0answers
193 views

Naming layers in DXF using OGR2OGR

We have been using ogr2ogr to export data from PostGIS into DXF. Using the default behaviour of the export, all data are put into layer '0'. We would put data into a layer name from the PG table name. ...
2
votes
2answers
934 views

Export from PostGIS to SpatiaLite?

My PostGIS database contains OSM data from my country. For transportation reasons I want to export a spatial view I created from that data to a SpatiaLite database. Is there any way to directly ...
9
votes
5answers
1k views

How to build a geographic database of GPS logs?

On our aerial wildlife surveys we typically generate dozens of GPX files, and usually convert most of them into shapefiles for display in a GIS application. GPX files are a terrific way of keeping all ...
2
votes
2answers
423 views

Using osgeo modules in ArcGIS10.1 and QGIS 1.8 python shells

This is related to an old question of mine - Issues with osgeo - qgis.core and arcpy modules Now in new versions of all the software QGIS Lisboa (1.8), ArcGIS 10.1 and pyScripter 2.5.3. They all use ...
1
vote
0answers
609 views

How do you format an OGR VRT file to best convert a CSV to KML?

I am attempting to get a nice KML for simple review of POI/geocoding from a CSV. I a using ogr2ogr and a vrt. You can see the vet file below, with two attempts to get this right. Basically, the issue ...