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
0answers
14 views

rename table/feature class in filegdb using ogr or qgis

According to the OGR SQL docs, it doesn't appear that it is possible to use and ALTER statement to rename an existing table (featureclass) inside of a file geodatabase. RENAME statements can be run on ...
0
votes
0answers
22 views

Python module for counting ratios from SHP attributes

Using OGR, I am supposed to create a Python module that finds out which specific administrative region of a country has the highest density of roads. I have two input shapefiles: roads connected ...
4
votes
1answer
462 views

How do I link OGR with spatialite?

Problem & Evidence: I'm trying to create a spatialite file with the code snippet below. However the outDataSource object gets assigned NoneType and all subsequent (unshown) code fails. I'm ...
0
votes
0answers
15 views

OGR WFS - GetNextFeature() - cannot parse - element arg attribute name had invalid value TYPENAMES

I am new to Python and OGR, and i try to follow advices given by Gene in ouvrir un WFS - debutant, but it fails... from osgeo import ogr driver = ogr.GetDriverByName('WFS') wfs_ds = ...
1
vote
1answer
21 views

Why can't PHP insert new geometry on PostGIS?

(Copied this question from stackoverflow, since it may have more answers here.) I'm using ogr2ogr to upload a GPX file to PostGIS. When I do it on command line (Ubuntu 14.04), it works fine. ...
3
votes
0answers
34 views

Rectangle shapefiles with the same extents does not align perfectly after projection

I have a rectangle shapefile built with UTM19 coordinates using a python script, and then projected to NAD83_CSRS (EPSG:4617). I have a second rectangle shapefile built with the same method (python ...
3
votes
2answers
72 views

GDAL/OGR ogr.Layer.Intersection fails when producing mixed geometry results

I am trying to intersect layers using the ogr.Layer.Intersection method, in Python. This works fine for pairs of polygons, but I have found intersecting two linestring layers containing matching ...
1
vote
1answer
26 views

Intersection with 2 KML files - newbie

I'm new to all this gis thing and I have this project for university where I'm trying to find the countries within a bounding box. So what I'm doing is, I have a set of coordinates that define a ...
1
vote
0answers
29 views

Problem loading from MySQL in QGIS 2.10 on Mac

I cannot load a vector layer from MySQL in QGIS 2.10 (Pisa) on a Mac. If I goto Layer -> Add Layer -> Add Vector Layer -> Database I do not see MySQL in the drop down. I found this link. I did not ...
3
votes
2answers
44 views

Find points that intersect a user-defined polygon in GDAL

I'm trying to do something that I don't know is possible in GDAL/Python. I have a list, L, of pre-defined lat/long points that make up a uniform grid. A user will send me a set of points that make ...
2
votes
1answer
51 views

Create GPX track in R. writeOGR function

I have a gpx file where someone exported two different activities in two separate locations to a single track. I need to split them and avoid getting the erroneous line in the track layer that ...
0
votes
1answer
26 views

Empty file after saving…? [closed]

Code below is working, but after opening - there are No features in shp file. What can be a problem? import osgeo, os from osgeo import ogr, gdal shpFile = r'C:\Users\ReBurns.shp' driver = ...
7
votes
1answer
572 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, ...
5
votes
1answer
32 views

Using ogrinfo how to extract number of columns and attribute population?

Currently i'm using this DO ogrinfo -al -so to extract Projection, Feature count, Field_names for a bunch of files in batch mode. Is it possible to extract number of fields & how many fields are ...
2
votes
0answers
30 views

How to run ogrinfo for files listed in a CSV? [closed]

I am using this code to extract info's of all the tab files in a folder. We have a csv list which has, say 100 file names out of 500 files in that folder. How to modify the code only to do ogrinfo's ...
1
vote
1answer
1k views

Importing Census TIGER Shape Files to SQL Server 2012?

I've been doing my research on how to import shape files into Microsoft SQL Server 2012. and am still unable to figure out how to do it after hours of playing around with it. I'll document what I've ...
7
votes
2answers
94 views

Polygons across international dateline [-180..+180 longitude]

I'm trying to generate polygons for satellite orbital swaths. So far I have a method to generate two lines which represent the edge of each swath in [lat,long]. Some of the swath's cross the ...
2
votes
2answers
46 views

How to select polygons by criteria and save them to shp file?

I have file of polygons and want to select few by criteria - area more or less then specific number and save result to shp file. code gives 0 by passing criteria: from osgeo import ogr, ...
0
votes
1answer
36 views

Converting files with ogr2ogr and dropping ALL attribute fields

I want to add a gpx file to a PostgreSQL/PostGIS table using ogr2ogr, but my table does not have any of the fields that are attributes of the GPX file. There are previous questions here dealing with ...
1
vote
1answer
204 views

Geoprocessing tool Difference from the Terminal?

I have used QGIS Geoprocessing tool Difference to cut polylines (SHP) into to smaller pieces using a polygon (SHP). This works very good in QGIS. Now, to speed up the process, I'd like to be able to ...
0
votes
1answer
186 views

How to get projection data (.prj) of raster image using GDAL/OGR?

I start with a boundary shape-file (think U.S. states) in lat/long that I convert to some projection, and then rasterize the result as a .tif. What I need now are the raster coordinates of the ...
0
votes
0answers
20 views

Convert geoalchemy2 Geometry(polygon) column to OGR Geometry

I would like to use OGR to perform analysis. My data currently lives in a PostGIS database. I am loading my data into a python environment using geoalchemy2. I am hoping that a line similar to the ...
5
votes
2answers
1k 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 ...
18
votes
8answers
18k views

Installing 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 ...
1
vote
1answer
25 views

Add attribute of type Date to shapefile using OGR

can anyone tell me how to add an attribute of type Date during a shapefile creation? For Integer works fine using the following code: Layer1.CreateField(ogr.FieldDefn('NumberIndv', ogr.OFTInteger)) ...
2
votes
1answer
35 views

Why is the first element of my WFS layer None instead of a feature?

I have made a WFS connection and got a layer from it. I want to use the first feature from that layer. driver = ogr.GetDriverByName("WFS") wfs_url = "WFS:http://example.com/wfs" wfs = ...
5
votes
1answer
1k 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 ...
0
votes
1answer
29 views

How to extract a shapefile with a SQL expression from a database of shapefiles using PyQGIS or OGR [duplicate]

I have a shapefile Water_Districts.shp that consists of several water district polygons. I am trying to use the script below to 'extract' a specific polygon with the name Cache La Poudre River listed ...
0
votes
0answers
30 views

ogr2ogr - PostGIS to GML with nested attributes

I am attempting to create GML from PostGIS tables and having issues with nested tags. Before I waste too much time on this, I would like to know if what I am trying to do is possible with "ogr2ogr". I ...
3
votes
2answers
991 views

How do I get the centroid of line with OGR

Can somebody explain how to get the centroid of a feature with ogr? I have no idea what the centroid() function itself does. >>> linelyr = lineshp.GetLayer() >>> f = ...
-1
votes
1answer
61 views

The reason why dataset does not create layer

I have a plugin written in Python, and two versions of the QGIS, assembly there are differences, but the main suspect, that the version of GDAL==2.0.0dev (1) another 1.11.3 (2) for first ...
1
vote
0answers
31 views

ogr2ogr (or other) simplification of polygons with shared boundaries

I am trying to simplify a collection of 100,000 or so polygons containing nearly 4 million vertices. The data is stored in a 2GB shapefile so there is no explicit representation of the topology ...
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 ...
2
votes
1answer
43 views

How to save points without losing z dimension

I try to save Points with OGR. It works well but I lose the z dimension while saving/loading. from osgeo import ogr from osgeo import osr shapePath="...xxx.shp" X='1.0' Y='2.0' Z='3.0' driver = ...
5
votes
1answer
432 views

ogr SimplifyPreserveTopology does not keep the Topology

I use ogr2ogr to simplify a layer of polyline, from the document: -simplify tolerance: (starting with GDAL 1.9.0) distance tolerance for simplification. This method will preserve topology, in ...
3
votes
1answer
678 views

GDAL/OGR to extract pixel values

I want to use GDAL/OGR to extract pixel values from a raster file. The extraction should be based on polygons, stored in a shapefile. My thought was to iterate over the features in the shapefile, ...
3
votes
1answer
69 views

Understanding intersection of GDAL and QGIS?

Background I'm starting a project that will be done entirely through Python, except perhaps at the end for visualisation. So far I've been doing it with ArcGIS and arcpy, but we'd like to move it to ...
1
vote
1answer
160 views

VSI File API support in ogr2ogr

It seems that support for streaming input is wishy-washy in ogr2ogr. For example, why can I do this: curl "http://data.usgin.org/arizona/wfs?service=WFS&version=1.1.0& ...
2
votes
3answers
106 views

I have an existing attribute table that I'd like to add values to the fields within it while preserving the geometry, how can I do this?

I've tried to use fiona and shapely and ogr, but the tutorials seem to be insufficient to describe how to do such a seemingly simple task. In arcpy this could be done simply with an update cursor. ...
3
votes
2answers
47 views

ogr2ogr sql query from text file

In ogr2ogr or ogrinfo, I can successfully query an Oracle database using this command as a test: ogrinfo -al -so "OCI:USER/PASSWORD@SERVER/DATABASE" -sql "SELECT * FROM SCHEMA.TABLE" However, ...
1
vote
2answers
2k 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 ...
1
vote
0answers
24 views

Command line join attributes by location using OGR

I have two overlapping vector files (polygons and sample) and want to do a spatial join from the command line to extract all features in polygons that intersect with sample. Essentially I want to have ...
1
vote
1answer
33 views

Available Python client libraries for WFS transactions?

I am looking for a Python module to allow me to use WFS-T. Everything I found so far only supports getting data out via WFS, I need to INSERT and UPDATE. owslib does not support WFS transactions ...
2
votes
1answer
2k 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 ...
13
votes
2answers
11k 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 ...
7
votes
3answers
186 views

Identify and delete overlaping or near lines with similar running

I have shapefiles with lines that shows surface water runoff. I need to clear and simplify these shapefiles by condition that if some lines are near by other and has similar running, this lines has to ...
2
votes
1answer
42 views

How to set CRS for a DXF file and prevent any warning on QGIS using pyQGIS?

I am trying to import dxf file with no warnings or popup from Spatial Reference Selector. However, even after modifying QGIS Spatial Reference Selector setting, I still get a qgisMessagebar warning. ...
0
votes
1answer
57 views

Can updates be made to “ogr_fdw” foreign tables in PostgreSQL?

I am accessing a Microsoft SQL Server table (w/ SQL Server a geometry column) via an ogr_fdw foreign table. SELECT statements work great, including the PostGIS functions that I've tried. Are UPDATES ...
1
vote
1answer
64 views

Add Color To GTiff output raster band

I am using GDAL in Python to create a tiff raster of data that is originally from a shapefile. I have an auxillary data channel, which I would like to use to color the pixels of the tif. I have made ...
3
votes
3answers
367 views

How to make a local copy of a large WFS dataset?

We are writing a application in which a part of the job is to fetch a relatively large (>10000 features) and often updated dataset from a WFS server, store a local copy, and do geospatial analyses on ...