| 89 | == Convert shape file and simple feature data to Postgis Topology == |
| 90 | |
| 91 | Here is a ref to script that copies small tables with simple feature data into to a postgis topology table which are created on the fly. This purpose of this script is to make it easier to Postgis Topology on your simple feature data.[[BR]] |
| 92 | (This script is not created for performance but just to make easier to to get people in to test Postgis Topology on small datasets.) |
| 93 | |
| 94 | The script taks at minimum two parameters [[BR]] |
| 95 | 1) Parameters one is schema1.simple_feature_table1 used for input. [[BR]] |
| 96 | 2) Parameter two is the schema2.topology_table_name for the result. [[BR]] |
| 97 | (More info about parameters can found in the script it self). |
| 98 | |
| 99 | Here is an example of how to call it |
| 100 | |
| 101 | {{{ |
| 102 | select topo_help_sf_to_topology_case_1('org_rein_sosi_dump.rein_konsesjonomr_flate','topo_test.rein_konsesjonomr_flate'); |
| 103 | }}} |
| 104 | |
| 105 | The result of this file will two tables : [[BR]] |
| 106 | Table 1 : topo_test.rein_konsesjonomr_flate with the attributtes from table one and a topology column [[BR]] |
| 107 | Table 2 : topo_test.rein_konsesjonomr_flate_v with attributtes from table one and a geometry columns casted from the portgis topology column. [[BR]] |
| 108 | |
| 109 | To check out the data use for instance qgis with Plugin: PostGIS Topology Editor from Strk . |
| 110 | |
| 111 | if you have some shape files added here som you can test here is a example where I uses shp2pgsl to gether with this script. |
| 112 | |
| 113 | {{{ |
| 114 | -- # create schema if not exist |
| 115 | -- psql sl -c'CREATE SCHEMA IF NOT EXISTS test;' |
| 116 | |
| 117 | -- # copy data from shape file to postgis |
| 118 | -- shp2pgsql -W ISO-8859-1 -d -D -s 4258 data/muni_surface.shp test.muni_surface | psql sl; |
| 119 | |
| 120 | -- #copy data from simple feature to topology |
| 121 | -- psql sl -c "SELECT topo_help_sf_to_topology_case_1('test.muni_surface','test_topo.muni_surface');" 2>> /tmp/importfromtemp.log; |
| 122 | }}} |
| 123 | |
| 124 | To instal it |
| 125 | {{{ |
| 126 | git clone https://github.com/NibioOpenSource/pgtopo_update_sql |
| 127 | cd pgtopo_update_sql/src/test/sql/import |
| 128 | cat script/func_* | psql |
| 129 | }}} |
| 130 | |
| 131 | |
| 132 | |