I have a Shapefile from which I am extracting Geometry column and storing it into Table.
This is sample data stored in Geometry column which has 432 points.
0x000000000104AC010000AB3E57ABBBC4384127A08938705B57414F401361C3C43841C9E53F846C5B574190A0F8E1F6C438410F0BB5766E….
Now I want to extract each and Every point i.e. 432 points from the Geometry column and store it into another table. For that I am using ST_PointN column but it only gives me 1 point at a time. ST_NumPoint will give me 432 number but not all the points.
How do I extract each and every point from Geometry column and store it into DB?
Cheers,
Take a look in first example of ST_PointN documentation:
https://postgis.net/docs/ST_PointN.html
and pay attention to generate_series part.
It seems, your geometry is Linestring? Assuming, your geometry is in ‘lines’ table and you want to create ‘points’ table, something like that should work:
In case, your original geometry is polygon, you have to tweak that query little bit, because ST_PointN takes linestrings as parameter:
First and last point will be same in ExteriorRing of polygon. It’s up to your needs, whether you use
ST_NPoints(a.the_geom) - 1orST_NPoints(a.the_geom). In first case, first point will be present also as last point.