Stack Exchange Network

Stack Exchange network consists of 175 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.

2
votes
0answers
39 views

Write 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
42 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
8 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
19 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
23 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
38 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
47 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
9 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
47 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
44 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
32 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
41 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
42 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
30 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
30 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
21 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
18 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
88 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
47 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
26 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
65 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
43 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
121 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
83 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
112 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
70 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
137 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
31 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
55 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
71 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
104 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
86 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
25 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
77 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
128 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
65 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
69 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
67 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
80 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
44 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
133 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
151 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
382 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....
2
votes
1answer
168 views

How to style KML through LIBKML layer creation options?

I am exporting a layer from PostgreSQL to KML using ogr2ogr. I get a workable KML with a series of features (Placemarks). Here is a simplified example of a feature. (I took out the long list of ...
0
votes
1answer
185 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
76 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
37 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
22 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
67 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
60 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 ...