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
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
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
34 votes
3 answers
21k views

Uploading Geopackage contents to PostgreSQL

As a bit of background, we are looking to transition away from the use of shapefiles. We've already started using Geopackages for desktop work (QGIS / ArcGIS) but often have a requirement to upload ...
James Norris's user avatar
33 votes
1 answer
13k views

What does OGR stand for?

There are numerous commands and libraries that I see referenced or prefixed with OGR. What does the OGR stand for? ogrinfo ogr2ogr
Evan Carroll's user avatar
  • 7,091
30 votes
2 answers
7k views

Using OGR and Shapely more efficiently? [closed]

I'm looking for some suggestions about how to make my python code more efficient. Normally efficiency doesn't matter for me but I am now working with a text file of US locations with over 1.5 million ...
GrantD's user avatar
  • 309
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
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
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
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
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
23 votes
1 answer
7k 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?
rudivonstaden's user avatar
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
22 votes
1 answer
11k views

How to change the field value of a Shapefile using GDAL/OGR?

I am trying to change the field value of a shapefile. However it doesn't change the value. What's wrong with my code? import ogr driver = ogr.GetDriverByName('ESRI Shapefile') fn = 'dist.shp' ...
ustroetz's user avatar
  • 8,014
21 votes
4 answers
27k views

Where do I find the ogr2ogr command for Mac OS X Lion?

I am looking for the equivalent of FWTools for Mac OS X, Lion. Is there anything I can easily install and get that command?
CLJ's user avatar
  • 823
21 votes
7 answers
13k views

Stopping 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) ...
JPD's user avatar
  • 1,678
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
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
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
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
19 votes
2 answers
16k views

Adding custom feature attributes to shapefile using OGR in Python

I am seeking a way to take an existing Shapefile that has a Feature set of 200 countries. Each country Feature has an attribute of "NAME." My objective is to create a Python script that adds an ...
mattdeboard's user avatar
19 votes
1 answer
2k views

Converting line shapefile into CSV with nodes and links

Is there a way to convert a linear shapefile into a CSV file of the following format: Node_1 Node_2 attribute_1 .... attribute_x 1 2 "hello" .... 567845.334 I have looked at GDAL/OGR2OGR ...
dassouki's user avatar
  • 8,563
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 ...
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
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
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
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
16 votes
2 answers
20k 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 ...
dvreed77's user avatar
  • 373
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
16 votes
3 answers
3k views

ogr2ogr fails to convert GeoJson file > 200MB

As a followup to my previous question (Converting SimpleGeo Places GeoJSON file to shapefile), I am now struggling with what I perceive might be an ogr2ogr "memory" limitation, but I cannot be sure. ...
RyanKDalton's user avatar
  • 23.1k
14 votes
3 answers
6k views

Calculate total area of polygons in shapefile using GDAL?

I have a shapefile in British National Grid projection: Geometry: 3D Polygon Feature Count: 5378 Extent: (9247.520209, 14785.170099) - (638149.173223, 1217788.569952) Layer SRS WKT: PROJCS["...
Richard's user avatar
  • 3,299
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
14 votes
3 answers
3k 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. ...
Jay Laura's user avatar
  • 4,463
14 votes
3 answers
4k views

What is the intended Behavior of -skipfailures in ogr2ogr?

I am trying to run ogr2ogr to convert some geojson to shapefile. All is good until any of the geojson features have an invalid geometry (for example, the coordinate array of point geometry is empty). ...
user890's user avatar
  • 5,733
14 votes
1 answer
3k views

Is there a way to properly have GDAL raise exceptions in Python?

I am working with GDAL in Python and have wanted to get GDAL to raise exceptions so that I can do something useful with them. For instance if a file cannot be opened with gdal.Open() I would like to ...
Doug's user avatar
  • 617
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
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
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
13 votes
1 answer
3k views

OGR/GDAL threading results in low core utilization

I'm trying to process some raster data using ogr/gdal and I can't seem to get full utilization of all the cores on my machine. When I only run the process on a single core, I get 100% utilization of ...
Max's user avatar
  • 391
12 votes
5 answers
8k views

how can i convert a shapefile to lat and lon boundaries?

i have a shapefile of country subdivisions and i would like to extract an array of bounding lat and lon for each division.. is it possible to do?
mossplix's user avatar
  • 223
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
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
12 votes
1 answer
2k views

ogr2ogr (or other) simplification of polygons with shared boundaries

I am trying to simplify a collection of 100,000 or so polygons containing nearly 4 million vertices. The data is stored in a 2GB shapefile so there is no explicit representation of the topology ...
embeepea's user avatar
  • 221
11 votes
3 answers
8k views

How to make a local copy of a large WFS dataset?

We are writing a application in which a part of the job is to fetch a relatively large (>10000 features) and often updated dataset from a WFS server, store a local copy, and do geospatial analyses on ...
user avatar
11 votes
2 answers
7k 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 ...
Kay's user avatar
  • 1,856
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
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
11 votes
2 answers
7k views

How to buffer a vector shapefile using ogr python?

I am trying to learn how to use ogr in python using the country and populated places datasets from http://www.naturalearthdata.com/downloads/50m-cultural-vectors/. I am attempting to use filters and ...
user1765941's user avatar
10 votes
3 answers
18k 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 = connection.cursor(...
ilia choly's user avatar

1
2 3 4 5
23