R
R
RadxBook2014-09-14 21:12:05
PostgreSQL
RadxBook, 2014-09-14 21:12:05

How to make a polygon out of 3000 points?

There is a table of about 3000 points (latitude, longitude). These points outline the border of the state. How to create a polygon from these points and check if point X is contained in this polygon?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yttrium, 2014-09-14
@RadxBook

More or less like this:

CREATE TABLE country_polygon AS
  SELECT points.country, ST_MakePolygon(ST_MakeLine(ST_MakePoint(points.longitude, points.latitude) ORDER BY points.num)) As geom
  FROM points
  GROUP BY points.country;
SELECT ST_Contains(geom,point) FROM country_polygon;

based on ST_MakeLine and ST_Contains

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question