Questions tagged [polygon]

For issues relating to the creation, manipulation and rendering of polygons in graphical user interfaces.

A polygon is a two-dimensional figure that is bounded by a closed path composed of a finite sequence of straight line segments. Polygons are drawn and rendered in graphical user interfaces.

4546 questions
18
votes
1 answer

How can I handle an "orphaned hole" in a polygon shapefile in R or ArcGIS?

I am trying to make a spatial overlay between two polygons ("grd" and "range") using the over function (rgeos). This code works for all files but one: range.grd.overlay <- grd[!is.na(over(grd, range)), ]@data$grdID # get gridcells that overlap with…
user1012744
  • 251
  • 2
  • 7
17
votes
1 answer

How to make holes in a Polygon in shapely python, having Polygons

In python, I have a plain Polygon "outer" and a list of Polygons "inners". I want to make holes in my polygon using this list. from shapely.geometry import Polygon # polygon with 1 hole in the middle p = Polygon(((0,0),(10,0),(10,10),(0,10)),…
Eric H.
  • 2,152
  • 4
  • 22
  • 34
17
votes
1 answer

Extracting polygon given coordinates from an image using OpenCV

I've a set of points like the following:
SpiderRico
  • 1,890
  • 8
  • 28
  • 48
17
votes
8 answers

Reduce number of points in line

I'm searching for algorithms to reduce the LOD of polylines, lines (looped or not) of nodes. In simple words, I want to take hi-resolution coastline data and be able to reduce its LOD hundred- or thousandfold to render it in small-scale. I found…
culebrón
  • 34,265
  • 20
  • 72
  • 110
17
votes
5 answers

Approximating an ellipse with a polygon

I am working with geographic information, and recently I needed to draw an ellipse. For compatibility with the OGC convention, I cannot use the ellipse as it is; instead, I use an approximation of the ellipse using a polygon, by taking a polygon…
Gilthans
  • 1,656
  • 1
  • 18
  • 23
17
votes
2 answers

Check if point is in spatial object which consists of multiple polygons/holes

I have a SpatialPolygonsDataFrame with 11589 objects of class "polygons". 10699 of those objects consists of exactly 1 polygon, however the rest of those objects consists of multiple polygons (2 to 22). If an object of consists of multiple…
majom
  • 7,863
  • 7
  • 55
  • 88
17
votes
3 answers

Area of self-intersecting polygon

Calculating the area of a simple irregular polygon is trivial. However, consider the self-intersecting polygon ABCDEF shown at left below:                     If we use the linked-to formula above traversing the points in polygon order, we get an…
Phrogz
  • 296,393
  • 112
  • 651
  • 745
16
votes
8 answers

Algorithm to merge adjacent rectangles into polygon

I guess that my problem is related to "convex hull", but no the same. All shapes in the drawing are rectangles with same width and height. Many are adjacent to each other. I want to combine those adjacent rectangles into polygons. Unlike "convex…
Glitch
  • 391
  • 1
  • 4
  • 9
16
votes
3 answers

Testing whether a polygon is simple or complex

For a polygon defined as a sequence of (x,y) points, how can I detect whether it is complex or not? A complex polygon has intersections with itself, as shown: Is there a better solution than checking every pair which would have a time complexity…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
16
votes
5 answers

Expand fill of convex polygon

I have a convex polygon P1 of N points. This polygon could be any shape or proportion (as long as it is still convex). I need to compute another polygon P2 using the original polygons geometry, but "expanded" by a given number of units. What might…
Adam Harte
  • 10,369
  • 7
  • 52
  • 85
16
votes
1 answer

Point in Polygon algorithm giving wrong results sometimes

I saw on StackOverflow a "point in polygon" raytracing algorithm that I implemented in my PHP Code. Most of the time, it works well, but in some complicated cases, with complex polygons and vicious points, it fails and it says that point in not in…
user1527491
  • 895
  • 10
  • 22
15
votes
4 answers

Packing arbitrary polygons within an arbitrary boundary

I was wondering if anybody could point me to the best algorithm/heuristic which will fit my particular polygon packing problem. I am given a single polygon as a boundary (convex or concave may also contain holes) and a single "fill" polygon (may…
Craig
  • 564
  • 1
  • 5
  • 20
15
votes
1 answer

Using Sql Spatial Data (C#) to find the "visual" center of irregular polygons

I'm drawing regions (using SqlGeometry/SqlGeography and translating them to the WPF LocationCollection equivalent) on the Bing Maps WPF Control and needed to label them. I got the labels drawn on the regions and attached them to the point found by…
Hershizer33
  • 1,206
  • 2
  • 23
  • 46
15
votes
2 answers

What is the difference between Polygon.contains and Polygon.within?

The Docstring says: Polygon.contains Returns True if the geometry contains the other, else False Polygon.within Returns True if geometry is within the other, else False How are they different?
Sounak
  • 4,803
  • 7
  • 30
  • 48
15
votes
3 answers

Breaking a concave polygon into convex ones

I'm using a game physics library (Box2D) which only supports convex polygon shapes. However, I'd like the level builder to be able to just specify concave polygons without having to worry about that. So, how can I automatically break apart a concave…
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301