Skip to main content

Questions tagged [ogr]

The OGR Simple Features Library is a C++ open source library (and command line tools) providing access to vector file formats.

Filter by
Sorted by
Tagged with
46 votes
1 answer
36k views

Getting pixel value of GDAL raster under 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 ...
James's user avatar
  • 813
22 votes
3 answers
91k views

Check if a point falls within a multipolygon with Python

I have tried several examples of code using libraries such as shapefile, fiona, and ogr to attempt to check whether a point (x, y) falls within the boundaries of a multipolygon created with ArcMap (...
spartmar's user avatar
  • 563
10 votes
7 answers
24k views

Fixing corrupt shapefile?

I have a shapefile that I was working on in ArcGIS Desktop 9.3 get corrupted somehow and it gives me the error "Number of shapes does not match the number of table records.". What I would want is to ...
Erick's user avatar
  • 873
20 votes
4 answers
45k views

Opening ESRI Personal GeoDatabase (*.mdb) in QGIS

How can I open an ESRI Personal Geodatabase (*.mdb; ArcGIS 10.2) in QGIS 2.6 or above?
David's user avatar
  • 201
17 votes
4 answers
17k 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 ...
Alex Tereshenkov's user avatar
25 votes
1 answer
20k views

Selecting features by attributes using ogr2ogr?

I am writing a shapefile after some processing; however, in the final step I need to do some selection by attributes from the the shapefile. I am using the command in a shell with the aim of using it ...
user2757128's user avatar
41 votes
10 answers
54k views

Generating points that lie inside polygon in QGIS

In QGIS I have a polygon feature and want to be able to generate points inside it. I need this for one classification task. Any suggestions? Generating random points until one is inside the polygon ...
user2024's user avatar
  • 419
26 votes
5 answers
33k views

Adding 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 ...
Mike T's user avatar
  • 42.2k
4 votes
1 answer
3k views

How to run OGR in ArcGIS Scripts?

When I run my script outside ArcGIS it works because during execution script uses a GDAL and OGR modules from osgeo. When I use script as a tool in ArcGIS it does not work. In PySripter I can import ...
ConeGIS's user avatar
  • 389
3 votes
1 answer
8k 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 (...
Hugolpz's user avatar
  • 2,653
24 votes
5 answers
49k views

Installing GDAL on MacOSX?

Does anybody know what's the easiest way to install GDAL 2.0 on a MacOSX? The usual suspects kingchaos binary distribution and homebrew seem to be stuck on GDAL 1.11 I need support for TopoJSON ...
tato's user avatar
  • 813
19 votes
3 answers
25k views

Generating GeoJSON with Python

I want to programmatically create a GeoJSON file using polygons from a shapefile but adding attributes from my own application. This is easily done for a shapefile: def create_data_dayer(self,...
fccoelho's user avatar
  • 1,237
35 votes
10 answers
7k views

Shifting all features in vector dataset using Bash/OGR

Let's say that I put together a Shapefile and all the features have their vertices shifted by a constant amount. What's the easiest way of shifting all the features (hence the (x,y) position of ...
Jose's user avatar
  • 3,342
18 votes
3 answers
7k views

Join 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 "...
Lincoln Mullen's user avatar
16 votes
3 answers
22k views

How to create polygon shapefile from a list of coordinates using python gdal/ogr?

I am trying to create a polygon shapefile from a list of coordinates using open source python tools. The following is what I have so far which was hacked together from the Python GDAL/OGR Cookbook and ...
Aaron's user avatar
  • 51.7k
18 votes
8 answers
106k views

Installing GDAL and OGR for Python?

I am developing some code in Python, and I want to use the GDAL/OGR python bindings. What is the minimum I need to install in order to use the GDAL and OGR python bindings? What is the easiest way to ...
13 votes
5 answers
10k views

How to build a geographic database of GPS logs?

On our aerial wildlife surveys we typically generate dozens of GPX files, and usually convert most of them into shapefiles for display in a GIS application. GPX files are a terrific way of keeping all ...
Simbamangu's user avatar
  • 14.8k
9 votes
3 answers
11k views

Converting CSV file of WKT data to shapefile using ogr2ogr?

This question is related to Converting shapefiles to text (ASCII) files?. I have a CSV file, with one column, where all the rows correspond to WKT POLYGON()'s: WKT POLYGON(...) POLYGON(...) ... I'm ...
Pris's user avatar
  • 1,251
6 votes
2 answers
5k views

GDAL Python bindings not picking up OGR PostgreSQL driver

I have a windows server (Microsoft Windows Server 2003) with: Python 2.7, PostgreSQL 9.04-1, GDAL 1.8.1 (installed from the windows installer (gdal-18-1500-core.msi) hosted at http://vbkto.dyndns....
fod's user avatar
  • 348
1 vote
1 answer
4k views

Problem intersecting shapefiles with OGR in Python

I'm trying to move from ArcPy for geoprocessing. After searching some posts, I found this solution using the GDAL/OGR Python bindings: Intersect Shapefiles using Shapely My code is the following: ...
Ernesto561's user avatar
1 vote
1 answer
4k views

Writing a shapefile using OGR, from Shapely Geometry - No feature added Error

I am trying to write a shapefile from a Shapely geometry using PyQGIS in the QGIS 2.6.0 console. Lines of code before the OGR method to write shapefile: extnt = poly.extent() # gives a QtRectangle ...
Akhil's user avatar
  • 1,435
24 votes
1 answer
3k views

Can File Geodatabase API be Redistributed?

Esri's file geodatabase API can now be used with GDAL/OGR - Link however each individual seems to have to login to Esri and download the API files individually. For example this is referenced in a ...
geographika's user avatar
  • 14.3k
20 votes
2 answers
20k views

API documentation for Gdal/Ogr with C#

I want to assign projection to shapefile in my web C# application, for this i am using Gdal/OGR/OSR C# bindings and add osr_csharp.dll and ogr_csharp.dll references. But i am facing some difficulty ...
user1899's user avatar
  • 1,427
19 votes
4 answers
16k views

Get all vertices of a polygon using OGR and Python

I'm having a little trouble with the Python OGR API. What I am trying to do is get all the coordinates of each vertex of the outer ring of a polygon. This is what I have so far: import osgeo.ogr ...
Nathan W's user avatar
  • 34.8k
14 votes
8 answers
13k 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....
Vish's user avatar
  • 607
12 votes
1 answer
10k views

How to resample a batch of rasters using OGR/GDAL?

I'm looking for a function similar to GRASS r.resample. I have a folder full of TIF files and want to reduce their resolution ("scale them down") to reduce file size.
underdark's user avatar
  • 84.2k
11 votes
2 answers
7k views

Why can't I edit KML/GML layers?

Newbie here confused by my first experience in QGIS I have a handful of lines defining a bike route. Originally they were saved in a .gml file and later translated into .kml so they could be viewed ...
Dennis Conklin's user avatar
8 votes
2 answers
7k 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 = ogr.Open('...
user2076663's user avatar
8 votes
4 answers
3k views

Is it possible to create 3D dxf with OGR?

Does anyone know if it's possible to create a 3D dxf with OGR? I would like to assign the contour lines a Z value and then export them to dxf for some cad work. PS. I know FME can do this, however I ...
Nathan W's user avatar
  • 34.8k
7 votes
2 answers
9k views

Changing shapefile longitude from -180 - 180 to 0 - 360?

I have a shapefile of world countries, with longitude between -180° and 180°. How can I change the shapefile (eg. with ogr2ogr) for having longitude between 0 and 360°. Following OSGEO/Trac ...
Bruno von Paris's user avatar
7 votes
1 answer
9k 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 ...
ustroetz's user avatar
  • 8,014
4 votes
3 answers
7k 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 ...
Basile's user avatar
  • 3,583
4 votes
2 answers
2k 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....
Ratnanil's user avatar
  • 1,003
4 votes
1 answer
937 views

Clip overlapping polygon in equal sharing size

Within single shapefile I am trying to clip overlapping polygons to their boundaries using centre line of overlapped area using Postgis or ogr2ogr. I tried to use ogr2ogr command to remove slivers ...
Losbaltica's user avatar
  • 1,469
4 votes
1 answer
2k views

Styling KML through LIBKML layer creation options

I am exporting a layer from PostgreSQL to KML using ogr2ogr. I get a workable KML with a series of features (Placemarks). Here is a simplified example of a feature. (I took out the long list of ...
Andy's user avatar
  • 220
2 votes
3 answers
4k 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 ...
Sepideh Abadpour's user avatar
2 votes
2 answers
2k 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 ...
Moggy's user avatar
  • 371
2 votes
1 answer
6k 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, ...
LarsVegas's user avatar
  • 2,556
1 vote
1 answer
4k views

How current is GDAL in Java

I have used ogr2ogr to import various formats to PostgreSQL and have used GDAL utilities. Is there a complete Java port for these tools or are they simply wrappers calling JNI to C++ code? I have ...
Ramesh Elaiyavalli's user avatar
28 votes
3 answers
17k views

Is it possible to get the EPSG value from an OSR SpatialReference class using the OGR Python API?

When reading a layer from a OGR PostGIS connection I can get the SpatialReference of the layer, but is it possible to get the EPSG value? Is there any documentation on this? For example: lyr = conn....
Tomas's user avatar
  • 748
18 votes
2 answers
31k views

Convert a spatial polygon object to data frame using R

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 ...
John's user avatar
  • 181
17 votes
7 answers
9k views

Free tool to simplify parcel shapefiles?

Is there any tool available which let's me run millions of parcel shapefiles and simplify them?
NetConstructor.com's user avatar
16 votes
1 answer
14k views

Importing shapefile 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?
franco_b's user avatar
  • 522
13 votes
5 answers
2k views

Converting line simple features to topological network using GDAL/OGR

Using GDAL/OGR is there a way to convert an SHP, KML, or PostGIS line layer into a network of nodes and segments so it can be used in packages such as networkx?
dassouki's user avatar
  • 8,563
13 votes
3 answers
9k views

Divide a complex shapefile into a grid

I have a decently detailed shapefile with polygon/multipolygon features (the file is about 500mb). It's actually a shapefile of the entire world, with the features representing coastlines. I need to ...
Pris's user avatar
  • 1,251
12 votes
2 answers
11k views

Determining if shapefile and raster overlap in Python using OGR/GDAL? [closed]

I am building a script in python using OGR/GDAL. I have a set of shapefiles and a set of GeoTiff raster files. I would like to have my script ignore shapefiles if they do not intersect with the ...
JFerg's user avatar
  • 347
11 votes
2 answers
5k views

ogr2ogr sql query from text file

In ogr2ogr or ogrinfo, I can successfully query an Oracle database using this command as a test: ogrinfo -al -so "OCI:USER/PASSWORD@SERVER/DATABASE" -sql "SELECT * FROM SCHEMA.TABLE" However, ...
Karl Zinglersen's user avatar
10 votes
3 answers
5k views

getting dxf files out of PostgreSQL

I've successfully loaded a bunch of shapefiles into a PostGIS database. I would like to be able to retrieve specific geometry and layers as dxf files based on SQL queries. I'm using PostGIS, GDAL, ...
BenjaminGolder's user avatar
10 votes
1 answer
6k views

ogr2ogr specify lat/long order on conversion to GeoJSON

When using ogr2ogr to convert a polygon from a .shp file to GeoJSON, I noticed that it writes the coordinates in order lat, long. I noticed this because whenever I tried to view the GeoJSON on a map, ...
user139014's user avatar
10 votes
2 answers
4k views

DXF attribute to z value

We have been given a DXF that contains a Elevation attribute but we would like to generate a 3D DXF. I know I can generate a 3D dxf from a shapefile using: ogr2ogr -f "DXF" out.dxf in.shp -zfield ...
Nathan W's user avatar
  • 34.8k

1
2 3 4 5