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
729 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
289 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
456 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
556 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
127 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 ...
8
votes
2answers
1k views

Can ArcMap 9.3 process sqlite files?

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 ...
1
vote
0answers
185 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
666 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 ...
8
votes
4answers
919 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
357 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
520 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 ...
3
votes
1answer
198 views

Is there no EPSG code to use for Behrmann equal-area projection in ogr2ogr?

I'm trying to use ogr2ogr to reproject some shapefiles. The projection I wish to use is Behrmann equal-area. I cannot find an EPSG code to use for the '-t_srs' part of the syntax. Is there any way ...
3
votes
1answer
258 views

How to stop writeOGR from abbreviating Field Names when using “ESRI Shapefile” driver

I'm currently using the following script to add some attribute data from a table to lots of individual shapefiles: library(rgdal) specieslist <- read.csv("SpeciesList1.txt", header=F) attdata ...
1
vote
3answers
372 views

Getting Field value for a given coordinate out of ESRI Shapefile using GDAL/OGR

I have a bunch of ESRI shapefiles that contain Land Cover data across Canada (provided by Geobase). I need to query the files and obtain the value of a certain field (called COVTYPE) in a given ...
7
votes
2answers
414 views

How to catch PostgreSQL/PostGIS errors in GDAL/OGR Python bindings?

Is it possible to catch PostgreSQL output error messages in OGR after a query has failed? For example conn.ExecuteSQL('SELECT * FROM non_existing_table;') In Postgres this returns an error ...
8
votes
1answer
307 views

Is there a way to properly have GDAL raise exceptions in Python?

I am working with GDAL in Python and have wanted to get GDAL to raise exceptions so that I can do something useful with them. For instance if a file cannot be opened with gdal.Open() I would like to ...
2
votes
3answers
729 views

How to merge several GML files into one

I have a folder of GML files that I want to be able to merge to create one GML file that I can then view. I have tried this using the code described but substuting for GML in this website but to no ...
4
votes
1answer
301 views

ogr2ogr when importing from fgdb and use in python

I want import data from my GDB to PostGIS. It works fine on some datasets (all records -data- is imported or nothing is imported) from a gdb but just doesn't import others. I can't find any ...
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
294 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
113 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
213 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 ...
3
votes
1answer
886 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
317 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
345 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
622 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
1answer
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
275 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
428 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
162 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
849 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
117 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 = ...
4
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?
10
votes
2answers
2k 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
508 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
662 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
862 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
529 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
411 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
581 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
753 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 ...