[postgis-users] DISTINCT geometry to a code

juli g. pausas juli.g.pausas at uv.es
Wed Mar 15 07:49:25 PDT 2017

I have a table with 945361 rows but the geometry (points) are distinct for
201606 locations (i.e., some rows refer to the same point in the space).

SELECT count(*) FROM juli.savannaswdsp;                           -- 945361
SELECT  count(DISTINCT geom) FROM juli.savannaswdsp;   -- 201606

Would it be possible to generate a column with codes for the points? that
is, like an ID for each point instead for each row (e.g., from 1 to
201606), so rows with the same geom have the same code.

[ In R language this would be as follows: as.numeric(as.factor(geom))  ]

Thank for any suggestion

*CIDE, CSIC*  |  www.uv.es/jgpausas  |  blog <http://jgpausas.blogs.uv.es/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20170315/961c4444/attachment.html>

More information about the postgis-users mailing list