Tagged Questions

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
1answer
104 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 ...
1
vote
1answer
170 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? ...
2
votes
1answer
433 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
118 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 = ...
0
votes
1answer
220 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 ...
0
votes
1answer
82 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& ...
1
vote
2answers
156 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 ...
3
votes
1answer
1k 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 ...
2
votes
1answer
102 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
79 views

Is georeference the same as geotransform?

Does georeference mean the same as geotransform? If not then what is the difference?
6
votes
1answer
273 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
610 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 ...
0
votes
1answer
196 views

how is the command of ogr2ogr for converting the adf to shp?

What is the correct format of ogr2ogr for converting the ADF grid to SHP file? I tried this, but it fails. $ ogr2ogr -where "OGR_GEOMETRY='Point'" -f "ESRI Shapefile" SHP.shp ADF.adf
1
vote
0answers
93 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 ...
1
vote
1answer
92 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
0answers
75 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 ...
3
votes
1answer
202 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 * ...
0
votes
1answer
252 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 ...
2
votes
0answers
319 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 ...
2
votes
1answer
475 views

Error when using gdal/ogr and python to clip a “shp” file by a “shp”

I am new to the gdal/ogr library for python and I was wondering how to clip a shp file by another shp file. I think I am having trouble with the syntax. Thanks - Stefan I keep getting a windows error ...
0
votes
1answer
216 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
141 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
167 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 ...
1
vote
2answers
741 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)) ...
3
votes
0answers
57 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 ...
6
votes
1answer
3k 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
1answer
941 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
0answers
97 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
1answer
528 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
135 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 ...
5
votes
4answers
451 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 ...
3
votes
2answers
723 views

GDAL SQL syntax to add field an put values

I try to make a new field in my attribute table and put in values from another field after converting from character to integer but can't get the right syntax. I run this as shell-script in MSYS. cd ...
1
vote
1answer
132 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 ...
2
votes
3answers
224 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 ...
1
vote
0answers
54 views

how to get correct geo reference system for a VMap

I am new to GIS, trying to read the GeoRef System for VMap by using the following code: OGRSpatialReference *ref = layer->GetSpatialRef(); if( ref ) { QString georefSystem = ...
14
votes
1answer
705 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?
1
vote
4answers
312 views

Does shapefile or MapInfo TAB have advantage as source format for OGR conversion to GeoJSON?

I'm relatively new to OGR and GIS in general. Most of the sources I look at give a choice of ESRI shapefile and MapInfo formats. I'm using ogr2ogr to convert these to GeoJSON for import into ...
2
votes
0answers
104 views

traversing KML files with ogr python

i'm new to OGR processing and KML format so be gentle: i've got a series of KML files all containing multiple regions partitioning a larger area in each. i also have a series of geocoded points for ...
2
votes
1answer
272 views

OGR - Weird GeomType -2147483645 on polygon shapefile

I am trying to import a shapefile (multipolygon) in an app with ogr but I got an error about invalid geom type. If I inspect the data with ogr like this: datasource = ogr.Open("c:\\temp\\data.shp") ...
0
votes
1answer
468 views

OGR OSM-driver unable to open datasource

I want to read an OSM file with OGR. I use Version GDAL 1.9.1, released 2012/05/15. To read a SQLITE file works fine: $ ogrinfo test.sqlite INFO: Open of `test.sqlite' using driver `SQLite' ...
1
vote
4answers
556 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 ...
1
vote
3answers
138 views

Why is ogrinfo showing no layers from an ESRI FileGDB?

I have an ESRI File Geodatabase (FileGDB) (size is 15+GB), which has over 10 layers, when I open it up in ArcGIS, everything seems to be working. I want to move this database to postgreSQL with OGR ...
4
votes
1answer
1k views

better way to duplicate a layer using ogr in python?

I'm splitting a large shapefile into many smaller ones using ogr. I'd like to just copy all of the field and layer config information from the original. Here's how I'm doing it now: src = ...
3
votes
2answers
249 views

Need help assigning values to field using OGR in python

I've got a similar question to this one How to programatically populate a shapefile field with polygon areas in OGR?, but the solution doesn't seem to be working for me. I am trying to import a ...
2
votes
1answer
333 views

need help for script checking topology using ogr in python

My main goal is to create a new feature indicating if the line features intersect each other as well as if they are not connected to a feature. My problem is how to identify the intersecting and not ...
0
votes
2answers
100 views

OGR GetX() returns always zero

I am trying to get the first x-coordinates of a polygon. However I only get zero in return. What could cause that? import os, sys, gdal, ogr from gdalconst import * driver = ...
2
votes
1answer
216 views

Convex Quadrilateral Polygons subdivision in equal parts using Python / OGR

Consider an irregular polygon (P) which has four vertices. I would like to subdivide P into smaller polygons as shown here http://i.stack.imgur.com/4SKhB.jpg In the old days I was using ArcGIS 9.3 ...
2
votes
1answer
223 views

OGR CreateLayer returns TypeError

I'm trying to create a shapefile layer based on the spatial projection of an already existing raster. (Ultimately, this will be used in gdal.Polygonize to get a shape from my raster data.) However, I ...
3
votes
1answer
276 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 ...
4
votes
1answer
329 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. ...