Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ogr]

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

1
vote
0answers
16 views

How to break when a GDAL/OGR warning is generated?

I am debugging C++ code under Linux (CentOS) that, after many many iterations, gives an OGR warning:"Warning Run Time Elapsed: 0000:27:40.43 for [myfilename].dbf. Going on, but might cause ...
1
vote
1answer
11 views

Add FID to attribute table using ogrinfo

I want to add the fid to the attribute table using ogrinfo in OSGeo4W Shell. Here is my code: ogrinfo layer.shp -sql "ALTER TABLE layer ADD COLUMN ID integer" ogrinfo layer.shp -dialect SQLite -...
0
votes
1answer
16 views

How could a GeoJSON look that OGR recognizes more than one layer?

I load a GeoJSON with OGR and apply the method GetLayerCount(). How must the GeoJSON look like that GetLayerCount() > 1? driver = ogr.GetDriverByName("GeoJSON") dataset = driver.Open(my.geojson, 0) # ...
2
votes
1answer
76 views

Can't delete features from TAB layer table in QGIS if no geometry

I have some layers containing DAT,MAP and TAB files, when I loaded these layers into QGIS some layers have check boxes before layer name and some layers won't like showing in below image. In the ...
1
vote
0answers
29 views

Convert an OGR File to a Raster

i tried out this recipe from the GDAL/OGR cookbook: from osgeo import gdal, ogr # Define pixel_size and NoData value of new raster pixel_size = 25 NoData_value = -9999 # Filename of input OGR file ...
0
votes
1answer
19 views

How to free the memory of return value of OGRGeometry::Buffer()?

I have in C++ (gdal 2.3.2) OGRPolygon poly; OGRGeometry* geom = poly.Buffer(1e-12, 1); now how do I free the memory allocated for geom after done using it?
0
votes
0answers
34 views

Merge two shapefiles into one new shapefile with OGR/GDAL library in C#?

I am currently coding a C#/WPF application that lets you choose two shapefiles and create a new merged one, with the content of both shapefiles. My problem is that I am quite new (1 month with gis) ...
2
votes
1answer
28 views

How to export a unique ID field of a geopackage

When I am converting my geopackage file in shapefile, the unique ID field is not exported. I could duplicate it before exportation, but I wanted to know if it could be done in one step, in order not ...
0
votes
1answer
73 views

Converting self-intersecting polygons into distinct polygons

How to convert self-intersecting polygons into distinctive, well behaving polygons? My polygon inputs consist of self-intersecting polygons, which fails the st_isvalid test, ie: the below statement ...
0
votes
0answers
29 views

OGR Python: Copying features from one datasource to another works with shapefile but not with geopackage

I have a shp/dbf EPSG4674 input datasource, and I want to copy features from one layer of this input datasource, create a new output datasource and write these features to that output datasource. As ...
0
votes
1answer
38 views

Getting OGR to work on a Mac

I downloaded GDAL on my Mac (running Mojave 10.14.1) through Homebrew and I'm having trouble getting OGR to work with Postgresql. When I try the following to create a geojson from gpx files I have, I ...
0
votes
1answer
47 views

How can I write a zipped shapefile with ogr2ogr and /vsizip/?

After reading a bit of GDAL Virtual File Systems docs, I am trying to write a zipped Shapefile using this gdal command involving the use of /vsizip/: ogr2ogr -f "ESRI Shapefile" /vsizip/test.zip\test....
0
votes
2answers
82 views

QGIS SERVER - convert WFS GetFeature GML as Shapefile with ogr2ogr

I'd like to use ogr2ogr with the WFS driver to convert the GML response of my QGIS Server 3.4.2 GetFeature layer into Shapefile. I have to do this from a WebGIS JavaScript application I am developing, ...
1
vote
1answer
18 views

Keep only one geometry type when clipping polygons to sqlite with ogr2ogr

I have a regular grid of polygons and want to clip them using ogr2ogr. While using sqlite files as destination I stumbled over some wierd behavior: When clipping polygons exactly at their borders, a ...
2
votes
1answer
46 views

Can't open specific layers with Qgis nor OGR

I'm working with mutliple sets of layers in order to create a new one. As I need to load them directly from the internet, I use both /vsizip/ and /vsicurl/ But I'm stuck at loading one of them. Here ...
0
votes
1answer
33 views

ogr2ogr polygon to point with point inside the polygon

Can ogr2ogr be used to convert a polygon to a point but the point must remain inside the polygon? It does not matter where the point is as long as it is inside the object polygon.
0
votes
0answers
31 views

Combine GeoJSON files into bigger shapes with external JSON to merge on

I have a shapefile of New York ZCTAs here I also have these neighborhood definitions that map zip codes to New York City Boroughs. I'd like to take my "all of New York zip code" data and: Clump up ...
1
vote
0answers
42 views

OGR SetAttributeFilter does not let datasource to update

I am trying to update an attribute value for a certain feature in a shapefile. To filter out that feature, I use SetAttributeFilter. This returns the feature I want, and SetFeature also works as ...
1
vote
0answers
19 views

Which polygons intersect rectangle in PHP/Linux GDAL?

I'm developing a website where I want to test which polygons from a shapefile intersect a given rectangle. Using PHP, I thought about using exec() function, calling a GDAL program, like ogrinfo. ...
1
vote
1answer
61 views

QGIS cannot save to SpatiaLite after vector difference?

In QGIS I have a spatialite DB full of roads. I'd like to do a Difference operation (Vector > Geometry Tools > Difference) with another layer in order to keep roads only available in a given ...
0
votes
1answer
68 views

Get a bounding box of a geometry that crosses the antimeridian using OGR

I'm trying to get a bounding box of the geometry that crosses the antimeridian using OGR: from osgeo import ogr geom = ogr.CreateGeometryFromJson('{"type":"MultiPolygon","coordinates":[[[[-180.0,-40....
1
vote
1answer
40 views

C++ OGR GDAL Set spatial reference of new layer

When creating a new layer using OGR / GDAL in C++, how do i set the spatial reference? OGRLayer *poLayer2; poLayer2 = poDS2->CreateLayer( "layerName", NULL, wkbPoint, NULL ); if( poLayer2 == NULL ...
4
votes
1answer
34 views

Get a list of all supported EPSG code from OGR

I need get a a list of all supported EPSG code from OGR/GDAL. I need this becaouse i'm developing a C++ application map, and I need this information to put it in a user form. I read the OGR ...
1
vote
1answer
48 views

Get path of feature classes in feature datasets without arcpy

I'm looking for a way to get the full path of a feature class within feature datasets (either in personal or file geodatabases) without using arcpy. My first attempt was to use ogr which works fine ...
0
votes
1answer
54 views

GDAL/BUILD can't get result files Geojson to mbtiles

i try to 2.55gb of GeoJson (maybe 200 over layers in one file) to vector Mbtiles, but fail to create .mbtiles. so i try convert each layers(.shp) to geojson(over 200 files), then create each ....
0
votes
0answers
38 views

Can any suggest an open source workflow to convert an Esri LiDAR terrain dataset to a LAS file

I’ve got a very large file geodatabase (1TB) that contains LiDAR data stored as a multiple terrain datasets. I’d like to spatially filter the data and export the result as a LAS file without using ...
1
vote
0answers
87 views

Can't set OGR layer geometry type in Python

I'm trying to create a layer of geometry type polygon, with a feature of geometry type polygon, and a geometry of type polygon. However, no matter how I attempt to set the geom type of the feature, ...
0
votes
1answer
105 views

gdal/geopandas data object compatibility in python

Is it possible to convert an ogr datasource into a geopandas GeoDataFrame without writing the datasource first as a physical file and reading it back? I am referring to something like import ogr, ...
1
vote
1answer
302 views

Where is official documentation of gdal/ogr?

Where can I find the official docs for gdal/ogr python API? I am looking for something comprehensive which shows all the classes with descriptions of their attributes, methods and input/output types....
0
votes
1answer
88 views

OGR multipolygon with holes model

I'm trying to unpack shapefiles in C# using GDAL-OGR library, but I'm confused about the structure of multipolygon with holes in OGR. As far as I know, the models of shapefiles and OGR geometry (the ...
1
vote
1answer
50 views

Python OGR: Filter Shapefiles by Lat Long and Export To CSV

Using osgeo's Python API for OGR, I'd like to implement the following process: Import ESRI Shapefiles from a given directory (call it input_dir) Import a CSV file that contains lat-longs of interest (...
0
votes
0answers
30 views

OGR SQL Intersect layer slow to iterate

I am having an issue with OGR's ExecuteSQL, but not with the actual SQL query. What I am intending to do is to take a large number of polygons ~500k and find out if they intersect with a ...
0
votes
0answers
20 views

Intersecting files with different projections

I am attempting to calculate the intersection of two files(vectors/shapefiles) that have different projections but would in real life have actual overlap. I am attempting to do this using the ogr ...
1
vote
2answers
50 views

.Length() method from ogr is crashing python

I created a simple 1-feature polyline shapefile in QGIS 2.18. I would like to now read this shapefile in gdal using python and extract its length. I have done the following import ogr driver = ogr....
0
votes
0answers
43 views

How get attributes from GeoJSON

How can i get only attributes names from GeoJSON? ogrinfo gets attributes with others info: ogrinfo -al -so rw.geojson Output is: ERROR 4: GeoJSON Driver doesn't support update. Had to open ...
0
votes
0answers
195 views

GDAL/ogr2ogr ( to convert osm to shapefile)

I use GDAL / ogr2ogr to convert osm to shapefile but I get an error. C:\Users\alo>ogr2ogr -f "ESRI Shapefile" outputdir "C:\Users\alo\Desktop\London.osm" Warning 1: Cannot find osmconf.ini ...
1
vote
0answers
75 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?" ...
3
votes
1answer
141 views

Create Hexbin (honeycomb) grid using command line or Python

Qgis has this amazing Create Grid function. Is there an alternative for python / unix command line? I've found Gdal_grid but it is not the same. The goal is to eventually create a hexbin heatmap.
0
votes
0answers
19 views

geodjango ogrinspect on geojson layer returns all field lengths to zero

I have a geojson layer which I am running python3 manage.py ogrinspect reporter/data/parcels.geojson parcels --srid=4326 --mapping --multi which returns from django.contrib.gis.db import models ...
0
votes
0answers
31 views

Convert total area calculation from ogrinfo (cli) to python ogr

How can I do this command (source): ogrinfo -q -sql "SELECT SUM(OGR_GEOM_AREA) AS TOTAL_AREA FROM way" way.geojson with Python ogr? from osgeo import ogr
0
votes
0answers
26 views

How to use our polygon intersect on all rows on 2 dataframes

If I have to intersect all rows of one dataframe geom column with another dataframe geom column without using for loop, how can I do that? geom1 = ogr.CreateGeometryFromWkt(df['geom_value'][0]) ...
0
votes
2answers
122 views

OGR says that my data source is invalid when I use the method QgsVectorLayer in PyQGIS

I am begining with PyQGIS and QGIS in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code : def activatePlugin (self): ...
0
votes
0answers
69 views

gdal: apply orthorectification to ogr dataset

I'm trying to process Digital Globe L2A image with gdal utilities (e. g. this one: https://www.digitalglobe.com/resources/product-samples/washington-dc-usa) I am using SRTM digital elevation model to ...
1
vote
0answers
39 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....
0
votes
0answers
73 views

ogr2ogr: Transformation from NAD27 to WGS84 not working

I'm trying to use ogr2ogr to transform from NAD27 to WGS84 and check the precision afterwards. For that, I used a GML file with coordinates -124.0, 48.0 It looks like this: { "type": "...
1
vote
0answers
30 views

Avoiding grids when transforming between SRS using ogr2ogr?

I'm trying to use ogr2ogr to transform from NAD27 (EPSG:4267) to WGS84 with my custom "towgs84" Bursa-Wolf parameters. However, I think the ogr2ogr uses grids which are part of the GDAL installation ...
6
votes
2answers
822 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 ...
3
votes
1answer
61 views

How to call geom.Polygonize() with OGR?

The Python documentation for OGR lists a Polygonize() method belonging to the Geometry class, as does the C documentation. The docstring suggests it can be called on a geometry object of type "...
0
votes
1answer
39 views

Problem reading shapefile with Python ogr-module

Trying to read naturalearthdatas shapefile vers. 4 "ne_110m_admin_0_countries.shp" with the python-ogr.modul I encounter a problem. inspecting the file with the following code-snippet: counter = 0 ...
1
vote
1answer
55 views

How to specify transformation method when using ogr2ogr to reproject geometry?

I have a question regarding geometry transformation using OGR/GDAL (or perhaps another open-source solution). Let's say I need to transform geometry from one coordinate system to another using ...