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
151 views

OGR: How to save layer from AttributeFilter to a shape filter?

I select a subset of features from my shape file like so: node_lyr = nodes.GetLayer() q_str = "%s = %i" % (field, value) node_lyr.SetAttributeFilter(q_str) What is the best way to make a shape file ...
0
votes
2answers
90 views

please Introduce me a free 3rd party library appropriate for showing Geospatial information

Up to know I have used GDAL to extract raster data from geotiffs and then opengl's used to show that raster data. But when it comes to extract vector data with the help of ogr library, what library ...
0
votes
2answers
106 views

Python ogr: why is GetFeatureCount() so slow?

I did some profiling for a program I wrote and discovered that ogr's layer.GetFeatureCount() is significantly slower than just using python's BIF len(). Here are my test results def test(): ...
1
vote
1answer
153 views

OGR: How to best use GetFeature on a selection?

I think the following is very confusing sel_str = "ND_14 = '108'" l.SetAttributeFilter(sel_str) l.GetFeatureCount() >>> 1 In a for-loop this gives me for f in l: g = ...
3
votes
1answer
110 views

is it possible to project a shapefile to a raster's custom projection with command line gdal/ogr?

I have a raster with a user defined sinusoidal projection and a shapefile in lat/lng coordinates (I believe this is called 'unprojected'?). I'd like to use ogr/gdal's command line utilities to ...
1
vote
1answer
80 views

Offset shapefile to start from prime meridian

I have Natural Earth shapefile (for example this file: link) covering whole globe in -180:180 range. I want to offset this file, so that it starts from Greenwich prime meridian instead -180. How can ...
0
votes
1answer
253 views

How to conditionnally assign a new value to pixels of a raster image?

Given a topographic GIS raster of one country crop.tif: Given a know pixel value such as elevation (z) is +73 : $ gdallocationinfo crop.tif 1 1 -valonly > 73 Given an elevation threshold n = 50 ...
0
votes
2answers
244 views

Gdal: How iterate through all pixels of a raster image?

Given a topographic raster image. How to iterate through all pixels of this raster image ? Solution preferably with gdal, in console. Some other libraries/script could be installed. Related: ...
1
vote
1answer
148 views

How to make a virtual layer from ogr geometry?

I know how to do this: nodes = driver.Open(node_nav,0) node_lyr = nodes.GetLayer() node_lyr.SetSpatialFilter(None) But how do can use the layer methods on a geometry I created from scratch? ...
0
votes
0answers
242 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, ...
2
votes
2answers
858 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 ...
1
vote
1answer
133 views

Importation of .csv on grass gis converts numeric data to string data

When importing a csv file on grass7, the numeric data is converted into a data of type string. My csv looks like this : id_core value 1 F1 83.0611472396 2 F2 98.8584345936 3 F3 ...
6
votes
1answer
265 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 ...
0
votes
1answer
184 views

Why won't OGR connect to my PostGIS database, but QGIS will?

Trying to connect to my PostGIS database with some success... One hiccup is that OGR will not connect to my server from a remote machine, though QGIS can connect to it just fine from that same ...
3
votes
1answer
885 views

ogr2ogr coverting DXF to shapefile, why am I losing part of the feature?

I'm starting to mess around with some of the GDAL toolsets, specifically the ogr2ogr. I'm working with converting a 2000 ACSII DXF file to shapefiles depending on geometry. Everything seems to work ...
1
vote
0answers
127 views

How to shift vertices of shapes in shapefile using FOSS python library?

I need to shift each vertice of shape in a shapefile (of any type:point, line, polygon, multiline etc.) with Python. I need to loop in all shapes, get the vertices, get it's coordinates and for each ...
2
votes
1answer
102 views

Using ogrinfo to list all projection source of a database [closed]

I have to reproject all the layers from a database, but some of them are undefined and some are defined in a wrong projection. I would like to sort all those layers in a text file with their source ...
0
votes
1answer
95 views

ogr SetAttributeFilter uppercase?

How do I use the ogr SetAttributeFilter with uppercases? Code example: lyr = shp_obj.GetLayer() sel_str = "%s = '%s'" % (field, value) lyr.SetAttributeFilter(sel_str) Can I just do: sel_str = ...
1
vote
2answers
138 views

Erase method using ogr

I'm trying to find the erase geoprocessing method as i am familiar with in ARC, but i can't seem to find it in OGR using Python. I have looked through the module ogr documentation but perhaps i missed ...
2
votes
1answer
356 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 = ...
0
votes
1answer
211 views

SetGeometry problems when using python/ogr

So i am trying to use the difference function and i pretty much create the new file i want but the Geometry is empty. No error is produced. any help would great! Thanks. #!/usr/bin/env python import ...
2
votes
1answer
96 views

Is there a quicker way of checking if a feature exists with OGR

I'm writing lot's of features to a FileGDB using OGR. The slow point in my script is checking that the feature isn't already in the Feature Class, based on the ID. Currently I'm using a function ...
0
votes
1answer
75 views

Is georeference the same as geotransform?

Does georeference mean the same as geotransform? If not then what is the difference?
6
votes
1answer
243 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 ...
2
votes
2answers
458 views

Python GDAL/OGR: retrieved feature is NoneType

I'm doing some scripts in Python to deal with shapefiles, and I have an issue I don't understand. I'm looping over a shapefile, and I want to retrieve the geometry of each feature, but very often I ...
4
votes
1answer
287 views

OGR Info - Check for spatial index?

If we want to get information about a vector layer (shapefile for example) we could use ogrinfo: ogrinfo -so myshapefile.shp mylayer This returns a lot of pertinent information about the shapefile. ...
5
votes
4answers
387 views

How to computational efficiently check if there are any overlapping polygons in a group of polygons?

I need to do some processing with groups of polygons. If any of the polygons in the group overlaps other polygon the result is unpredictable and don't throw any error. So, I need to detect if there is ...
1
vote
0answers
89 views

Gdal/Ogr - OGRLayer.Intersection() Question

I was trying to perform intersection on two feature classes (shape file format) using OGRLayer.Intersection(), but have problems making it work with C# bindings. I am not able to figure out on how to ...
2
votes
0answers
280 views

ogr.GetDriverByName('FileGDB') returns None

I installed: gdal-110-1600-x64-core.msi GDAL-1.10.0.win-amd64-py2.7.msi gdal-110-1600-x64-filegdb.msi from www.gisinternals.com I can open my gdb on the command line: C:\data>ogrinfo ...
0
votes
0answers
73 views

Confusing offsets in shapefile written by QGIS/OGR

I think I'm stuck here. A shapefile has been updated in QGIS. Records have been deleted and those records have been marked with an asterix in the first byte of the record in the dbf file. I open the ...
1
vote
2answers
564 views

OGR Projection transformation error

I am trying to convert shapefile that was created by FME in EPSG:900913 to EPSG:3857 (I know its the same definition) with OGR in a script. datasource = ogr.Open(os.path.join(dirname,shapefileName)) ...
2
votes
1answer
171 views

How to sort features in a layer using OGR/Python?

How can I sort the features of an ogr layer by the values of a field? I tried naive variations of def sortlayer(ds, layer, field): lname = layer.GetName() lsort = ds.ExecuteSQL(b'select * ...
2
votes
1answer
1k views

Installing GDAL with Java Bindings (gdal.jar) on Ubuntu 12.10

I am trying to build a postgis importer for mutliple shapefiles. After geotools took orders of magnitude longer than shp2pgsql to import my data, I decided to attempt to use the java bindings to GDAL ...
0
votes
1answer
216 views

How to create feature LineString in a Polygon shape file layer (OGR/GDAL)?

I used below codes to create ShapeFile layer OGRDataSource *poDS, *poSHPDS; OGRLayer *poSHPLayer; ...... poSHPLayer = poSHPDS->CreateLayer (shpFileName, NULL, wkbPolygon , NULL); And I ...
3
votes
1answer
240 views

Python - OGR: Distance different than in ArcGIS

I want to determine the shortest distance between a point and a line. I use the following Python script to do so. If I compare the result of the script with the result of ArcMap's Near Analysis, I get ...
0
votes
1answer
188 views

Problem with showing Shape file in Geoserver

I have a number of Shape files from a customer. I can read them with both ogrinfo and QGIS. They don't have a prj-file, but I know that the projection is EPSG:3006. When I add them as layers in ...
0
votes
0answers
123 views

How to check are there any OGRGeometry (polygons) within an OGRGeometry (polygon) ?

Please see my image: I used the below statements to get Geometry: OGRGeometry *poGeometry; poGeometry = poFeature->GetGeometryRef(); Do you know how to check whether the Polygon 1 ...
0
votes
1answer
148 views

Can't convert geometry from Dgn file to Shape file?

I am using below codes to try convert geometry from a Dgn file to Shape file. But, I can't exit the Feature reading loop. Are there anyone know why and how to fix it ? Please download the dgn file ...
12
votes
1answer
557 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?
3
votes
0answers
54 views

How do I get the domain from an OGRSpatialReference?

I would like to know what the projected bounds are for a spatial reference using OGRSpatialReference. Is there some way to use the GetProjParm method to get this information? An example of what ...
12
votes
1answer
3k 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 ...
5
votes
1answer
758 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 ...
1
vote
1answer
128 views

Creating prepared geometries with OGR from Python

Is it possible to create a prepared geometry object using the Python SWIG geos.ogr module? It seems that Shapely and GeoDjango both have this functionality, but I can't see any mention of it in the ...
1
vote
0answers
88 views

Python GDAL/OGR: check lines geometries connectivity

I'm working with shapefiles representing roads, so basically it's stored as (poly)lines. I need to perform a road connectivity checking. In other words, I want to ensure that roads meant to ...
2
votes
3answers
203 views

How to test if geometry is inside another?

I need to tell whether geometries from a shapefile are inside other geometries or not. For example, I want to test if there are trees (represented as points in trees.shp) inside the urban areas ...
2
votes
1answer
435 views

Batch convert OSM/PBF data

I need to import some OSM data about a region of Italy into a SHP file or Postgres DB, possibly with batch process. I already use OGR2OGR to batch import data from SHP to Oracle and Postgres and I ...
1
vote
1answer
124 views

OGR UnionCascaded gives strange lines (flat polygons)

I'm using OGR to perform a union using UnionCascaded. All my polygons have been created by GDAL polygonize which ensures that all polygons follow pixel edges and should therefore align nicely. But I ...
1
vote
4answers
446 views

Get vector features inside a specific extent

The problem: I have a very large vector layer with many features and a much smaller raster layer in a defined region. I want to get only those vector features which are within the raster layers ...
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 ...
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 ...