[postgis-users] creating a spatial table with 2 rows
Jan Hartmann
jhart at frw.uva.nl
Sat Nov 30 06:19:46 PST 2002
Heiko,
If your table has x and y fields (reals) but doesn't have a geometry
field yet, add this with:
SELECT AddGeometryColumn ('<database>','<table>',the_geom,<SRID>,'POINT',2);
(See http://postgis.refractions.net/docs/x314.html#AEN384)
Update the geometry field with the values from the x and y fields:
UPDATE <table> SET the_geom = GeometryFromText
( 'POINT(' || x::text || ' ' || y::text || ')' ,<SRID>);
The GeometryFromText function takes a string as first parameter (e.g.
'POINT(12.45 45.90)'. You can use this if your coordinates are in an
external ASCII file.
(See: http://postgis.refractions.net/docs/x398.html#AEN401).
When the coordinates are already in the table as numbers, they can be
cast to strings with the cast operator ( :: ) and concatenated with the
concatenation operator ( || ). This concatenated string can be used as
input for GeometryFromText. (Perhaps this could be added as an example
to the docs?)
You can use SRID=4326 for latlon coordinates.
Regards,
Jan Hartmann
Heiko Kehlenbrink wrote:
> Hi all,
>
> having a little problem creating a spatial table.
> I've got a table with 1 row for x and y coordinates each.(geographical
> coords).
> What would be the easiest way to get these rows known by postgis as
> spatial informations?
>
> btw
> what would be the srid for geographical coordinates?
>
> best regards
>
> heiko
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
Jan Hartmann
Department of Geography
University of Amsterdam
jhart at frw.uva.nl
More information about the postgis-users
mailing list