Questions tagged [ogr]

The OGR Simple Features Library is a C++ open source library (and commandline tools) providing read (and sometimes write) access to a variety of vector file formats including ESRI Shapefiles, S-57, SDTS, PostGIS, Oracle Spatial, and Mapinfo mid/mif and TAB formats. OGR is a part of the GDAL library

The OGR Simple Features Library is a C++ open source library (and commandline tools) providing read (and sometimes write) access to a variety of vector file formats including ESRI Shapefiles, S-57, SDTS, PostGIS, Oracle Spatial, and Mapinfo mid/mif and TAB formats.

OGR is a part of the GDAL library

212 questions
2
votes
1 answer

Segmentation fault returning OGR Layer object from function in Python

I have a simple programme that processes points from a Geopackage layer. On a first attempt I encapsulated file access into a function: from osgeo import ogr pointsFile = "points.gpkg" def getPoints(): driver = ogr.GetDriverByName("GPKG") …
Luís de Sousa
  • 5,765
  • 11
  • 49
  • 86
2
votes
2 answers

Install GDAL/OGR Python API on Debian

I trying to install Python GDAL/OGR bindings to be accessible directly from Python interpreter on Docker python:3.6-stretch image. My Dockerfile looks like that: FROM python:3.6-stretch ENV PYTHONUNBUFFERED 1 ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 RUN…
sorryMike
  • 769
  • 9
  • 25
2
votes
2 answers

relative paths using readOGR are different depending on whether R script or rmarkdown

In my regular .R script I am using relative paths to read data using rgdal::readOGR: library(rgdal) pts <- readOGR("data/points.gpkg") However the same code in an R snippet in an Rmd doc: ```{r} pts <- readOGR("data/points.gpkg") ``` returns the…
ASeaton
  • 95
  • 6
2
votes
1 answer

How to load all fields/ExtendedData (not just 'name' and 'description') from KML layer into R

I've been working on loading KML files into R to make web maps with Leaflet/Shiny. The import is pretty simple (using this sample KML): library(rgdal) sampleKml <- readOGR("D:/KML_Samples.kml", layer = ogrListLayers("D:/KML_Samples.kml")[1]) In…
Lauren
  • 1,035
  • 1
  • 14
  • 32
2
votes
0 answers

How to fix a shapefile reprojected from sinusoidal projection to lat long?

I have been work in convert the MODIS Tiles Grid from sinusoidal projection to lat long projection using python ogr2ogr. It doens't works well, the shapefile reprojected presents some lines that was not present in the original shape and it produces…
2
votes
1 answer

Python GDAL/OGR : how to create a MapInfo TAB file?

Using import gdal,ogr, and given an EPSG (e.g. here 2154), what is the code in python to write a (nearly) empty MapInfo TAB file, or just the summary line of the projection (TAB format) : CoordSys Earth Projection…
Eric H.
  • 2,152
  • 4
  • 22
  • 34
2
votes
0 answers

How to make Gdal work again with El Capitan?

I had Gdal installed and it worked fine with MacOS Lion and Yosemite. Now that I moved to ElCapitan, it does not work anymore. I realized this while trying to run a command ogr2ogr for which I received the error: bash: ogr2ogr: command not…
Doon_Bogan
  • 359
  • 5
  • 17
2
votes
0 answers

Python crashes when adding a field to a shapefile with ogr

When adding a field to a shapefile using the ogr package in python, the program crashes at the last step which is "SetFeature". This problem has been reported before, but I have not been able to resolve it based on other posts. Here is a sample…
2
votes
1 answer

Use Python "with" statement for ogr.open(file)

Is it possible to use the Python "with" statement with the ogr.open(file) function? For example, I would like to do something like: with ogr.open(file) as ds: At the moment, I can only get the following to work: try: ds = ogr.open(file) …
Philip Whitten
  • 293
  • 2
  • 16
2
votes
1 answer

How to replace values in an attribute table for one column?

I need to replace values in an attribute table for one column (replace zeroes in column named "label" to 100). Is this possible using ogr or python? I have to do this for 500+ shapefiles.
ropsi
  • 141
  • 2
  • 8
2
votes
0 answers

readOGR with geojson giving me "cannot open file" error

I'm pretty new to using rgdal so I'm hoping this is something simple that I'm missing, but I've been googling around about it for a few hours and I can't figure out the issue. Basically I'm trying to make a leaflet map in a shiny app, but I'm…
seth127
  • 2,594
  • 5
  • 30
  • 43
2
votes
0 answers

R how to fastly select features within a polygon from another layer?

I'm looking an R or OGR equivalent to rgeos::gIntersection() but as efficient as the the "Vector->Research tools->Select by Location" from QGIS or the "Select by location" in ArcGis.
Wraf
  • 747
  • 2
  • 10
  • 24
2
votes
2 answers

Can't get Python IDLE to recognize OGR/GDAL Module

Folks, Just getting started using OGR and Python for a variety of geospatial tasks. I'm working outside of OSGEO4w, and have installed GDAL w/ Python Bindings as well as Python v. 2.7.8 on my machine. That said, I can run python and import gdal from…
GISNC31
  • 21
  • 2
2
votes
0 answers

string replace does not work as expected

I am using python to read the shapefile, however I meet some problems, this is the core code: value="#code" print 'value:',value if '#' in value: v=value.replace('#',''); print 'replaced:',v …
hguser
  • 35,079
  • 54
  • 159
  • 293
2
votes
1 answer

Remove point from GDAL LineString

I am trying to just include geographic features from a shapefile that lie within a given bounding box. I couldn't find a function similar to Matlab's shaperead function with a BoundingBox option [1] and so I am trying to remove non-relevant points…
tjp
  • 203
  • 1
  • 4
  • 9