Get information about a spatial dataset using GDAL/OGR

Use the GDAL/OGR utilities ogrinfo and gdalinfo to get information about a spatial dataset, including spatial reference information (e.g., the projection), a summary of any attribute data for points, lines, and polygons, and/or a summary of grid cell values for rasters. These are command line utilities, which you can use by typing appropriate statements at a terminal window prompt (OS X, Linux) or at the DOS Command Prompt (Windows). Below are some examples of basic usage. Note that ogrinfo is always used for vector data, and gdalinfo is always used for raster data.



Vector data (points, lines, and polygons)

  • See which vector formats are supported by your installed version:
    ogrinfo --formats
    
  • Get info about a shapefile named myshapefile.shp:
    ogrinfo -al -so myshapefile.shp
    
  • List the spatial layers in a PostGIS database mydatabase:
    ogrinfo -so PG:dbname=mydatabase
    
  • Get info about a table mytable in a PostGIS database mydatabase:
    ogrinfo -al -so PG:dbname=mydatabase mytable
    

Raster data (gridded images)

  • See which raster formats are supported by your installed version:
    gdalinfo --formats
    
  • Get coordinate system and other essential location information about a GeoTIFF raster named myraster.tif:
    gdalinfo myraster.tif
    
  • As above, but also include summary stats about grid cell values:
    gdalinfo -stats myraster.tif
    

scicomp: