Questions tagged [ogr]

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

223 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
0 answers
452 views

OGR failing to unpack polygons and respective holes from shapefile

I'm trying to unpack shapefiles in Python (v3.7.4) using the GDAL-OGR library (v2.3.3). Each shapefile has only one feature containing multiple polygons with holes. They cannot be produced differently....
Thaine Herman Assumpção's user avatar
5 votes
1 answer
497 views

Optimizing pixel extraction from GeoTiff using Python

I am creating IDF Curves for work using python and 30-minute rainfall rate rasters. There are 24 rasters per day and about two decades worth of data. I basically input lat/lon coordinates and my ...
JWB's user avatar
  • 574
5 votes
0 answers
218 views

Python osgeo/OGR not returning all features in PBF

I have a PBF file that is a limited export of the Nepal area. I'm trying to pull out all the adminstrative boundaries. If I use osmconvert to turn my PBF file into a OSM file, sure enough I see the ...
Nicolas Pottier's user avatar
5 votes
0 answers
2k views

How to perform spatial join and obtain attribute in python/GDAL?

I am working on a script that will take an unprojected raster, and using a UTM grid (shapefile), will obtain the correct SRS (I have a shapefile where each zone is attributed with its numerical SRS) ...
auslander's user avatar
  • 1,507
4 votes
0 answers
253 views

rename table/feature class in filegdb using ogr or qgis

According to the OGR SQL docs, it doesn't appear that it is possible to use and ALTER statement to rename an existing table (featureclass) inside of a file geodatabase. RENAME statements can be run on ...
jamierob's user avatar
  • 1,559
4 votes
0 answers
2k views

How to build .vrt of shapefiles?

I've a huge number of shapefiles and I would like to create a VRT as I do with gdalbuilvrt for raster. I find here https://github.com/dwtkns/gdal-cheat-sheet that it should be possible and the format ...
Wraf's user avatar
  • 539
4 votes
0 answers
2k 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 --version ...
rbuffat's user avatar
  • 143
4 votes
0 answers
1k views

Extracting x,y,z values from a postgis linestring to python using ogr

I am trying to load a postgis linestring into python (using ST_DumpPoints) and extracting x,y,z coordinates, which is working but extremely slow..and if i mean slow, i really mean it (yes, it takes ...
Arne's user avatar
  • 185
3 votes
1 answer
800 views

Dissolving polygons based on polygon attribute values in Python

I have a shapefile, with multiple features inside. I am trying to dissolve the nearby/adjacent features based on the shapefile particular attribute value (gridcode), but the difference shouldn't be ...
Shubham's user avatar
  • 39
3 votes
0 answers
237 views

Getting the results of a PostGIS query to a file with ogr2ogr with low memory usage

I have a PostGIS query returning geographies and attributes. The result set is deterministic and ordered (so OFFSET and LIMIT work for getting subsets). The result set of my query would exceed my RAM ...
inc42's user avatar
  • 810
3 votes
0 answers
1k views

How does OGR detect what GEOS version I have?

I'm attempting to solve this error: ERROR 6: GEOS 3.8 or later needed for MakeValid. The version of GDAL I am running is 3.0.4 which was downloaded as a .whl from https://www.lfd.uci.edu/~gohlke/...
Francis's user avatar
  • 917
3 votes
0 answers
428 views

ogr SetPrecision doesn't work

I'm creating a shapefile with a field type of real, but I want to lower the standard precision from 15 decimal places to 10, here is my code: dst_filename = "Polygonized.shp" drv = ogr....
Francis's user avatar
  • 917
3 votes
0 answers
483 views

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 ...
Iron Banker Of Braavos's user avatar
3 votes
0 answers
194 views

Generating pdf documents with geometries and raster using python

I'm looking for a way to generate PDF document containing: 1. Text in specified position 2. Raster file with border 3. Geometries overlaying raster. Basically it should look like this Geometries ...
kgkg's user avatar
  • 171
3 votes
0 answers
562 views

Boolean field (attribute type) in PostGIS with OGR Python

In my project I'm using ogr (python bindings) for inserting spatial data in PostGIS. The spatial data comes in all different formats (CSV, Shapefile, GeoJSON) etc and before creating new tables in ...
antonLundkvist's user avatar
3 votes
0 answers
244 views

Error Compiling GDAL with ESRI FileGeodatabase Support On Ubuntu 16.04

I am attempting to build GDAL in Docker/Ubuntu 16.04 for use in Postgis2.2/OGR_FDW on Postgres 9.6 beta3 using the travis.yml of the 2.1_gcc5.2_sanitize coverage branch as a guide -as there is oddly ...
THX1138's user avatar
  • 1,621
3 votes
0 answers
558 views

Non-zero error with ImportFromEPSG() in GDAL/OSR/Python

I'm currently getting an error when testing ImportFromEPSG() on my GDAL. import osr testSR = osr.SpatialReference() testSR.ImportFromEPSG(4326) #this returns value of 6 print testSR.ExportToPrettyWkt(...
dharmabum28's user avatar
3 votes
0 answers
530 views

Command line join attributes by location using OGR

I have two overlapping vector files (polygons and sample) and want to do a spatial join from the command line to extract all features in polygons that intersect with sample. Essentially I want to have ...
mace's user avatar
  • 707
3 votes
0 answers
328 views

No Exception Handling in GDAL/OGR java bindings: ogr.UseExceptions() has no effect

When a GDAL/OGR 2.0.1 swig/java operation encounters an error, the message is written to stderr but no exception is thrown within the application -allowing it to continue, which is highly undesirable....
THX1138's user avatar
  • 1,621
3 votes
0 answers
5k views

create image out of geojson (gdal_rasterize?)

Short version: I need to know how I can convert a .geojson-file to an according .png-file (or any other image format) long version: I have a .geojson which was created by gdal_polygonize from a .png ....
Selphiron's user avatar
  • 775
3 votes
0 answers
429 views

What is the area that OGR extracts from the (geometry) shp files for polygons?

The ESRI July 1998 technical documentation for polygon shapefiles at page 10 makes no mention of either area measures or length measures (apart from byte/record-layout matters). Yet OGR enables me to ...
Robert Denne's user avatar
3 votes
0 answers
228 views

QGIS view bounding box on Add vector layer GeoGSON protocol?

Our server can serve GeoJSON with an optional bounding box HTTP parameter. e.g. http://our_gis_server.org.au/layername?bbox=xmin,ymin,xmax,ymax In QGIS I can add this vector layer as a Protocol and ...
om_henners's user avatar
  • 15.6k
3 votes
0 answers
228 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 ...
user28189's user avatar
3 votes
0 answers
629 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 = datasource....
juliomalegria's user avatar
3 votes
0 answers
1k 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 ...
jederlacht's user avatar
3 votes
0 answers
249 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 I'...
David's user avatar
  • 183
3 votes
0 answers
388 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 ...
rikb's user avatar
  • 133
3 votes
1 answer
947 views

EPSG code lost when writing shapefile with sf

I've found that the EPSG can be recorded in the .prj file of a shapefile using the "AUTHORITY["EPSG","xxxx"] syntax. However, writing a shapefile with sf::st_write() doesn't seem to add that entry, ...
krlmlr's user avatar
  • 213
2 votes
0 answers
286 views

How to create Block References in dxf files using GDAL?

I need to use GDAL to create dxf files in AutoCAD. I have already implemented the creation of point-line geometry layers and label layers, but now the creation of Block References keeps failing. In ...
DXnima's user avatar
  • 21
2 votes
0 answers
49 views

Is any GIS processing in Python bound to be single threaded due to the GIL?

I'm processing a really complex geometry using Python and ogr, which is taking forever to compute. Looking at the CPU usage, I've noticed that it never exceeds 100% (more than 100% signals that the ...
Francesco Ghizzo's user avatar
2 votes
0 answers
752 views

How to use ogrinfo in a Python script

I've been using OGR/GDAL in its command window to obtain information regarding a vector file with this command ogrinfo -so -al d:/vector_file.shp I'm now trying to do the equivalent of this feature ...
dabba293's user avatar
2 votes
0 answers
425 views

How to query a file geodatabase using GDAL/OGR C# for records with an invalid geometry

Presently, I have a snippet of code that works well when iterating over a file geodatabase. The problem I'm currently having is that, on occasion, a geometry is supplied that is invalid, such as a ...
JJMar's user avatar
  • 41
2 votes
0 answers
824 views

Reproject vector layer with OGR and python

I want to reproject a vector Geopackage from WGS (4326) to UTM (32605) using OGR and python. However, after running the code below the feature geometry and data extent is still in degrees and not in ...
PyMapr's user avatar
  • 1,630
2 votes
0 answers
168 views

Connection pooling in OGR PostgreSQL driver

OGR (GDAL) provides a vector driver for "PostgreSQL" and data in the DB can be accessed with something like the following: driver = ogr.GetDriverByName("PostgreSQL") datasource = ...
tomfumb's user avatar
  • 3,678
2 votes
0 answers
714 views

Deleting GDAL created raster

I am simply trying to delete a TIF that I created with GDAL. I have tried, simply, to use shutil which errors with: NotADirectoryError: [WinError 267] The directory name is invalid: 'T:/p003M01p0001/...
D_C's user avatar
  • 1,359
2 votes
0 answers
37 views

SIGSEGV when loading vector file with QgsVectorLayer class, yet ogrinfo looks valid?

I have a program set up as part of a QT application written in C++ to overlay data on a KDE Marble map, and am using the C++ API from QGIS to achieve this. I create the vector file as a GeoJSON by ...
skew_t_pie's user avatar
2 votes
0 answers
188 views

Extract Geometry information from NMEA GGA sentence in SQLite database for display in QGIS via a Virtual Layer

I have a SQLite database containing a GGA sentence in one of its fields. I'd like to display this information as a POINT layer. I've looked at OGR Virtual Format solution as suggested here but I ...
YeO's user avatar
  • 609
2 votes
0 answers
44 views

Reprojecting a shapefile Error

I am trying to write a function to reproject a vector file , by taking the original shapefile as input and giving out the name of the reprojected layer . Though when I call this function I get an ...
Thedarknight's user avatar
2 votes
0 answers
369 views

Improve OGR SQL query for polygon intersection using WKT geometry

I want calculate the intersected area between a shapefile and WKT geometry. My target big layer: a.shp My query small layer: 'POLYGON((1150046 1264030, 1160100 1263793, 1160079 1260606, 1150218 ...
gonzalez.ivan90's user avatar
2 votes
0 answers
59 views

GDAL osgeo for python treating Z dimension differently

I have a space defined by a polyhedral surface, and I would like to check if a point is inside this space, and I would like to do this in python with gdal. After trying the default installation of ...
lozsarson's user avatar
2 votes
0 answers
192 views

Applying filter on the geometry for a given feature?

I have multiple layers, with multiple features, where I am interested in extracting information from a given feature within a rectangle. I am able to achieve this using the following filter, ...
Thomas's user avatar
  • 61
2 votes
1 answer
350 views

QGIS with MSSQLSpatial : no geometry. OgrInfo Corrupt data

I am having this issue while I am trying to connect to my MSSQLSpatial database. So, I've created this features with just one record with geometry. I can see this feature on Microsoft Management ...
ePascoal's user avatar
  • 951
2 votes
0 answers
401 views

ogr2ogr: filter on date-field

ogr2ogr -spat_srs EPSG:31370 -spat 179600 167350 179800 167500 -f "ESRI Shapefile" test.shp "WFS:http://ccff02.minfin.fgov.be/geoservices/arcgis/services/WMS/Cadastral_Layers/MapServer/WFSServer?" ...
user27534's user avatar
2 votes
0 answers
121 views

Importing Shapefile into PostGIS and EPSG of created table is different from Shapefile?

I'm trying to import a Shapefile into PostGIS using the ogr2ogr, but it seems that the OGR is not automatically getting the EPSG from Shapefile. My Shapefile has EPSG 4618, but the table created by ...
rmmariano's user avatar
  • 257
2 votes
0 answers
423 views

GDAL/OGR Returning wrong reprojected shapefile

I use the script in this link to reproject a shapefile and save it. The target projection is derived from a georeferenced raster. The problem is while the target coordinate system is UTM 33N (epsg: ...
Nikos's user avatar
  • 380
2 votes
0 answers
712 views

How to open memory data with ogr in rasterstats function?

I would like to reuse vector data created in memory in another function called rasterstats (source code, documentation): I have a function that creates vector data: def createPolygons: ...
Sophie Crommelinck's user avatar
2 votes
0 answers
102 views

Does WFS support what OGR calls "OLCFastSetNextByIndex"?

Background I'm working on an application that has multiple threads getting features from the same OGR layer at the same time, but with different spatial filters. This is problematic because it causes ...
Kapten-N's user avatar
  • 245
2 votes
0 answers
749 views

GDAL API: GDALPolygonize - nodata

I am attempting to polygonize a raster using GDAL C API. The input rasters can contain nodata pixels. My current method (see the code below) produces a new polygon vector, but the output also includes ...
Jot eN's user avatar
  • 972
2 votes
0 answers
1k views

Converting OSM.PBF to Geopackage in CLI?

I would like to refresh this tutorial for my purposes - background vector map in one file - just to load in QGIS. My idea is a script doing this: Import directly downloaded Openstreetmap PBF file (...
Juhele's user avatar
  • 1,738
2 votes
0 answers
1k views

How to get a shapefile DBF encoding?

I wrote a python code that is used in different countries. It process a shapefile DBF, that can be encoded in any of the local langage (or being provided by another foreign partner), or even in ascii. ...
Bruno von Paris's user avatar

1
2 3 4 5