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

20
votes
2answers
2k 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 ...
20
votes
1answer
1k 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 ...
14
votes
6answers
4k views

Generate points that lie inside polygon

I have polygon feature and want to be able to generate points inside it. I need this for one classification task. Generating random points until one is inside the polygon wouldn't work because it's ...
14
votes
4answers
6k views

How to add an attribute field to an existing Shapefile via Python

I have a Python script that adds an attribute field to a Shapefile if doesn't exist. This is easy to do with ArcGIS (graphically or via Python), but I'm looking for something that doesn't depend on ...
14
votes
3answers
5k views

What's the easiest way to install GDAL and OGR for Python?

I am developing some code in Python, and I want to use the GDAL/OGR python bindings. What is the minimum I need to install in order to use the GDAL and OGR python bindings? What is the easiest way to ...
13
votes
7answers
3k views

Free tool to simplify parcel shapefiles?

Is there any tool available which let's me run millions of parcel shapefiles and simplify them?
11
votes
1answer
423 views

How to rename field names in a shapefile from the commandline?

I need to rename the field names (attributes) in a shapefile. Is there an easy way to do this from the command line?
11
votes
1answer
2k 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 ...
11
votes
3answers
861 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. ...
10
votes
2answers
3k views

Point (of a linestring) within Polygon using ogr and Python

I'm currently working on a project in which I need to build a topological network out of the geometry features I find in shapefiles. So far using Ben Reilly's open source project I've managed to ...
10
votes
2answers
2k views

How to add custom Feature attributes to ESRI Shapefile with Python?

I am seeking a way to take an existing ESRI Shapefile that has a Feature set of 200 countries. Each country Feature has an attribute of "NAME." My objective is to create a Python script that adds an ...
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 ...
10
votes
1answer
343 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 ...
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 = ...
9
votes
3answers
1k views

getting dxf files out of PostgreSQL

I've successfully loaded a bunch of shapefiles into a PostGIS database. I would like to be able to retrieve specific geometry and layers as dxf files based on SQL queries. I'm using PostGIS, GDAL, ...
9
votes
4answers
3k views

installing GEOS, PROJ, GDAL/OGR into a python virtualenv on Mac OS X

I am trying to setup an isolated python virtualenv to work on GIS projects on my Mac OS X. Sounds like I will need to install the GEOS, PROJ, GDAL/OGR from the kyngchaos site here ...
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 ...
8
votes
4answers
2k views

how can i convert a shapefile to lat and lon boundaries?

i have a shapefile of country subdivisions and i would like to extract an array of bounding lat and lon for each division.. is it possible to do?
8
votes
3answers
2k views

Get all vertices of a polygon using OGR and Python

I'm having a little trouble with the Python OGR API. What I am trying to do is get all the coordinates of each vertex of the outer ring of a polygon. This is what I have so far: import osgeo.ogr ...
8
votes
4answers
1k views

Best way to find the polygons crossed by a line

I'm trying to find all the polygons crossed by a single line (a GPS track). I'm using the OGR library (from python) for computing this, but it's currently a bit 'brute-force' (and slow). For every ...
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 ...
8
votes
5answers
1k views

How to convert line simple features to topological network?

using Gdal/ OGR is there a way to convert a shp, kml, or PostGIS line layer into a network of nodes and segments so it can be used in packages such as networkx?
8
votes
6answers
822 views

How do I generate thumbnails images from lots of shapefiles?

A colleague and I recently released an Open Source project called Mapoteca which is a set of Python Scripts that integrates with a GDAL/FWTools installation allowing a full walk-through of directories ...
8
votes
1answer
303 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 ...
8
votes
4answers
914 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 ...
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 ...
7
votes
2answers
2k 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 ...
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 ...
7
votes
2answers
3k views

How to convert GML Surface to SHP Using OGR?

I have a very large .gml file with multiple layers in it. I would like to export one of these layers to .shp. It is a polygon layer (of lakes). However, I am getting the error: ERROR 1: ...
7
votes
2answers
2k views

Deploying Application With C# GDAL/OGR Bindings

I developed a relatively simple web app that uses the C# OGR bindings to do a couple of simple geometric functions; buffer, clip...etc. I developed this application on my local machine, which has ...
7
votes
1answer
1k 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 ...
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 ...
7
votes
3answers
3k views

How To Convert A Set of ARC/Info ASCII .e00, .e01, .e02, etc Files Into .shp Files

I have a set files that I downloaded with extensions (.e00, .e01, .e02, etc). I have read that these are files used by ARC Info mainly, but I do not have ARC and nor am I really that interested in ...
7
votes
2answers
410 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 ...
7
votes
2answers
510 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 ...
7
votes
2answers
963 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 ...
6
votes
1answer
750 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 ...
6
votes
2answers
272 views

Convert points to lines with Python GDAL

I have a dictionary with points. The points are derived from a raster (see image below). The points are not sorted and are not in order. The dictionary looks for example like this: pointDict = {0: ...
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 ...
6
votes
1answer
205 views

Geometry Projection Speed Test

Lately I've been using the OGR projection classes that come with ogr/gdal, but pyproj was recommended to me, so I thought I'd give it a try. To help me decide if I should make the switch, I did a ...
6
votes
3answers
310 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). ...
6
votes
1answer
223 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 ...
6
votes
2answers
640 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? ...
6
votes
1answer
399 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 ...
5
votes
1answer
586 views

Python - OGR: Transform coordinates from meter to decimal degrees

I have a point in a shapefile. The shapefile is in a WGS_1984_Web_Mercator Projected Coordinate System. I want to get the coordinates of that point in decimal degrees with GDAL/OGR in Python. I am ...
5
votes
1answer
141 views

ogr2ogr selecting features by attributes

I am writing a shapefile after some processing; however, in the final step I need to do some selection by attributes from the the shapefile. I am using the command in a shell with the aim of using it ...
5
votes
1answer
1k views

R : convert a spatial polygon objet to spatial polygon data frame

My goal is to modify an existing shapefile by merging certain polygons. After importing the shapefile and using the UnionSpatialPolygons command, I get the polygon outline that I want. However, this ...
5
votes
3answers
1k views

Is it possible to create 3D dxf with OGR?

Does anyone know if it's possible to create a 3D dxf with OGR. I would like to assign our contour lines a z value and export them to dxf for some cad work. PS I know FME can do this, however I would ...
5
votes
2answers
1k views

Call FWTools (ogr2ogr) from ArcGIS python script

In ArcGIS, I want to use a Python script (and a standard ArcGIS script tool UI) to call functionality from FWTools. How would I make the call to FWTools? I tried using ...
5
votes
2answers
342 views

Python: how to speed up spatial search (nearest point)?

I'm working on a program that determines the closest location from a given point. The point cloud I'm testing against is very big (~800.000). However, this doesn't really explain why my implementation ...