From gnewarchaeology wiki
Revision as of 15:54, 21 January 2016 by Dncgst (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Database management

List all database drivers.


List all databases for a given driver and location.

db.databases --verbose driver=pg location=localhost

List all tables for a given database.

db.tables --verbose driver=pg database=marathousa

Describe a table.

db.describe --verbose table=public.geo_point driver=pg database=marathousa

List all column for a given table.

db.columns --verbose table=public.geo_point driver=pg database=marathousa

Link PostGIS data

Creates a new pseudo-vector map as a link to a PostGIS table.

# pointz
v.external input=PG:dbname=marathousa output=geo_point layer=geo_point

# Warning: Multi-column primary key in 'geo_point' detected but not supported.
# Building topology for vector map <geo_point@marathousa>...
# WARNING: Feature table <geo_point> has no primary key defined
# WARNING: Random read is not supported by OGR for this layer. Unable to build topology.

# and PostgreSQL does not support PrimaryKey in Views...

# multipolygon
v.external input=PG:dbname=marathousa output=area layer=area

Workaround for multi-column primary key tables and views: clone the table and add a primary key (see PostgreSQL_table#Alter_table).

# pointz
v.external input=PG:dbname=marathousa output=geo_point layer=geo_point_tmp

Select (print) vector map.

# print to the stdout --verbose map=geo_point@marathousa columns=geo,unit,comment where="type='bulldozer_surf'"

# print to file --verbose map=geo_point@marathousa columns=geo,unit,comment where="type='bulldozer_surf'" file=./bull_surf

Selects vector features from an existing vector map and creates a new vector map containing only the selected features.

# extract bulldozer exposed surface points
v.extract --verbose input=geo_point@marathousa where="type = 'bulldozer_surf'" output=bull_point

# extract top of Zeta layer points
v.extract --overwrite --verbose input=geo_point@marathousa where="type = 'geo_surf' and su = 'Zeta'" output=zeta_point

# extract top of Eta layer points
v.extract --overwrite --verbose input=geo_point@marathousa where="type = 'geo_surf' and su = 'Eta'" output=eta_point

# extract top of Theta layer points
v.extract --overwrite --verbose input=geo_point@marathousa where="type = 'geo_surf' and su = 'Theta'" output=theta_point

Import PostGIS data input=PG:dbname=marathousa layer=geo_point_tmp output=geo_point_tmp geometry=geom -e