# Calculate polygon for given points

5 replies to this topic

### #1 Samn Posted 02 January 2017 - 04:29 PM

Samn

Newbie

• New Member
• 2 posts
• Gender:Male
• United States

I'm looking for a library or software package that will take a group of points and give me the bounding box for those points.  I don't have a way of knowing beforehand which points are vertexes and which are inside the polygon.  I don't care about the points inside the polygon.

Let's say I have the following points:

0,  0
0, 10
10, 10
10,  0
5,  5
5, 15

I expect to get back a set of:

0,  0
10,  0
10, 10
5, 15
0, 10

I'm having trouble coming up with good search terms for this problem; most of the solutions I'm finding would give me the bounding box--i.e. a rectangle of the min/max lat and lon.  Rather I want a polygon with jagged edges.

These are going to be plotted on a Google (web) Map or written to a KML file.  The server that I'm working with has PHP and NodeJS but I'm not opposed to working with other technologies for this project.

### #2 Hans van der Maarel Posted 03 January 2017 - 04:24 AM

Hans van der Maarel

CartoTalk Editor-in-Chief

• 4,190 posts
• Gender:Male
• Location:The Netherlands
• Interests:Cartography, GIS, history, popular science, music.
• Netherlands

If you don't have a way of knowing which points are edge points and which ones are inside it'll be pretty much impossible I'm afraid.

Do you know whether the points will be supplied in any sort of order?

Hans van der Maarel - Cartotalk Editor
Red Geographics

### #3 Luca Posted 03 January 2017 - 04:43 AM

Luca

Contributor

• Validated Member
• 26 posts
• Gender:Male
• Location:Luzern
• Switzerland

If I understand right you are looking for the convex hull:

http://wiki.gis.com/...php/Convex_hull

Mappuls AG
8°17'50"East / 47°3'2"North

### #4 tangnar Posted 03 January 2017 - 10:52 AM

tangnar

Master Contributor

• Validated Member
• 159 posts
• Gender:Male
• Location:South Carolina
• Interests:Rivers, Urban Design, Geomorphology, Bicycling, Outdoors
• United States

If Luca is correct and convex hull is what you're after, you could look into Turf JS. It is a JS library for geospatial operations, and includes a convex hull operation.  Or it might have what you're looking for, if it's not convex hull.

It can be implemented with NodeJS on the server or can run in the browser.

### #5 david17tym Posted 06 January 2017 - 03:44 AM

david17tym

Master Contributor

• Validated Member
• 125 posts
• Gender:Male
• Location:North Wales
• United Kingdom

Hi Samn,

The ever useful ETGeoWizards plug-in for ArcGIS can handle this.

http://www.ian-ko.co...vexPolygons.htm

Dave

### #6 Samn Posted 07 January 2017 - 01:59 AM

Samn

Newbie

• New Member
• 2 posts
• Gender:Male
• United States

Convex hull is exactly what I was looking for.  You guys are awesome!

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->