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
2answers
32 views

How to force ogr to treat JSON mapserver query as “Multiline” instead of “Line” geometry type?

I have a script that obtains feature data from a JSON output of an ArcGIS REST MapServer. At present my script treats the JSON data as a "LineString" Geometry type, but, the JSON data is in fact a "...
0
votes
1answer
47 views

How to install gdal postgresql driver in Ubuntu

I want to use Python to load PostGIS table by ogr. But after I try ogr.open in python (it works if loading a shapefile), I can only get null value. Now I have tried GDAL debug, the output shows like ...
4
votes
1answer
529 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 ...
2
votes
1answer
19 views

Does the GDAL GeoJSON driver read or write multipart geometries?

In the documentation for the GDAL GeoJSON driver, I can only see mention of primitive geometries. Does the GDAL GeoJSON driver read multipart geometries like MultiLineString? If not, is there ...
0
votes
1answer
37 views

Use OGR and GDAL in Python outside OSGEO4W shell

I have QGIS installed, therefore it installed the OSGeo4W with all functionalities and that works great. I added all the environment variables as proposed in this post: Is there a way to use gdal ...
0
votes
1answer
20 views

Copy features from one layer to another with ogr and python

I have two layers with the same feature definitions named lyr and lyr_add. These layers were populated from a JSON based mapserver. I would like to append all of the features from lyr_add to lyr, ...
0
votes
0answers
10 views

Raster to CSV with x y cell center coordinates, the original raster cell value, and values from another raster avoiding shapefile

I am looking for FOSS (maybe GDAL/OGR) solutions to a problem. I need to go from raster (200 million records) to CSV. It is easy enough to do via point but the point file breaks the allowable 2GB “...
0
votes
1answer
28 views

Create ShapeFile from CSV Using OGR and Python

I want to convert a CSV file of point coordinates to a ShapeFile using OGR and Python. The example.csv file looks like this: ID,X,Y 1,240007.000,647756.000 2,240008.000,647756.000 3,240009.000,647756....
1
vote
1answer
195 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 ...
2
votes
1answer
41 views

Selecting features from shapefile where field=“value” using Geopandas?

I don't understand the difference between OGR and Geopandas librairies. I have checked the documentation of GDAL as well as http://geopandas.org/ but I still don't get it. I just started learning ...
0
votes
0answers
17 views

Finding closest coordinate between geometries using OGR libraries?

I'm currently working on a project where I need to find the closest coordinate on a geometry using the OGR Geometry class. As far as I can tell the only easy operation to do with this class is ...
9
votes
3answers
2k 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 <-...
0
votes
1answer
219 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
22 views

Finding intersections in multiple files and exporting to single shapefile using OGR

I saw this solution using Shapely, but unfortunately I can't get Fiona to work with my Python IDE nor with OsGeo4W. I have a single shapefile that has a 500m buffer on about 350 trail polylines. I ...
1
vote
1answer
209 views

How to set time field when generating a GPX track with Python OGR?

I want to generate a GPX file with Python OGR. In particular I want to generate a tracks (layer of features of OGR type wkbMultiLineString) My script is below. I get the error ERROR 1: No such field: ...
1
vote
3answers
2k views

Storing two kinds of point geometry in shapefile or creating multipoint shapefiles? [closed]

Following How many interior and exterior rings can a polygon have in a standard ArcGIS shapefile?, can I have a mixture of two kinds of geometry in a shapefile of type point. Just like I have about ...
0
votes
0answers
25 views

GDAL online courses and Books with tutorials [closed]

I feel I have progressed well with some GDAL functionality including some novel uses of calc but I feel I am missing so much more. I would like to learn more particularly when it comes to raster data ...
1
vote
0answers
17 views

Trying to get all Landscan Urban areas in the USA (from Natural World shp files)

I'm desperately trying to get a json file of all the Landscan urban areas in the USA. The ne_10m_urban_areas_landscan.shp has a list containing polygons of all urban areas in the world with a NAME ...
1
vote
0answers
22 views

Setting default encoding for python in QGIS in Windows

I have a problem that I have been working on for too long now... I am creating a python plugin for QGIS and I have problems with encoding. Characters with accents are displayed funky, but it is fine ...
1
vote
1answer
49 views

Using 'ogr2ogr' algorithm in QGIS to transform SHP to GPX

So I am trying to convert a LineString shapefile into GPX using the 'gdalogr:ogr2ogr' algorithm in a QGIS python plugin. The problem is that I alway get routes instead of tracks, even if I specify ...
9
votes
1answer
2k 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 ...
1
vote
2answers
43 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 ...
7
votes
1answer
590 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, ...
4
votes
2answers
2k views

Join a CSV file to shapefile using gdal/ogr?

I have a shapefile with several attributes, for example YEAR, COUNTY, and AREA. I also have a CSV file with more fields that I want in the shapefile, such as POPULATION. Both the shapefile and the CSV ...
1
vote
2answers
103 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
84 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
40 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
38 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
13 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
69 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
31 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 ...
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....
4
votes
2answers
11k 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
60 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
784 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
22 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) ...
0
votes
1answer
57 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
77 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 =...
21
votes
1answer
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
42 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
63 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
25 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
65 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
15 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
41 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
40 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
35 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
47 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
695 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 ...