Questions tagged [ogrinfo]

ogrinfo is a program in the suite of GDAL tools. ogrinfo provides information about an OGR supported data format (traditionally vector format types).

Filter by
Sorted by
Tagged with
0 votes
1 answer
37 views

How do I set the result of a SELECT query equal to a new column in a GPKG file using ogrinfo?

This thread: How do I add a new column to a GPKG file using ogrinfo? explains how to add a new column to a GPKG file and set all rows in it to a specific constant value. Here, I would like to add a ...
zabop's user avatar
  • 1,810
1 vote
1 answer
34 views

How do I use the ogrinfo's -json option to return the result of the SQL query?

I crate an example GPKG, example.gpkg: import geopandas as gpd import shapely.geometry gdf = gpd.GeoDataFrame.from_dict(dict( geometry=[shapely.geometry.Point([0, 0]), ...
zabop's user avatar
  • 1,810
1 vote
1 answer
103 views

How do I add a new column to a GPKG file using ogrinfo?

I create an example file, example.gpkg using Python: import geopandas as gpd import shapely.geometry gdf = gpd.GeoDataFrame.from_dict(dict( geometry=[shapely.geometry.Point([0, 0]), shapely....
zabop's user avatar
  • 1,810
2 votes
1 answer
146 views

Fast selection of intersecting geometries in GPKG file

I have a GPKG file, example.gpkg, with 2 layers, base and circles. There is only 1 geometry in base, and there is a large number of geometries in circles. I would like to select all the geometries in ...
zabop's user avatar
  • 1,810
4 votes
2 answers
157 views

How do I view the contents of spatial indexes of a GPKG file?

I create an example GPKG file, example.gpkg, with layer our_layer: import geopandas as gpd import shapely.geometry gpd.GeoSeries( [ shapely.geometry.Polygon([[0, 0], [1, 0], [1, 1]]), ...
zabop's user avatar
  • 1,810
7 votes
2 answers
331 views

Fast subtraction of geometries in GPKG file

I have a GPKG file, with 2 layers, p and q. I would like to create a third layer, r. I would like r to contain those parts of p which do not intersect with q. We could phrase this as r=p-q. Below is a ...
zabop's user avatar
  • 1,810
1 vote
2 answers
160 views

How to extract information from a shapefile with the command ogrinfo in a machine readable way

I am looking for information like the SRID/CRS for a shapefile in an automated way. I know that by using ogrinfo path/to/xxx-filename.shp yyy-layer -so I can see some output with indentation left to ...
TPPZ's user avatar
  • 407
1 vote
1 answer
282 views

Use ogr2ogr/ogrinfo to connect to MSSQL on Ubuntu Server

OS: Ubuntu Server 20.04; Software: GDAL/QGIS, ogr2ogr/ogrinfo My goal is to use ogr to pull data from MSSQL as part of a longer process that I'm working on. First step is to test out the connection ...
MidPiedmont's user avatar
1 vote
1 answer
228 views

How to get feature count of a GeoJSON into a bash variable?

I would like to have the number of features in a GeoJSON loaded into a bash variable. An example GeoJSON, example.geojson: { "type": "FeatureCollection", "features": [ { &...
zabop's user avatar
  • 1,810
2 votes
0 answers
296 views

How to download all parcel boundaries of North Rhine-Westphalia?

Context I'd like to download North Rhine-Westphalia's cadastre parcels as GeoJSON. Their website provides a WFS URL: https://www.wfs.nrw.de/geobasis/wfs_nw_inspire-flurstuecke_alkis?REQUEST=...
zabop's user avatar
  • 1,810
1 vote
1 answer
163 views

ogrinfo doesn't respond while exporting to MSSQL with ogr2ogr

I am trying to export data from postgres to MSSQL. While ogr2ogr -nln outputLayerName -f "MSSQLSpatial" "MSSQL_conn_string" --config MSSQLSPATIAL_USE_GEOMETRY_COLUMNS NO "...
Goran's user avatar
  • 385
1 vote
0 answers
60 views

Find best cell size to use for rasterization from a shapefile

I've been using GDAL/OGR so far to gather information about my shapefile ogrinfo -so c:/shapefile.shp Using information such as the extents, I can incorporate this into my next command of gdal_grid ...
fuzzy_raster9873's user avatar
0 votes
0 answers
34 views

Using ogrinfo in Python to find specified information [duplicate]

I am using ogrinfo in Python to find out information about a shapefile from subprocess import Popen, PIPE args = ['ogrinfo', '-so', '-al', 'C:/test/test_shapefile.shp'] process = Popen(args, stdout=...
fuzzy_raster9873's user avatar
2 votes
1 answer
1k views

ogrinfo - specify what information you want returned

I am using ogrinfo to find out information about a shapefile ogrinfo -so -al 'C:/test/test_shapefile.shp' This obviously gives me a large summary, but I'm wondering is there any way to specify that I ...
fuzzy_raster9873's user avatar
1 vote
1 answer
792 views

Docker ogr2ogr & ogrinfo .shp shapefile "Unable to open datasource"

I am using current gdal docker image osgeo/gdal:ubuntu-full-3.4.1 to display metadata from a shapefile. After multiple failed attempts of failed installation of GDAL 3.4 on Ubuntu 20.10 I am now using ...
nonNumericalFloat's user avatar
1 vote
0 answers
138 views

ogrinfo filter invalid geometries

I have shapefile and I want to filter all invalid geometries. ogrinfo -q /workspace/INVALID/0.shp -sql "SELECT * FROM \"0\"" -fid 1749 Layer name: 0 OGRFeature(0):1749 Target (...
Roman Alekseiev's user avatar
0 votes
1 answer
438 views

Getting all Datasets and/or Feature classes and consequently spatial data from Esri Structures in MS SQL

I'm looking for query Esri data on MS SQL Server (best by using pure SQL). So far I'm using ArcPy from Esri Python toolset but that is far from being optimal. Example of iterating through the entire ...
Pepik's user avatar
  • 162
1 vote
1 answer
203 views

PyQGIS: Prompt ogr2ogr error in the log window of the processing tool

I have a processing tool that helps users to export data from PostGIS tables to GPKG. I am using ogr2ogr commands to achieve the tasks. I am calling the commands via subprocess. However, I cannot ...
Nil's user avatar
  • 1,457
3 votes
1 answer
493 views

How to batch rename tables in GeoPackage with OGR

I would like to rename all tables in a GeoPackage file. The "translations" are stored in a .csv file. I would like to do this on the command line and found the below thread that uses the ...
Aron's user avatar
  • 153
0 votes
2 answers
89 views

One-liner to print first feature from GPKG

To make the findings from this GDAL issue more discoverable, I'm posting here as well. ogr2ogr has a -limit option. I couldn't find this option for ogrinfo, while ogrinfo has e.g. -where. I would ...
StefanBrand_EOX's user avatar
0 votes
1 answer
102 views

One-liner to print first feature from GeoJSON

To make the findings from this GDAL issue more discoverable, I'm posting here as well. ogr2ogr has a -limit option. I couldn't find this option for ogrinfo, while ogrinfo has e.g. -where. I would ...
StefanBrand_EOX's user avatar
1 vote
1 answer
333 views

ogrinfo st_area for geopackage returns invalid target SRID

I want to use ogrinfo to get areas from a lat-long (EPSG:4326) layer right on the terminal shell, I'm using the query: ogrinfo -dialect sqlite -sql "select st_area(st_transform(geom, 32615)) from ...
Elio Diaz's user avatar
  • 3,456
2 votes
1 answer
856 views

ogr2ogr cannot import .osm.pbf file to PostGIS

I'm trying to import a multipolygon layer from "colorado-latest.osm.pbf" into PostGIS. GDAL 2.4.2 has been installed in a Ubuntu system. However, whenever I'm trying to import the osm.pbf file, I get ...
Nilabja Ghosh Chowdhury's user avatar
1 vote
1 answer
3k views

Create and use index with GDAL/ogr on shapefile

I'm using OGR and VRT to create a new shapefile from two distinct sources (CSV file and shapefile). It works well, but it is very slow. I want to make it more efficient, so I tried indexing my data ...
simo's user avatar
  • 8,580
3 votes
1 answer
2k views

Converting DXF to ESRI Shapefile using ogr2ogr

I like to convert this DXF file to ESRI Shapefiles. I tried the following command: ogr2ogr -f "ESRI Shapefile" test.shp Umweltzone-Neu-Ulm.dxf ... which output the following warnings ...
JJD's user avatar
  • 1,511
6 votes
1 answer
1k views

Adding file info using ogrinfo -sql UPDATE expression

I try to add the filename with the tool ogrinfo in a bunch of shape files for later merging reasons under Debian 8 and gdal 2.4.0. I stuck by expressing a valid statement for UPDATE part. For the ...
huckfinn's user avatar
  • 3,538
8 votes
1 answer
428 views

QGIS and Mapinfo reporting different projections for some files

When I open a tab file that's been generated in QGIS using EPSG 28355 (MGA 94, z55s) using QGIS 3.10 the projection is transformed to 5551 But when I open it in Mapinfo v17 it's correctly reported as ...
GeorgeC's user avatar
  • 8,196
1 vote
0 answers
37 views

How to get feature class name using ogrinfo

I am importing kmz into postgres $ogrCommand = 'ogr2ogr -f "PostgreSQL" -a_srs "EPSG:4326" PG:"host='.env("DB_HOST").' port='.env("DB_PORT").' user='.env("DB_USERNAME").' dbname='.env("DB_DATABASE")...
Awais Khan's user avatar
0 votes
1 answer
693 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 ...
nat's user avatar
  • 289
1 vote
2 answers
253 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 ...
mbela's user avatar
  • 127
0 votes
0 answers
478 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 ...
Nat's user avatar
  • 219
3 votes
2 answers
287 views

ST_Area(geometry) with ogrinfo estimates a stable area per grid cell

I use ST_area(geometry) in order to calculate the area of each grid cell of a vector grid with LCC projection and 6x6km2 resolution. The CRS of the vector is: +proj=lcc +lat_1=45 +lat_2=22 +lat_0=38.7 ...
Nat's user avatar
  • 219
3 votes
1 answer
990 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 -...
Helga F.'s user avatar
  • 365
8 votes
4 answers
5k views

ogr2ogr sql: what is the name of the geometry field?

I have the following ogrinfo -so output about a shapefile: Layer name: PREDEFINED Geometry: Polygon Feature Count: 58075 Extent: (425995.430000, 336399.500000) - (447356.663000, 359782.760000) Layer ...
Richard's user avatar
  • 3,291
1 vote
1 answer
2k views

ogrinfo says "Unable to open datasource" with KML?

I have a KMl file that will open fine in QGIS, but when I try to use ogrinfo I get: $ ogrinfo -so "myfile.kml" FAILURE: Unable to open datasource `myfile.kml' with the following drivers. -> ...
Richard's user avatar
  • 3,291
2 votes
0 answers
409 views

ogrinfo: Unable to use sqlite dialect with -oo GEOM_POSSIBLE_NAMES open option

I am having problems using the SQLite SQL dialect to read a CSV file using ogrinfo, but only if I also specify a geometry column using the -oo GEOM_POSSIBLE_NAMES open option. Suppose file test.csv ...
nw31304's user avatar
  • 21
4 votes
1 answer
98 views

Why won't ogrinfo write to new column using informaiton from previous columns?

I'm having problems classifying an area of mixed forest using ogrinfo. I have an .sqlite file which contains the three columns; proportionclass1. proportionclass2, proportionclass3. I'm trying to ...
Walshe_d's user avatar
  • 729
2 votes
1 answer
2k views

How to List Fields of a Featureclass in a FileGDB using ogrinfo

I have an ArcGIS File Geodatabase, and I know that there is a featureclass within it. If I type: ogrinfo myfilegdb.gdb it lists the featureclasses within it. I now want to just find out what are the ...
Devdatta Tengshe's user avatar
1 vote
1 answer
4k views

How to install older GDAL v1.11 on Ubuntu 16.04 instead of v2.1.3

I have another question going on this forum regarding GDAL 2.1 ogrinfo not working at Trying to get GDAL 2.x to work, but ogrinfo reports ERROR 3: and ERROR 4: and "Failed to open table res_t48....
Tom Haws's user avatar
1 vote
0 answers
349 views

Trying to get GDAL 2.x to work, but ogrinfo reports ERROR 3: and ERROR 4: and "Failed to open table res_t48.PAT"

We have been using GDAL 1.9 for years on a Ubuntu 12.04 machine, but are trying to upgrade to Ubuntu 16.04 with the latest PostGIS and GDAL. When I install gdal-bin I end up with version 2.1.3. But ...
Tom Haws's user avatar
1 vote
2 answers
1k views

Remove Duplicate Records IDENT field -Shapefile using GDAL OGRINFO or OGR2OGR

I have two shapefiles that I am merging/combining. However, this produces more than 4,000 duplicate records. I need to have only unique records. Is this possible with OGRINFO or OGR2OGR? I've ...
Geospatial Engineer's user avatar
4 votes
2 answers
177 views

Reading various (non-.shp) vector types using ogrinfo

I am using the OSGeo4W shell to call ogrinfo on a directory (geodata) to see what vector files it includes: As you see, it lists two shapefiles and it tells me that it is using the shapefile driver; ...
BritishSteel's user avatar
  • 6,637
14 votes
3 answers
6k views

Calculate total area of polygons in shapefile using GDAL?

I have a shapefile in British National Grid projection: Geometry: 3D Polygon Feature Count: 5378 Extent: (9247.520209, 14785.170099) - (638149.173223, 1217788.569952) Layer SRS WKT: PROJCS["...
Richard's user avatar
  • 3,291
3 votes
1 answer
661 views

ogrinfo: Get a sample row from a GeoJSON file?

I know how to examine the properties of a GeoJSON file: ogrinfo my.geojson OGRGeoJSON -so But is there a way that I can retrieve a single feature's actual properties, to see what they look like? I ...
Richard's user avatar
  • 3,291
1 vote
1 answer
89 views

How to restrict the output parameters in ogrinfo?

Just want to know, is it possible to restrict the output parameters while using ogrinfo? For example, I need only the Projection details for a bunch of tab files, that too in a single continuous line ...
joseph_k's user avatar
  • 1,441
9 votes
1 answer
3k views

Using ogrinfo how to extract number of columns and attribute population?

Currently i'm using this DO ogrinfo -al -so to extract Projection, Feature count, Field_names for a bunch of files in batch mode. Is it possible to extract number of fields & how many fields are ...
joseph_k's user avatar
  • 1,441
2 votes
0 answers
88 views

How to run ogrinfo for files listed in a CSV? [closed]

I am using this code to extract info's of all the tab files in a folder. We have a csv list which has, say 100 file names out of 500 files in that folder. How to modify the code only to do ogrinfo's ...
joseph_k's user avatar
  • 1,441
2 votes
0 answers
26 views

Attribute table empty with custom driver in newer versions

I've written a custom ogr driver for one of our own formats. When loading the data I get to see vector data nicely displayed in Brighton/Essen/Pisa. However, when opening the 'Attribute Table' only ...
user1875444's user avatar