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
3
votes
1answer
34 views

Find duplicate point geometries in a shapefile [on hold]

How to find a duplicate point geometries in point shapefile (around one lakh geometries) using Python OGR/GDAL
2
votes
1answer
41 views

Making polygon shapefile from unsorted point shapefile?

I have a point Shapefile with unsorted feature ID's (FID). I want to convert the same point file into polygon Shapefile by using python gdal/ogr. I got the help from link1 and link2. I'm able to make ...
1
vote
1answer
19 views

Cast 3D geometry as 2D for ogr2ogr GeoJSON

I'm trying to take a shapefile that can be downloaded here (specifically the shapefile titled PVS_19_v1_vtd_21031.shp), convert it from EPSG:4269 to EPSG:3857, and output the GeoJSON into CSV with ...
2
votes
1answer
52 views

How to rasterize individual feature (polygon) from shapefile using GDAL/OGR in Python?

I would like to convert the individual records (polygons/features) of a shapefile to raster using GDAL/OGR. Here is the example shape and the mask raster. Rasterizing the full layer with all records (...
1
vote
1answer
37 views

Extract data from osm.pbf with GDAL

I tried osmosis, osm2pgsql, osmfilter, and probably most of OSM related tools in order to extract polygon rivers and water bodies. Among the tools, OGR is intuitive and returns good results so far ...
1
vote
1answer
45 views

Cannot access LibKML driver using OGR in Python

I am trying to read a kmz file using OGR in Python. I believe the standard driver for reading .kmz files is LibKML (Can ogr2ogr read .kmz files? How?), but I am only getting None when I am building ...
2
votes
1answer
42 views

Unclosed linestring to polygon works with QGIS but not with PostGIS

Just like the title, I am extracting OSM riverbank and a lot of riverbanks in OSM is in 'unclosed' linestring. This is the original river shape i extracted from OSM In order to polygonize the ...
2
votes
0answers
31 views

GDAL Warp Memory Datasource as Cutline

I am attempting to use a memory vector to crop a raster using GDAL warp but I get the following error: ERROR 1: Cannot open <osgeo.ogr.DataSource; proxy of <Swig Object of type '...
0
votes
0answers
25 views

Possible to import current version (v2) of the SQL Server Spatial binary format with QGIS/GDAL?

I'm running QGIS 3.4.3 on a Windows 10 machine and when loading vector layers from our MS SQL Server version 12 everything seems to be working great. No problems connecting or visualizing the data. ...
2
votes
1answer
50 views

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

I am trying to change the field value of a shapefile, but only in some specific features. However the code I have changes the value for all features in the shapefile. Is there any way of accessing the ...
1
vote
1answer
29 views

Finding GDAL Build Format List?

I am building GDAL from source to limit the list of supported drivers however I cannot find a definitive list of formats and their appropriate shorthand names to use in my ./configure list to set them ...
2
votes
1answer
26 views

ogr2ogr cannot append of truncate PostGIS table

I am reading in GML data to a specified PostGIS schema. This is part of an automated job so and the db table might include views so I don't want to drop the table each time the script is run. EDIT: ...
0
votes
0answers
21 views

Error with Datetime fields when loading Tab file to SQL Server using OGR2OGR

I have a MapInfo Tab file that needs to be loaded to a MSSQL Server DDBB in a scheduled basis and I want to use OGR for this task. The tab is going to be appended in an existing DDBB table that has ...
2
votes
2answers
68 views

OGR: Load layer with sql statement and write to new data set

I am having difficulties after loading a shapefile with a sql statement with ogr. The layer and its features seem to be correctly loaded. Still I am not able to write them into a new shapefile or pass ...
1
vote
0answers
31 views

Select features of a shape which are not in another shape

I have a shape with some features (let's say 100) and a second shape with some of this features (50) buffered (5 meters inside buffer). I want to select and write in a new shape every feature of the ...
0
votes
0answers
30 views

Export OGR feature style data from QGIS for use in GeoPDF

I have a fully formated map in QGIS from which I wish to make a GeoPDF. I followed this and this tutorial and generated a simple version of my map without much problems. I am however looking for an ...
2
votes
1answer
30 views

GDAL SQLite geometry error

I am having the following issue writing points to a SQLite file using ogr with SPATIALITE enabed: ERROR 1: Cannot insert feature with geometry of type POINTZ in column GEOMETRY. Type POINT expected ...
0
votes
1answer
26 views

gdal FlattenTo2D makes geom null

I have a df that has geoms as ogr geom in 3D. I was trying to convert to 2D but it empties out the geom. ipdb> df['default_geom'][0] <osgeo.ogr.Geometry; proxy of <Swig Object of ...
0
votes
0answers
25 views

What is the geom_type at CreateLayer() in ogr for xyz-GeoJSON?

My GeoJSON-File is a Multipolygon which creates several triangles with a X, Y and Z coordinate. Z determines the height of the specified point for X/Y. If i try to render my GeoJSON into a shapefile ...
1
vote
1answer
75 views

OGR SetAttributeFilter with multiple fields?

I am trying to open a layer using OGR in Python and filter the features using SetAttributeFilter() where two fields are greater than zero. from osgeo import ogr driver = ogr.GetDriverByName('ESRI ...
0
votes
2answers
75 views

How to extract FileGDB's domains without ArcGIS?

I'm trying to get an ESRI File Geodatabase domains by using the GDAL\OGR library. By doing so, I wish to edit this datasource using QGIS' Attributes Form with designated value map widgets that point ...
0
votes
0answers
59 views

GDAL OGR Polygon.Contains(Point) returns false but point is contained in QGIS map

I'm sure I must be missing something here but for the life of me I can't see what it might be. I have been struggling for the last hour with an issue with the Contains() method in OGR. I am iterating ...
0
votes
1answer
66 views

Cascading union OGR Multipolygons?

I have 2 OGR Multipolygons that intersect, hence I want to cascade Union them. I tried this but it returns me empty and doesn't union it. Seems this works only on Polygons and not Mul;tipolygons. What'...
1
vote
1answer
118 views

Drawing graticule with GDAL/OGR?

I'm trying to generate a graticule with user-defined range of latitude, longitude, and interval; however, my code only displays one line of latitude and one line of longitude when loading it in QGIS. ...
2
votes
0answers
105 views

Writing selected features to shapefile using OGR and Python?

I have two shapefiles that intersect: one containing a line, and the other containing polygons. I'm trying to use OGR and Python to create a buffer around the line and select polygons within it, then ...
0
votes
1answer
65 views

Clip shapefile based on another shapefile [closed]

I have two shapefiles with me, one big and one small. I want to clip part of big shapefile where the small shapefile is located. I tried QGIS vector intersect by geometry, but that is returning me ...
0
votes
0answers
24 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 ...
0
votes
1answer
48 views

How to convert an ASCII file (with lat,lon coordinates) to a shapefile using OGR?

I have an ASCII file with the following columns : ID, longitude, latitude, value Is it possible to use OGR (ogr2ogr or ogrinfo) in command line in order to open the ASCII file and convert it to a ...
1
vote
1answer
52 views

Find layer name of sp object

After making some changes to an sp object I want to save it as a shapefile using writeOGR()so that I don't have to repeat the cleaning every time. I haven't found a way to identify the layer name of ...
0
votes
1answer
80 views

“OGR: not enough data error” when using st_transform in R

I'm trying to use st_transform (from the R package sf) on a sf object and am getting the following error when projecting from WGS 1984 to Albers Equal Area: > sf_obj_prj <- sf_obj %>% ...
0
votes
3answers
79 views

ogr2ogr CSV conversion with two points into column names

I have a CSV with ":" in all column names. I am trying to convert it with ogr2ogr to another format. I don't need all fields example for formating: #0:imgID,1:camSN,2:lat,3:lon,...,57:fields ...
0
votes
0answers
15 views

QgsVectorLayer, configuring ogr uri for a shapefile (to set field datatypes)

I'd like to load a .shp and set the data type of one of the fields. I thought something like this would work: uri = 'C:/myfile.shp?field=myfield:integer' vlay = QgsVectorLayer(uri ,'some_name','ogr')...
2
votes
1answer
50 views

When is it worthwhile to reproject in QGIS? [closed]

My QGIS project has various raster and (complex) vector layers from different sources, in different CRSes. Using reprojection on the fly, I don't have to reproject them. But should I, especially for ...
0
votes
2answers
50 views

How to efficiently extract specific metadata for many shapefiles?

I have a directory with 50 subdirectories containing a total of 300 shapefiles which I would like to query for their feature count and output to a text file. Thus far I am able to get the feature ...
2
votes
0answers
54 views

QGIS parsing layer source

I periodically need to refresh my QGIS map based on changed underlying data sources (currently locally-saved KML, GPKG, but trying to be general) using PyQGIS. Following Make a Qgis layer update from ...
0
votes
0answers
119 views

Alter and update a shapefile with a field from an ASCII file using ogr

I have a vector file "map.shp" with a field ID. I have an attribute table (data.txt) with the following fields: ID, value1, value2. The field ID is the same in both files. I want to update map.shp by ...
2
votes
1answer
110 views

Populating new field in shapefile with values from list?

I'm looking to populate a newly created field in a shapefile that from a list using basic python and osgeo tools. The values are integers and in a python list that is the length of the number of ...
1
vote
1answer
67 views

Getting Field by name from feature using GDAL?

I have recently started using GDAL in C#, I want to get a value from a field of a feature using the name of that field. In the docs here it says that the operator [char*] is supported, however it's ...
0
votes
1answer
80 views

How to specify GPKG Driver in GDAL/OGR under C++?

Working under CentOS (Linux), we have run up against the 4GB shapefile (dbf) limitation in our Monte Carlo model. We've decided to switch to GeoPackage to output our point attributes. I cannot find a ...
1
vote
1answer
48 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
20 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
100 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
1answer
74 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
35 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
155 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) ...
3
votes
1answer
66 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
251 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
174 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
318 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
124 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....