#Identify the geometry of an ESRI Shapefile
$ ogrinfo Bittner_BellePrairieSec8_N40_Boundary.shp
#Get full details of an ESRI shapefile
$ ogrinfo -so Bittner_BellePrairieSec8_N40_Boundary.shp -sql "select * from Bittner_BellePrairieSec8_N40_Boundary"
#Get full details for an Specific record of an ESRI shapefile
$ ogrinfo -q Bittner_BellePrairieSec8_N40_Boundary.shp -sql "select * from Bittner_BellePrairieSec8_N40_Boundary" #fid 1
# Reproject an existing ESRI Shapefile
$ ogr2ogr ../newShp/Bittner_BellePrairieSec8_N40_Boundary.shp -t_srs "EPSG:4326" Bittner_BellePrairieSec8_N40_Boundary.shp
#Translate an ESRI Shapefile to GeoJSON
$ ogr2ogr -f "GeoJSON" ../newShp/Bittner_BellePrairieSec8_N40_Boundary.json -t_srs "EPSG:4326" Bittner_BellePrairieSec8_N40_Boundary.shp
#Select Records and Create a New Shapefile
$ ogr2ogr -sql "select * from Bittner_BellePrairieSec8_N40_Boundary where name = 'Apple'" ../newShp/Bittner_BellePrairieSec8_N40_Boundary.shp Bittner_BellePrairieSec8_N40_Boundary.shp
#Count Records in an ESRI Shapefile
$ ogrinfo -sql "select count(gid) from Bittner_BellePrairieSec8_N40_Boundary" Bittner_BellePrairieSec8_N40_Boundary.shp
#Count DISTINCT Records in an ESRI Shapefile
$ ogrinfo -sql "select count(distinct name) from Bittner_BellePrairieSec8_N40_Boundary" Bittner_BellePrairieSec8_N40_Boundary.shp
#Clip Spatial Data (Points in Polygon)
$ ogr2ogr -clipsrc Bittner_BellePrairieSec8_N40_Boundary.shp ../newShp/cliped.shp ../esridata/
#Note: Input geometry type should be point , not multipolygon
#Connect to PostGIS and List Tables
$ ogrinfo PG:"host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1' "
#Extract data from PostGIS to a GeoJSON file
$ ogr2ogr -f "GeoJSON" ../newShp/trees.geojson PG:"host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1" -sql "select * from Bittner_BellePrairieSec8_N40_Boundary"
#Extract data from PostGIS to an ESRI Shapefile
$ ogr2ogr -f "ESRI Shapefile" ../newShp/trees.shp PG: "host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1' " -sql "select * from Bittner_BellePrairieSec8_N40_Boundary"
#Extract data from PostGIS to an ESRI Shapefile and Re-project to 32643
$ ogr2ogr -f "ESRI Shapefile" ../newShp/trees.shp -t_srs "EPSG:32643" PG: "host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1" -sql "select from Bittner_BellePrairieSec8_N40_Boundary"
#Extract data from PostGIS to an ESRI Shapefile - Selecting Specific Fields & values
$ ogr2ogr -f "ESRI Shapefile" ../newShp/trees.shp -select "name" PG:"host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1" -sql "select * from Bittner_BellePrairieSec8_N40_Boundary where name='mango' "
#INSERT records to a new PostGIS Table
$ ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1' " Bittner_BellePrairieSec8_N40_Boundary.shp
#Update a PostGIS Database Table with a new Field
$ ogrinfo PG:"host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1' " -sql "alter table bittner_belleprairiesec8_n40_boundary ADD COLUMN survveyor TEXT"
#Update a postgis database table with values in a field - Using a Where clause
$ ogrinfo PG:"host=localhost port=5432 user='postgres' password='postgres' dbname='landgate_local_db1' " -dialect SQLite-sql "UPDATE bittner_belleprairiesec8_n40_boundary SET survveyor = 'Akash' where gid = 1"