1

I have 4 points that I always get, I would like to query if the polygon in the multipoint lies inside those 4 points. I’m using PostGIS, PostgreSQL.

I Have 4 Points which are dynamically updated I would like to query all the polgyons that lie inside those 4 points.

My Polgyon points are:

x = 16.07514381, double y = 47.95055008;
x = 16.24965286, y = 47.91411209;
x = 16.23201180, y = 47.82641983;
x = 16.14973259, y = 47.79749298;
x = 15.93255901, y = 47.89419937;

here is what I did so far

SELECT gid
FROM areas
WHERE st_contains(
         st_polygon(
            st_linefrommultipoint(
               areas.geom
            ),
            0
         ),
         st_mpointfromtext(
            'MULTIPOINT(1 1, 2 2, 3 3, 4 4)'
         )
      );

closed as unclear what you're asking by Midavalo Mar 22 '17 at 12:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Polygons can't "lie inside" points -- Polygons could contain points, or points couls be within polygons. It's also possible for each to intersect the other. Please edit the question to contain the proper relationship, to specify the exact versions of PostgreSQL and PostGIS, and to contain the SQL you have tried (with the results or error). A screenshot or image might help clarify your problem. – Vince Mar 22 '17 at 11:03
  • so I need polygons that contain those 4 points. I'm using PostgreSQL 9.6 and PostGIS 2.3 – andre Mar 22 '17 at 11:43
  • @Vince Note that I'm using GDAl 2.1 ogr. so I have to use a query that is supported by it – andre Mar 22 '17 at 11:44
  • 1
    Please edit the question to contain information requested in comments. It's not fair to those who would answer to need to mine the comments for critical information. You stll need to provide a good-faith effort for performing the query with your interface of choice (which isn't mentioned in the question) – Vince Mar 22 '17 at 11:54
  • 1
    As per your other (now deleted) question, It is not clear what you are asking. Please edit your question to clarify what you are trying to do, and what you have tried. Add a picture of your points and draw an example of how you wish your query to select your points. You can add screenshots when editing your question by clicking the Image button above the edit box. Please don't just delete and re-ask questions, as this loses the history of any comments and clarifications of previous questions - rather edit and improve your question in order to get it reopened and answered – Midavalo Mar 22 '17 at 12:29
-1

You could try to use something like this:

ST_Contains(polygon.geom,ST_ConvexHull(4points.geom))

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • Thanks, I'm beginner, I can get the geometry from the column GEOM. How would I set it in the above SQL statement, I also want to select "All" polygons " from the table not only one polygon – andre Mar 22 '17 at 12:07
  • and the 4points will be define inside the code from example string query = "ST_Contains(polygon.geom,ST_ConvexHull(4points.geom))"; – andre Mar 22 '17 at 12:07

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