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

0
votes
0answers
65 views

SetSpatialFilter worked unexpected when using ogr by python

I am using ogr python binding to read the shapfile, this is the code: ..... bbox="POLYGON ((20.18164062 30.63867188,20.63867188 30.63867188,20.63867188 30.18164062,20.18164062 30.18164062,20.18164062 ...
1
vote
0answers
16 views

Asking about OFTInteger data type in OGR/GDAL?

I created the shape file by using the feature field type: OFTInteger. But when I open the file in Arcgis (ArcCatalog) the data type is: Double (not integer). Do you know how to fix this (I want it ...
1
vote
1answer
204 views

Writing shapefile with projection defined crashes fiona

I've just started trying to use Fiona to write out shapefiles. I found the example code below, which seems to work fine from shapely.geometry import mapping, Polygon import fiona # Here's an example ...
1
vote
1answer
93 views

How to filter date values using OGR 1.11.0?

With OGR 1.10.1 this works: ogrinfo test2.shp -sql 'SELECT COUNT(*) FROM test2 WHERE DATE < "1970-01-01"' Note that DATE is a column of type date (not string). (Here's test data if you want to ...
0
votes
0answers
42 views

Comparing datums with GDAL/OGR

I have a bit of code in Java that takes in a SpatialReference object and checks that it is one of the acceptable datums (WGS84, NAD83, NAD83 HARN, NAD27), but because of the lack of standardization in ...
0
votes
1answer
58 views

TileStache can't find spatial ref for vector layer

I have a query based vector layer in my TileStache configuration, and it's hitting this block of code if layer.GetSpatialRef() is None and driver_name != 'SQLite': raise KnownUnknown('Couldn\'t ...
2
votes
2answers
60 views

How to replicate ArcGIS coordinate transformation with ogr2ogr?

I need to be able to replicate with ogr2ogr a coordinate transformation that was executed in ArcGIS for Desktop. Both ArcGIS and ogr2ogr are based on EPSG standard definition. There's not only one ...
0
votes
1answer
84 views

no viewable feature when creating line with ogr in python

the python code below produces the expected line shapefile viewable in QGIS import os from osgeo import ogr drv=ogr.GetDriverByName('ESRI Shapefile') if os.path.exists('test.shp'): ...
1
vote
1answer
53 views

List the tab/shp files properties within folders/sub folders w.r.t relative folder path [closed]

Currently i am using this command line For /R "U:\01 My Proj" %f in (*.tab) do ogrinfo -al -so "%f" >>U:\New.txt to extract all the tab file related information as a text.Instead of giving the ...
2
votes
0answers
63 views

Append ArcGIS feature layer data using GDAL/OGR API

ArcGIS servers are configured with a maximum records count that they're allowed to return following a REST query. This maximum is usually 1000 records, which means that GDAL/OGR clients should ...
3
votes
2answers
361 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 ...
0
votes
1answer
160 views

Get the outer ring inner ring for a given polygon using ogr python binding

I am trying to read the geometry of some shapefiles, now I meet some problem when I try to identify the polygon with holes, since a polygon may(or not) have one hole(or multiple holes). This is the ...
0
votes
1answer
71 views

Creating an OVF file for connecting Oracle and QGIS

I'm trying to create an OGR file that can be opened in QGIS that pulls in vector data from an Oracle Database. I've tried a few combinations of things but can't seem to get anything to work. I've few ...
1
vote
1answer
240 views

Union multiple shapefiles with overlapping shapes

I have several shapefiles that overlap and I would like to union their geometries to get rid of those overlaps. I know how to do this with OGR and Python for single geometries. from osgeo import ogr ...
1
vote
0answers
48 views

GeoJson attributes encoding limitation

I have problem when trying to encode attribute values in latin1 using ogr GeoJson driver. Accent char are not displayed correctly. Is the geoJson encoding is limited to UTF-8? I cant find any info ...
0
votes
1answer
80 views

How to get feature for a given bbox from shapefile by ogr

I have some features point,line,polygon with shapefile format, now I want to get features for a given boundbox, is it possible to remove the features out of the bbox? And for a polygon, I think it is ...
1
vote
1answer
38 views

ogr: what is the advantage of using `geom.Clone()` over `geom`?

What is the advantage of using geom.Clone() over geom? Simple example: geom = link_feat.GetGeometryRef() newfeature.SetGeometry(geom.Clone()) # or newfeature.SetGeometry(geom) ...
1
vote
1answer
194 views

GDAL - How to get gemetry type of a MapInfo TAB file?

I am using the OGR MapInfo File driver to read a MapInfo TAB file. However, the function GetGeomType() returns 0 which means 'wkbUnknown` even if the features in the TAB are only multi-polygons. Is ...
0
votes
0answers
105 views

aggregate counts on a grid and determine grid adjacency

So here is the problem I am working on. I have a bunch of lat, long coordinates for event occurrences. I want to create a grid and then count how many points fall into each grid pixel. Once I have ...
0
votes
1answer
212 views

create polygon adjacency matrix using python

I am trying to create an adjacency matrix from a set of polygons. That is, I have a bunch of polygons and I want to identify which polygons have a common edge or "touch" each other. Once I find this ...
1
vote
1answer
109 views

My class using ogr to calculate distance is returning incorrect results away from the equator

In an answer to this question ustroetz kindly provided some sample code for use of ogr to do lat/lon distance and point in polygon calculations. I've created a Python class based on his example to do ...
3
votes
1answer
233 views

Are the functions in OGRPolygon accessible through the python bindings?

I'm currently trying to use the OGR python bindings to process some shapefiles. I want to obtain the number of interior rings in a polygon feature. Unfortunately I'm unable to use the documented ...
3
votes
1answer
120 views

writeOGR column limit error: “Creating Name field failed”

I have a SpatialPointsDataFrame with 1057 elements and 4760 columns and want to export it to a shapefile. When I try to do this with writeOGR() I get an error: > ...
0
votes
0answers
28 views

ogr: confusing results from `SetSpatialFilter()`

My layer is derived from a data source like this: l_131 = bounds.ExecuteSQL("select * from 'nam_l' where 'ND_5'= 131 ") feat = l_131.GetNextFeature() feat.GetFeatureCount() >>> 200 It is a ...
0
votes
4answers
265 views

Trouble converting .osm to .pbf with Osmosis

I would like to convert a shp file to map file. I know should use these steps: shp -> osm -> pbf -> map For step 1 I use a python script : ogr2osm.py For step 2 I use osmosis, but I get ...
0
votes
0answers
41 views

Does a road connect one grid cell to an adjacent grid cell?

So here is the problem I am working on. I have an OpenStreetMap roadmap which I overlaid with a 2-D cartesian grid. So for a given grid square, I want to find out if a road segment continues from the ...
2
votes
1answer
193 views

Using ogr2ogr to download GeoJSON files from ArcGIS MapServer

I am trying to download as a GeoJSON file a line feature from a ArcGIS MapServer REST Service run by the National Park Service (link is here) so that I can open the data in QGIS. Using the guide ...
1
vote
0answers
50 views

Transformation of OGR style data

I have been using GDAL/OGR in a project and it is going quite well. I have been re-projecting data from various source formats into a single CRS (using the C# bindings), but one issue I have come ...
1
vote
1answer
161 views

Equivalent function to shapely's envelope in ogr?

I wrote a very simple python function that gives me the envelope/bounding box/...based on two coordinate pairs (ower left and upper right corner): # ... def get_bounding_box(self, ll_corner, ...
2
votes
1answer
613 views

Import shp to Postgis using Python and ogr

I just export a Postgis Table to shp using this tips but I'm not able to import a shp to Postgis using the same library(ogr). Any idea? Thanks a lot f.
1
vote
1answer
121 views

ogr2ogr/python overwrite PostGIS table

Using ogr2ogr command line I can overwrite or append to an existing PostGIS table like: ogr2ogr -f "PostgreSQL"-overwrite PG:"host=myserver port=54321 user=user dbname=mydbname password=mypassword" ...
4
votes
3answers
1k views

PostGIS: parse geometry wkb with OGR

I'm trying to pull a LineString geometry out of PostGIS and parse it with OGR (python bindinds). from osgeo import ogr import psycopg2 connection = psycopg2.connect("...") cursor = ...
2
votes
1answer
52 views

ogrinfo returns a negative coordinate for extent of mif data file

I'm trying to get the extent of a MIF file using ogrinfo. The MIF file is supposed to be in epsg:23030 projection. This is: PROJCS["ED50 / UTM zone 30N", GEOGCS["ED50", ...
1
vote
0answers
97 views

Getting “Segmentation fault: 11” with ogr in Python

This is the code I'm trying to run: In [1]: from osgeo import ogr In [2]: datasource = ogr.Open('testdata.shp') In [3]: datasource.GetLayerCount() Out[3]: 1 In [4]: layer = ...
0
votes
1answer
67 views

Is it possible to get all projections form OGR?

I'm working on a project where the user can give my program so GIS data which may or may not have which projection it is using. So is it possible to get a list of all the projections from OGR or ...
1
vote
1answer
267 views

ogrinfo sql example

I'm having trouble learning how to query my shapefiles for certain features. I have a shapefile that looks something like this when I summarize it using the following command: ogrinfo -al -geom=OFF ...
5
votes
2answers
697 views

How to access Shapefile metadata using OGR?

I'm trying to use ogrinfo to get some details on a shapefile I downloaded. Currently, the only way I know how to do this is to load it into QGIS and manually click around to find any information on ...
1
vote
2answers
352 views

I need to extract a specific layer from a Geospatial PDF using GDAL/OGR

I have GDAL/OGR 1.10 installed on a 64bit Windows 7 machine. I have some Geospatial PDFs that I want to crop to the outline of the map and convert to Rasters. However I cannot clip to the neatline. ...
0
votes
0answers
96 views

GEOS assertion failed

The following script fails, if I import the 'rasterstats' library. import rasterstats import ogr geom1 = ogr.CreateGeometryFromWkt('POLYGON ((415924.806155724043492 ...
2
votes
2answers
56 views

Comparing projections of two datasets when SRID not available

Similar to this question: How to test if two GDAL datasets are in the same projection? However, the above does not cover cases where an SRID is not available. It can often be the case that an SRID is ...
0
votes
1answer
448 views

Will MapInfo only read PostGIS data that has been loaded via EasyLoader?

NMZ says in this thread that MapInfo will only read data in PostGIS that has been loaded by MapInfo's EasyLoader. I wasn't sure if this was still the case so I've loaded data into postgis via ogr2ogr ...
6
votes
1answer
246 views

How can I get Google Fusion Tables to work in QGIS?

I am using GDAL/OGR 1.10 and QGIS 2.0.1. I am trying to load a google fusion table into QGIS using the method mentioned in this blog post. The only difference is that I am not declaring a email and ...
1
vote
1answer
124 views

How can I use the proj string in java code?

I want to do projection from UTM/oblique mercator CRS to WGS84. And I know the solution to use a proj.4 string in commandline like+proj=omerc +lat_0=51.4 +lonc=7 +alpha=-10 +k=1 +x_0=0 +y_0=0 +gamma=0 ...
2
votes
0answers
155 views

How to compile QGIS with Oracle Spatial support for Linux?

I compiled it on Fedora and Ubuntu, but got error "Cannot get Oracle select dialog from provider." while trying to add Oracle layer. Packages in repositories don`t have oracle spatial support. Can ...
1
vote
1answer
227 views

Why does OGR driver.Open() for File Geodatabase give AttributeError: NoneType object has no attribute Open?

There are a number of existing Questions that hint at a possible Answer to this Question, but none seem to be providing me with the solution to my problem: How to access feature classes in file ...
0
votes
1answer
39 views

Debug/Improve Performance of GRASS v.in.ogr

I'm trying to import shapefiles (in this case, OpenStreetMap data) into GRASS (grass70-svn) using v.in.ogr; and it is painfully, brutally slow. At first I thought this was because I was using the ...
2
votes
2answers
156 views

Can I use the LEFT (string) operator in ExecuteSQL()?

In QGIS I can use the LEFT operator on a dataset like this: LEFT( "Name2",3) ='031' What is the syntax for using this expression with ogr in python? Isn't this the right syntax? ...
1
vote
1answer
912 views

OGR Layer Intersection

I am using what I would describe as the most primitive method of doing intersection with OGR. The short script below describes how I do it. Is there a best way of doing this? from osgeo import ...
0
votes
1answer
265 views

Convert from Gauss-Kruger to Bing coordinates / projection

I am trying to convert a shapefile with ogr2ogr from Gauss-Kruger (zone 4) to Bings coordinate system / projection using the advice given in ...
2
votes
1answer
132 views

How can I delete a shapefile using OGR?

In my QGIS Python plugin, I use shapefile layers and I am having a problem rewriting existing shapefiles. Is it possible to delete a shapefile from disk using OGR?