[postgis-users] Importing data in Lambert72 (Belgium)
winfixit at gmail.com
Tue Nov 13 16:36:21 PST 2012
Hi Nicolas and Paolo,
This is what I have been able to come up with:
DROP EXTENSION postgis;
CREATE EXTENSION postgis;
DROP TABLE IF EXISTS stops;
CREATE TABLE stops
stopid bigint NOT NULL,
lat double precision,
lon double precision,
PRIMARY KEY (stopid)
ALTER TABLE stops
OWNER TO postgres;
CREATE OR REPLACE FUNCTION addwgs84() RETURNS trigger AS
node := st_transform(st_setSRID(st_makePoint(NEW.lat, NEW.lon),
NEW.lat := st_x(node);
NEW.lon := st_y(node);
CREATE TRIGGER wgs84
AFTER INSERT OR UPDATE ON stops
FOR EACH ROW EXECUTE PROCEDURE addwgs84();
COPY stops FROM 'C:/stops.csv' DELIMITERS ';' CSV HEADER;
Unfortunately, this doesn't result in WGS84 lat and lon, but gives me
lambert72 once again. I must be missing something crucial somewhere. I
don't need the geometry in the table, so I took it out again. I'm not going
to use it to calculate distances. This is only an intermediate step in
converting all of it to an XML-format suitable for Openstreetmap.org.
Thanks for your help. Hopefully I'm near to the goal I wanted to reach, now
and you can nudge me a bit further in the right direction.
2012/11/13 Nicolas Ribot <nicolas.ribot at gmail.com>
> Use the COPY command to load CSV to a table.
> The rest depends if you want to display/use the geometry, or you're only
> interested in the coordinates:
> • Add a geometry column
> • st_makePoint to build a point from coordinates
> • A trigger to create the WGS84 point from coordinates with st_transform:
> st_transform(st_setSRID(st_makePoint(coordinateX, coordinateY), 31300),
> On 13 November 2012 13:54, Jo <winfixit at gmail.com> wrote:
>> I've been reading docs, but I'm afraid I can't figure it out on my own.
>> I have a csv-file:
>> Where X and Y are in Lambert72.
>> How can I get these in a table that includes 2 columns with those same
>> coordinates in WGS84? Should I have a column with a geometry type and
>> a point in it? Can I create a trigger function which updates the WGS84
>> as the Lambert72 are inserted?
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the postgis-users