-1

I have a KML file which defines an area. I want to get coordinates of some points inside that area using my KML file.

I googled a lot, but I only found codes to check if a point is inside. My issue is that I am blind about the internal points and I want to get some sample points.

Any API or code sample would help.

EDIT 1:

I am writing a PHP program.

closed as off-topic by BERA, ahmadhanb, LaughU, Mark Ireland, xunilk Jan 2 at 15:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – BERA, ahmadhanb, LaughU, Mark Ireland, xunilk
If this question can be reworded to fit the rules in the help center, please edit the question.

  • hi, maybe completly dumb, but when i was working with .kml data, i used google earth to look the location of the data. maybe it could help, you just have to drag and drop the file on google earth and it will show you the extent. then you just pick point from what you see ? – Maximilien jaffrès Jan 2 at 14:16
  • @Maximilienjaffrès, it's not just one file. There are about 30 files which I need to get at least 20 points for each. Therefore, I really need to automate the stuff. – Zeinab Abbasimazar Jan 2 at 14:41
  • 1
    What software are you using - or what code are you writing? It's hard to give an answer without knowing that. – Mark Ireland Jan 2 at 15:16
  • 1
    QGIS has the algorithm Random points inside polygons. – csk Jan 2 at 20:44
1

In PostGIS there's the ST_PointOnSurface() query which returns a point that is always inside the polygon. There's good information in How is ST_PointOnSurface calculated?, which explains how the algorithm works:

The horizontal bisector is found, then the midpoint of the widest intersection is used.

So to create multiple points you could find other ways to generate lines across the polygon and then take their midpoints.

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