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

1
vote
1answer
43 views

How to read geographic coordinates when the Shapefile has a projected spatial reference

I have a polygon Shapefile and want to read the polygon's vertices using OGR and Python. The reference system of the file is projected. However, for further processing I need the geographic ...
0
votes
1answer
60 views

Clipping GeoTIFF file by GeoJSON?

Input GeoJSON file: { "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Multipolygon", "coordinates": [[[ [27.397511483867362, 44.161117466010516], [...
2
votes
1answer
24 views

Creating an Interrupted Map With OGR, Mapnik and PIL

I am trying to create a simple interrupted Sinusoidal map with Python using OGR, Mapnik and PIL. The general idea is: Make 6x 60 degree sinusoidal maps For each one, make a mask to make it gore ...
1
vote
1answer
18 views

How do I convert WKT geometry from 3D to 2D

I'm working with kml files using Python gdal.ogr module. When I extract feature's geometry using feature.GetGeometryRef(), I get: POLYGON ((44.184069865521963 41.971859752507207 0,44.355248797385123 ...
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 ...
0
votes
0answers
11 views

How to color a KML with OGR/GDAL?

So I have successfully created a KML file and from an OSM file. Now I would really like to be able to color the lines of the KML file by using a value I calculated by using the KML. I already found a ...
1
vote
1answer
67 views

Force Python GDAL/OGR to flush changes to disk

I am trying to write a simple list of features and export it as a KML file, adding one extra attribute: in this case trafficability. However, ogr is failing to flush the data to disk when I run the ...
0
votes
0answers
26 views

How to add a field to an OSM file in Python?

I am writing a program that takes in a .osm file and then calculates some new attributes for that feature. I am using the python libraries gdal and ogr to help deal with the data. So far OGR has ...
1
vote
1answer
182 views

Adding Origin to Geotiff using Python GDAL?

Alright, so I'm getting closer to figuring this out but I'm stuck at one (that I know of) thing... how do I use GDAL to apply a known origin of a GeoTiff to another that has been processed in ...
0
votes
2answers
27 views

How to obtain Census block data in SQL format?

I am trying to create a web app where users can query a certain type of data that is offered by the Government. Unfortunately, the government prefers "Census Tract/Blocks" as opposed to Zip codes (it ...
12
votes
6answers
5k 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 http://www.kyngchaos....
0
votes
1answer
208 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 ...
4
votes
1answer
508 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 ...
3
votes
2answers
10k views

How to clip a line layer based on polygons with QGIS?

I have a line layer and a polygon layer. Both files have the same SRS. I want in a new shape file only the lines covered by the polygons. I tried in QGIS the Vector -> Geoprocessing -> Clip ...
1
vote
2answers
53 views

Preserving special chars using osgeo.ogr.Driver to shape in Python?

I am converting kml files to shape and run in to the problem that special characters are not preserved. #!/usr/bin/env python # -*- coding: utf-8 -*- import os, ogr, osgeo, sys ogr.UseExceptions() # ...
3
votes
1answer
752 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, ...
0
votes
0answers
20 views

splitting multipolygon with line

I am developing a QGIS plugin in python using mostly OGR that clusters features based on several conditions. One of the steps is to split the different multipolygon features (blue selection in image) ...
7
votes
1answer
583 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, ...
0
votes
1answer
48 views

kml to shape file (ogr2ogr)

I am trying to convert kml to shape file. I'm using ogr2ogr (gdal version = 2.0.0). Here is the command : /home/vineet/Project/gdal-2.0.0/bin/ogr2ogr --config SHAPE_ENCODING UTF-8 -update -append ...
2
votes
2answers
68 views

Selecting by attributes and making new shapefile using Python ogr only?

I have a problem making my selected features into a new shapefile with the same projection. I am new to python, any ideas? Below is my sample script. from osgeo import ogr import os, sys driver =...
20
votes
2answers
9k 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 ...
0
votes
1answer
34 views

Writeogr to PostgreSQL/PostGIS database with R

I'm producing some Spatialpolygondataframes with R that I would like to upload to my PostGIS Database. I've found out that the way to do this is via the writeOGR() function using the PostgreSQL driver....
0
votes
0answers
45 views

OGR error creating geometry for feature when deleting nodes

I have a line Shapefile that I need to remove many nodes from. Some I can delete fine, others delete but when I hit save I receive the following error: OGR error creating geometry for feature Using ...
2
votes
1answer
23 views

Read multiple layers of KML file using R

I have a KML that 3970 layers. I am trying to read it into R using the following script: library(rgdal) lyr <- ogrListLayers("file.KML") mykml <- readOGR("file.KML","Layer1") This works but ...
3
votes
1answer
55 views

Changing the origin of a raster?

I have a raster file that is projected not detailed enough. Every pixel in the raster should be replaced, just a bit. With ArcGIS I calculated the offset per pixel. I couldn't find a way to do this ...
0
votes
1answer
12 views

How do you use ogrinfo with a SQL Server database?

How do you use ogrinfo with a SQL Server database? I've tracked down documentation on it at GDAL and it mentions ... datasource_name: The data source to open. May be a filename, directory or ...
1
vote
1answer
29 views

How do I get the feature from a single-feature OGR layer in Python without looping?

A while ago I asked why the 0 index in a OGR layer was not a feature and it turned out that OGR interprets the index as Feature ID and looks that up. Now I filtered a layer to have only one feature ...
0
votes
0answers
38 views

Gdal ogr simplify/intersects

Can anyone give an example: How to use the simplification? For example // read the coordinates of the polygon char * wgsRef = NULL; OGRPolygon *poPol = (OGRPolygon *)...
1
vote
1answer
32 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)) ...
1
vote
1answer
42 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 ...
1
vote
2answers
682 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 ...
4
votes
2answers
138 views

How to add support for FileGDB (Esri file gdb API) driver in fiona?

There has been a tons of questions on that but none of them solved my problem. I have a machine with: Windows 7 x64 Python 3.4.3 x64 gdal installed: gdalinfo --version --> GDAL 1.11.4, released ...
7
votes
2answers
4k 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: ...
1
vote
0answers
33 views

point in polygon starting with csv and shp in python

I have a csv file with two sets of lat/lon points - the first set of points is represented by columns V1(lon) and V2(lat), and the second set of points by V3(lon) and V4(lat) (the csv does not have ...
18
votes
4answers
12k views

How to add attribute field to existing Shapefile via Python without ArcGIS?

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 ...
2
votes
0answers
35 views

Non-zero error with ImportFromEPSG() in GDAL/OSR/Python

I'm currently getting an error when testing ImportFromEPSG() on my GDAL. import osr testSR = osr.SpatialReference() testSR.ImportFromEPSG(4326) #this returns value of 6 print testSR.ExportToPrettyWkt(...
2
votes
0answers
18 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
24 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 ...
0
votes
0answers
24 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 = driver.Open("...
1
vote
1answer
33 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
36 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
111 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
42 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 ...
3
votes
2answers
60 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
75 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
28 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 = ogr....
5
votes
1answer
39 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
34 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 ...
7
votes
2answers
129 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
56 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, ...