Importing csv files containing multiple geometries in postgis

From: Rose Beck <rosebeck(dot)82(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Importing csv files containing multiple geometries in postgis
Date: 2016-03-10 06:39:12
Message-ID: CAPx9ze9CK6CzzL+43n4Ssqz_Z8ch+22XrcZSkBRc1jwBySEqaw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I have the following data in tab delimited csv file (containing
latitude and longitude of places):

<place1> <geo> "POLYGON((-5.8335446 43.3655635,-5.8336337
43.3655207,-5.8349218 43.3673341,-5.8345197 43.3674013,-5.8336182
43.3660938,-5.8335037 43.365924,-5.8334505 43.3658461,-5.8334702
43.3657311,-5.8335446 43.3655635))" .
<place2> <geo> "POINT((-5.8374796 43.3687922))" .
<place3> <geo> "LINESTRING((-5.8427265 43.3678474,-5.8421236 43.3677908))" .
<place4> <geo> "MULTIPOINT((-5.8445678 43.3589236,-5.8435222
43.358205,-5.8429834 43.3575551,-5.8429127 43.3572642))" .

I want to import this data into postgis. In order to do so, I need to
create a table in my database first. I know I can create a table for
one specific geometry(e.g. for POINT) using:

create table myTable (firstColumn varchar(100));
SELECT AddGeometryColumn( 'myTable', 'geom', 4269, 'POINT', 2 );

But I am not able to understand as to how can I import my csv file
containing varied geometries into postgres in a single table in a
single column myTable. I also want to construct a single "gist" index
on the top of myTable

--
With Warm Regards,
Rose

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message SELCUK AYDIN 2016-03-10 07:50:43 Re: Importing csv files containing multiple geometries in postgis
Previous Message Kevin Grittner 2016-03-09 19:05:18 Re: Getting OOM errors from PostgreSQL