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
-1
votes
0answers
18 views

Is there a better way to iterate through rows with a function than .apply?

I have created a geodataframe for a feature class on centroid points and need to transform the POINT geometry to a new crs. I wrote a gdal/ogr based function (this function is being used instead of ...
0
votes
1answer
38 views

Loading color table (.csv) file to interpret raster data using C#?

I have a raster (GeoTIFF .tif file) that is stored in three bands (Red, Green, Blue), with each band's data type as a byte. I have a separate color table in the form of a .csv file, that stores a ...
0
votes
0answers
21 views

Clip two shapefiles in Python using only OGR results in error Segmentation fault (core dumped)

Is it possible to clip two polygon shapefiles using only the ogr library? It has to be a native Python solution, so subprocess.call(['ogr2ogr', '-clipsrc', ...] ) is not what I'm looking for. ...
1
vote
0answers
27 views

How can I easily determine the precision of an OGR geometry?

I'm writing a python tool to update some river catchment boundaries and keep running into geometry errors, such as WARNING: TopologyException: Input geom 1 is invalid: Self-intersection at or near ...
0
votes
1answer
13 views

OGR Merge split part of basename

ogrmerge.py -single -o merged3.shp *.shp -src_layer_field_content {DS_BASENAME} let's me painless merge several shapefiles into one and adds a new field with the basename of the shapefile. Is it ...
0
votes
1answer
31 views

Getting string attribute from a shapefile with GDAL Feature.GetFieldAsString(name) returns incomplete value

I read a shapefile (zipped) with GDAL library in C#. Shapefile contains .cpg file with "UTF-8" encoding specified. When I call Feature.GetFieldAsString(attributeName) some of the attribute values get ...
0
votes
0answers
34 views

Error while performing an intersection of a point and a multipolygon

I'm willing to build a tiny service that given a point location, it searches within a multipolygon, which polygon object it is intersecting. My current development is defined as this: from osgeo ...
2
votes
0answers
21 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 ...
3
votes
1answer
54 views

Accessing OGR driver options using OGR/GDAL in Python?

Using OGR in Python, I am attempting to modify the driver settings for S57. I am able to read the meta data from the driver as follows: import ogr driver = ogr.GetDriverByName("S57") driver....
2
votes
0answers
60 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, ...
3
votes
1answer
40 views

Find duplicate point geometries in a shapefile [closed]

How to find a duplicate point geometries in point shapefile (around one lakh geometries) using Python OGR/GDAL
2
votes
1answer
51 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
25 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 ...
3
votes
1answer
168 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
58 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
75 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
46 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
1answer
44 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
27 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
63 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
42 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
31 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
26 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
102 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
32 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
32 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
38 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
30 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
27 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
121 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
87 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
84 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
84 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
139 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
142 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
74 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
28 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
56 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
88 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 ...
1
vote
1answer
108 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
97 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
19 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
52 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
54 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
62 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
156 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
147 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
81 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
130 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
73 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 -...