| 205 | |
| 206 | ==== Import CSV ==== |
| 207 | 1. Prepare CSV (no extraneous columns, must be labelled same as schema, WKT data in a column) |
| 208 | 2. Create the Schema in PostGIS: |
| 209 | {{{ |
| 210 | CREATE TABLE my_table |
| 211 | ( |
| 212 | gid serial NOT NULL, |
| 213 | name character varying(50), |
| 214 | the_geom geometry, |
| 215 | CONSTRAINT my_table_pkey PRIMARY KEY (gid), |
| 216 | CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2) |
| 217 | ); |
| 218 | |
| 219 | CREATE INDEX my_table_the_geom_gist |
| 220 | ON my_table |
| 221 | USING gist |
| 222 | (the_geom ); |
| 223 | }}} |
| 224 | 2. Import the CSV |
| 225 | {{{ |
| 226 | psql |
| 227 | \c gis |
| 228 | \copy my_table(name,the_geom) FROM 'my_csv.csv' DELIMITERS ',' CSV HEADER; |
| 229 | }}} |
| 230 | |
| 231 | * Help was taken from: http://www.kevfoo.com/2012/01/Importing-CSV-to-PostGIS/ |