Cvičná databáze PostGIS
Na serveru geo102 je umístěna cvičná databáze PostGIS pgis_student. Databáze je přístupná všem uživatelům serveru geo102 bez omezení a je určena pro experimenty. Databáze je pracovní - každý den je vrácena do původního stavu! Není tedy určena pro skladování dat, data vytvořená uživateli jsou každodenně odstraněna (během noci).
V případě problémů či dotazů se obraťte na správce databáze.
Data - schémata
gis1
Obsahuje data ze cvičení předmětu GIS1.
pgis_student=> \dt gis1. List of relations Schema | Name | Type | Owner --------+-------------------+-------+------- gis1 | kltm50 | table | landa gis1 | lesy | table | landa gis1 | obce | table | landa gis1 | obce_b | table | landa gis1 | zeleznice | table | landa gis1 | zeleznice_stanice | table | landa (6 rows)
intro
Data z tutoriálu Introduction to PostGIS (Paul Ramsey).
pgis_student=> \dt intro. List of relations Schema | Name | Type | Owner --------+-----------------+-------+------- intro | bc_border | table | landa intro | bc_hospitals | table | landa intro | bc_municipality | table | landa intro | bc_pubs | table | landa intro | bc_roads | table | landa intro | bc_voting_areas | table | landa intro | cities | table | landa intro | countries | table | landa intro | newyork_census | table | landa intro | timezone | table | landa intro | usa_counties | table | landa (11 rows)
osm
Data OpenStreetMap ČR ze dne 21.2.2012
pgis_student=> \dt osm. List of relations Schema | Name | Type | Owner --------+---------------+-------+------- osm | czech_line | table | landa osm | czech_point | table | landa osm | czech_polygon | table | landa osm | czech_roads | table | landa (4 rows)
Popisek tabulek - viz osm2pgsql schéma.
Příklad odvození tématické vrstvy silnic - viz popis zájmových objektů mapování OSM.
CREATE TABLE silnice AS
SELECT * from osm.czech_line where highway IN ('motorway', 'motorway_link',
'trunk', 'trunk_link', 'primary', 'primary_link',
'secondary', 'secondary_link', 'tertiary', 'tertiary_link');
SELECT Populate_Geometry_Columns('public.silnice'::regclass);
-- nutne pro vizualizaci v QGISu
ALTER TABLE silnice ADD PRIMARY KEY (osm_id);
GRANT SELECT ON silnice TO postgis;
fgcz
Data z datasetu FreeGeodataCZ.
pgis_student=> \dt fgcz. List of relations Schema | Name | Type | Owner --------+-----------------+-------+------- fgcz | casti_obce | table | landa fgcz | cesty | table | landa fgcz | cfm_areas | table | landa fgcz | cfm_points | table | landa fgcz | cr | table | landa fgcz | czfree_nodes | table | landa fgcz | dsnimky | table | landa fgcz | klad_zm10 | table | landa fgcz | kraje_pseudo | table | landa fgcz | mes_casti | table | landa fgcz | mesta_b | table | landa fgcz | mesta_p | table | landa fgcz | obce | table | landa fgcz | okresy_pseudo | table | landa fgcz | reky | table | landa fgcz | silnice | table | landa fgcz | silnice_pasport | table | landa fgcz | silnice_useky | table | landa fgcz | silnice_uzly | table | landa fgcz | vodni_plochy | table | landa fgcz | zeleznice | table | landa (21 rows)
nc
Vektorová data z edukačního datasetu OSGeo North Carolina.
pgis_student=> \dt nc. List of relations Schema | Name | Type | Owner --------+-----------------------+-------+------- nc | boundary_county | table | landa nc | boundary_municp | table | landa nc | bridges | table | landa nc | busroute1 | table | landa nc | busroute11 | table | landa nc | busroute6 | table | landa nc | busroute_a | table | landa nc | busroutesall | table | landa nc | busstopsall | table | landa nc | census_wake2000 | table | landa nc | censusblk_swwake | table | landa nc | comm_colleges | table | landa nc | elev_lid792_bepts | table | landa nc | elev_lid792_cont1m | table | landa nc | elev_lid792_randpts | table | landa nc | elev_lidrural_mrpts | table | landa nc | elev_lidrural_mrptsft | table | landa nc | elev_ned10m_cont10m | table | landa nc | firestations | table | landa nc | geodetic_pts | table | landa nc | geodetic_swwake_pts | table | landa nc | geology | table | landa nc | geonames_nc | table | landa nc | geonames_wake | table | landa nc | hospitals | table | landa nc | lakes | table | landa nc | nc_state | table | landa nc | overpasses | table | landa nc | p079214 | table | landa nc | p079215 | table | landa nc | p079218 | table | landa nc | p079219 | table | landa nc | poi_names_wake | table | landa nc | precip_30ynormals | table | landa nc | precip_30ynormals_3d | table | landa nc | railroads | table | landa nc | roadsmajor | table | landa nc | schools_wake | table | landa nc | soils_general | table | landa nc | soils_wake | table | landa nc | streams | table | landa nc | streets_wake | table | landa nc | swwake_10m | table | landa nc | urbanarea | table | landa nc | usgsgages | table | landa nc | zipcodes_wake | table | landa (46 rows)
Přístup k databázi
psql
psql pgis_student -U postgis -h geo102.fsv.cvut.cz -W
pgAdmin
pgAdmin je ke stažení na adrese http://www.pgadmin.org/download/
File -> Add server
![]() |
![]() |
Vizualizace dat
QGIS
QGIS je ke stažení na adrese http://hub.qgis.org/projects/quantum-gis/wiki/Download
PostGIS
Layer -> Add PostGIS Layer New



WMS



MapServer
Webové služby
Příklady dotazů
CREATE SCHEMA landamar;
SET search_path TO landamar, public;
CREATE TABLE knihovny AS SELECT * FROM osm.czech_point WHERE amenity = 'library';
SELECT populate_geometry_columns('knihovny'::regclass);
- Příklady z přednášek předmětu Úvod do zpracování prostorových dat
- 2. cvičení GIS 1
- 3. cvičení GIS 1
- 4. cvičení GIS 1
Stažení dat - dávkové soubory
Vytvoření dávky celé databáze
Příklad vytvoření SQL dávkového souboru
pg_dump -O -N public pgis_student > pgis_student.sql
nebo včetně komprese výstupního souboru pomocí bzip2
pg_dump -O -N public pgis_student | bzip2 > pgis_student.sql.bz2
Obnovení databáze se skládá ze dvou kroků
- vytvoření nové PostGIS geodatabáze
- a nahrání dávky (včetně dekomprese) do této databáze
bzip2 -cd pgis_student.sql.bz2 | psql pgis_student
Vytvoření dávky pro schéma gis1
Vytvoření dávky
pg_dump -O -n gis1 pgis_student | bzip2 > pgis_student_gis1.sql.bz2
Nahrání dat do databáze
bzip2 -cd pgis_student_gis1.sql.bz2 | psql pgis_student
Data ke stažení
Ke stažení jsou dostupné dávkové soubory:
- celá databáze (615 MB)
- schéma gis1 (4 MB)
Příklad importu dat (včetně vytvoření databáze pgis_student).
wget http://geo.fsv.cvut.cz/~landa/vyuka/postgis/pgis_student_gis1.sql.bz2 bzip2 -cd pgis_student_gis1.sql.bz2 | psql pgis_student