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

7
votes
4answers
1k views

Are there GUI resources for gdal and ogr?

For those who are new to the programming side of GIS, I feel that a lot of great tools and resources are inacessible. I am interested in GUI based wizards for handling geoprocessing with libraries ...
2
votes
1answer
337 views

How to create new layer within a DXF file?

Using OGR in Python, I'd like to create some geometries within a DXF file, but not in the "0" layer, but in new ones. I tried with: import ogr, os, osr, sys ds = ...
1
vote
2answers
128 views

“AttributeError: getZ” error when trying to get the elevation of DXF linestrings

I'm using Python and OGR to extract the elevation of lines within a DXF file. import ogr driver = ogr.GetDriverByName('DXF') datasource = driver.Open('test1.dxf', 0) layers=datasource.ExecuteSQL( ...
4
votes
1answer
248 views

ogrinfo SQL GROUP BY Clause

Does ogrinfo support a GROUP BY clauses? I could not find any good documentation of all the SQL syntax features it supports. I tried the following: ogrinfo . -geom=no -sql 'SELECT lsad FROM ...
4
votes
1answer
1k views

OGR and DXF files: Is it possible to handle layer names? (only “entities”)

I'm using Python and OGR to extract the layers of a DXF file and convert them into SHP. I began with: import ogr, os, sys driver = ogr.GetDriverByName('DXF') datasource = driver.Open('test1.dxf', 0) ...
3
votes
2answers
341 views

Eliminate small polygons from shapefile

I downloaded GTOPO30 *.DEM files, and extracted a contour line at 2000m altitude using gdal_contour. In the resulting shapefile, I have many small polygons in areas where the altitude is close to that ...
10
votes
1answer
409 views

OGR/GDAL threading results in low core utilization

I'm trying to process some raster data using ogr/gdal and I can't seem to get full utilization of all the cores on my machine. When I only run the process on a single core, I get 100% utilization of ...
4
votes
1answer
683 views

GEOS Python: Taking Union of several geometries

I am using the GEOS/OGR library in Python. I have files full of geometries that overlap, and I want to convert these to files of geometries that don't overlap. The way I have been approaching this ...
9
votes
3answers
3k views

Divide a complex shape file into a grid

I have a decently detailed shapefile with polygon/multipolygon features (the file is about 500mb). It's actually a shapefile of the entire world, with the features representing coastlines. I need to ...
5
votes
2answers
2k views

How can I convert a csv file of WKT data to a shape file using ogr2ogr?

This question is related to Shapefiles to Text. I have a csv file, with one column, where all the rows correspond to WKT POLYGON()'s: WKT POLYGON(...) POLYGON(...) ... I'm familiar with how to ...
1
vote
0answers
306 views

ogr2ogr failed to reproject shapefile error exceeds limits

I cannot get correct transformation from WGS84 to the Hungarian EOV EPSG:23700 (Hungarian Datum 72) using ogr2ogr. I am using ogr2ogr from the fwtools shell. I have a shapefile in GCS WGS84 (epsg ...
4
votes
1answer
456 views

ArcGIS SP4 fails to open file geodatabases created with ogr2ogr

I've been using the new FileGDB support in gdal-1.9.0 to create file geodatabases that can be opened in ArcGIS. For example (I'm doing this all on one line, so I'm not certain this will run as ...
1
vote
1answer
2k views

UnboundLocalError: local variable 'x' referenced before assignment

I am trying to execute this code, import osgeo.ogr def findPoints(geometry, results): for i in range(geometry.GetPointCount()): x,y,z = geometry.GetPoint(i) if results['north'] == ...
2
votes
1answer
174 views

Converting 2D shapefile to Equal Area Projection?

I have thousands of shapefiles with coordinates in lat/long (-180 to +180 x, -90 to +90 y), that contain polygons of which I wish to calculate the area. I'm using the Python GEOS/OGR/GDAL API. If I ...
3
votes
1answer
898 views

Convert KML to shapefile without losing attribute data

So I want to convert KML files to SHP shapefiles to load it onto PostGIS. Currently I'm using ogr2ogr to do the conversion for me, but it wipes out all the attribute data. How do i preserve this ...
5
votes
2answers
2k views

Point-in-polygon using Python and OGR

I want to use OGR in Python to write a simple point-in-polygon test: def point_in_polygon(point, polygon): """ point : [longitude, latitude] polygon : [(lon1, lat1), (lon2, lat2), ..., ...
2
votes
1answer
1k views

How to reproject shapefile using ogr2ogr

I have shapefile in EPSG:2834 and I want to reproject it into EPSG:4326. I am trying to use ogr2ogr in Windows; however, I get this failure output: C:\Users\Nik\Desktop\Logan_Lines>ogr2ogr -t_srs ...
2
votes
1answer
1k views

Error getting while creating new field to a shape file table

i am getting the error for following code to add a new field to a shape file table. from osgeo import ogr # Open a Shapefile, and get field names source = ogr.Open('my.shp', 1) layer = ...
6
votes
2answers
2k views

Why can't I edit KML/GML layers?

Newbie here confused by my first experience in QGIS I have a handful of lines defining a bike route. Originally they were saved in a .gml file and later translated into .kml so they could be viewed ...
1
vote
0answers
123 views

Is Django's LayerMapping capable of putting a static value into all features?

I'm using GeoDjango's LayerMapping utility to try and import a set of features. The catch is that aside from the attributes in the source layer, I want all the destination features to have the same ...
9
votes
2answers
2k views

Is it possible to get the EPSG value from an OSR SpatialReference class using the OGR Python API?

When reading a layer from a OGR PostGIS connection I can get the SpatialReference of the layer, but is it possible to get the EPSG value? Is there any documentation on this? For example: lyr = ...
6
votes
3answers
3k views

Where do I find the ogr2ogr command for Mac OS X Lion?

I am looking for the equivalent of FWTools for Mac OS X, Lion. Is there anything I can easily install and get that command?
12
votes
2answers
3k views

API documentation for Gdal/Ogr with C#

I want to assign projection to shapefile in my web C# application, for this i am using Gdal/OGR/OSR C# bindings and add osr_csharp.dll and ogr_csharp.dll references. But i am facing some difficulty ...
4
votes
2answers
538 views

Issues with osgeo - qgis.core and arcpy modules

Is it possible to have the python shell from either qgis or argis to load (import) both qgis.core and arcpy? I am developing a metadata creation tool and have completed the core functionality using ...
2
votes
1answer
780 views

Exporting PostgreSQL table to FileGDB: wkbUnknown layer geometry type

I'm attempting to export a PostGIS (1.5.3) database table as a File geodatabase using the new FileGDB OGR / GDAL 1.9.0 driver: $ ogr2ogr -overwrite -sql "SELECT * from db_pts LIMIT 1" \ -f ...
4
votes
1answer
957 views

How to assign OGR geometry a spatial reference when writing to a new layer using the Python API?

I'm using the Python OGR API to add new features to a PostGIS layer. However, despite setting the geometry spatial reference, when the geometry is written out the spatial reference is missing. This is ...
2
votes
1answer
2k views

Projecting shapefile with transformation using OGR in python

I want to change coordinate system of a shapefile from British National Grid to WGS84 (in order to be able to convert it to KML later on). To get the best results of projecting I would like to use ...
5
votes
2answers
555 views

Accessing non-spatial PostgreSQL tables using OGR Python bindings

When connecting to PostgreSQL/PostGIS using the OGR Python bindings is it possible to get non-spatial table names (i.e. OGR layers) from the connection? Currently, doing: conn = ogr.Open("PG: ...
2
votes
1answer
444 views

TopologyException side location conflict reading MapInfo with Sharpmap

I'm using SharpMap 0.9 to read various MapInfo (.tab) files. I have used a number of files without any problem and been able to perform intersection queries on them like so: var interesectionResults ...
1
vote
1answer
627 views

Errors when converting MapInfo .tab to .dxf

I am trying to convert some MapInfo files to .dxf format using OGR2OGR using the following command: OGR2OGR -f "DXF" "input.dxf" "output.TAB" -overwrite -skiperrors When I run this I am getting a ...
1
vote
1answer
837 views

Escaping spaces in paths for use in batch file

I am making a MapInfo program in MapBasic. I am calling OGR2OGR in order to convert some files. To do this I am generating a batch file and then running it. My code looks something like this: RunStr ...
8
votes
4answers
1k views

Is there a mapping between OGR and python data types?

I'm writing a shapefile using OGR in python, creating fields on-the-fly from a python data source. Creation of a new field requires an OGR data type, is there a mapping between OGR and python data ...
21
votes
1answer
2k views

Can ESRI's File Geodatabase API be Redistributed?

ESRI's file geodatabase API can now be used with GDAL/OGR - http://www.gdal.org/ogr/drv_filegdb.html however each individual seems to have to login to ESRI and download the API files individually. For ...
4
votes
2answers
847 views

How to cut a shape file?

I want to use a shape file of the Corine Land Cover. This covers all of Europe, but I am only interested in the area of Scandinavia. How can I cut this file using free software (preferably a ...
11
votes
3answers
970 views

ogr2ogr fails to convert GeoJson file > 200MB

As a followup to my previous question (Converting SimpleGeo Places GeoJSON file to shapefile), I am now struggling with what I perceive might be an ogr2ogr "memory" limitation, but I cannot be sure. ...
6
votes
2answers
702 views

Can I change the GDAL/OGR library that QGIS uses?

I have been adding a new format to OGR, all seems well and OGRInfo works. Now I would like to test my code out using QGIS. Is there an easy way to switch which GDAL lib QGIS uses on a windows box? ...
7
votes
1answer
2k views

How to convert Shapefile geometries to WKB using OGR?

I got the geometry of a feature of the shapefile, and i want to save that geometry in the postgis (in WKB formats like it happens when we import shapefiles using shp2pgsql and psql commands). How do I ...
3
votes
1answer
269 views

Create polygon from OGREnvelope

I have a folder full of about 2000 files and I would like to generate a kind of key map for each file so people don't need to just randomly load each one in order to find what is what. I have the ...
6
votes
3answers
365 views

What is the intended Behavior of -skipfailures in ogr2ogr?

I am trying to run ogr2ogr to convert some geojson to shapefile. All is good until any of the geojson features have an invalid geometry (for example, the coordinate array of point geometry is empty). ...
5
votes
2answers
2k views

GDAL Python bindings not picking up OGR PostgreSQL driver

I have a windows server (Microsoft Windows Server 2003) with: Python 2.7, PostgreSQL 9.04-1, GDAL 1.8.1 (installed from the windows installer (gdal-18-1500-core.msi) hosted at ...
2
votes
1answer
873 views

How to combine MapInfo tab files into one spatialite DB?

I have many folders, each with a collection of MapInfo tab files (each folder has the same table names). For each folder I want to merge the tab files into one spatialite DB. My current method is to ...
5
votes
1answer
328 views

How to label raster cells in QGIS?

I try to show a small resolution raster file in the QGIS Print Manager tool. I would like to show a small label with each cell value (position - circa middle of each cell). How I can do it? Is there ...
7
votes
2answers
627 views

DXF attribute to z value

We have been given a DXF that contains a Elevation attribute but we would like to generate a 3D DXF. I know I can generate a 3D dxf from a shapefile using: ogr2ogr -f "DXF" out.dxf in.shp -zfield ...
3
votes
1answer
274 views

Polygon Shared Boundaries in GML

Last week I was told on a phone conference that GML supports shared boundaries in Polygon's. I have been unable to find any documenatation to substantiate the claim. Here is the situation: I have a ...
3
votes
4answers
515 views

Determine Projection

I was given a shapefile at work with the information that it is in Lambert Azimuth Equal Area (LAEA) projection (EPSG 9820). After some research on the web, I found out that EPSG 9820 is a generic ...
5
votes
1answer
351 views

Combined area of all features within features of another layer

I have a grid shapefile (basically, a half-degree grid of the world, where each cell has a unique id number), and a set of files with features. I want to record for each grid cell, all the areas ...
7
votes
1answer
1k views

Help with PostGIS polygon geometry - non-closed rings

I've picked up a copy of the super-wicked book 'Python Geospatial Development' by Erik Westra (Amazon link), and I'm working through it. Currently, it's teaching me to load GSHHS coastline data from a ...
2
votes
3answers
2k views

Read KML file with GDAL/OGR for Python

I have file : test.kml and I try to open it with GDAL/OGR (1.6) librairie in Python (2.5). But I don't succed can you help me ? This is my code : from osgeo import ogr adresse = 'test.kml' ...
20
votes
2answers
3k views

Python Efficiency — Need suggestions about how to use OGR and Shapely in more efficient way

I'm looking for some suggestions about how to make my python code more efficient. Normally efficiency doesn't matter for me but I am now working with a text file of US locations with over 1.5 million ...
6
votes
1answer
838 views

Spatial joins in OGR SQL

I have seen that OGR supports it's own form of SQL, I was wondering if it's possible to do spatial joins. Something like select all objects where one intersects the other. I did have a look around ...