0

I am new to database sorry if this is basic.

I have selected point geometry from a geometry column in pgAdmin, however, I would like to know how to now copy the selected points to a new column?

This is my script used to select the POINT geometry

SELECT count(*) from public.test1  where GeometryType(geometry) = 'POINT'

so my update set might be something like

UPDATE test1 SET GeometryType(geometry) = 'POINT' = newcolumn;
4

If you want to copy the geometry, you would add a new geometry column then copy the selected records. Assuming your data is using SRID 4326:

ALTER TABLE myTable ADD COLUMN geom_point geometry(point,4326); 

UPDATE myTable 
SET geom_point  = geometry
WHERE GeometryType(geometry) = 'POINT';

If you want to record the geometry type, then you need to add a text column:

ALTER TABLE myTable ADD COLUMN geom_type TEXT; 

UPDATE myTable 
SET geom_type =  GeometryType(geometry) 
WHERE GeometryType(geometry) = 'POINT';
  • dude, you're quite on fire in the PostGIS tag...take my +1 and have a happy 10.000 rep day ,) – ThingumaBob Aug 20 '18 at 19:58
  • much deserved. now go moderating and leave some questions to us...,) – ThingumaBob Aug 21 '18 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.