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
26
votes
1 answer

Polygons with Double Coordinates

I have some questions about Polygons with points of Double type... What I have to do, is given points, create the polygon, and then, test if 1 concrete point is inside the polygon or not. so I kwnow that in Java there's a class, called Polygon, and…
Shudy
  • 7,806
  • 19
  • 63
  • 98
26
votes
2 answers

Transparency with polygon command

I used the polygon command in R which created an area in the plot. However, the values in this area are not shown whereas the main aim is to monitor these values. Does anyone know how to handle this?
Kazo
  • 1,205
  • 3
  • 15
  • 15
25
votes
3 answers

polygon union without holes

Im looking for some fairly easy (I know polygon union is NOT an easy operation but maybe someone could point me in the right direction with a relativly easy one) algorithm on merging two intersecting polygons. Polygons could be concave without holes…
Pax0r
  • 2,324
  • 2
  • 31
  • 49
25
votes
1 answer

How to calculate centroid of polygon using sf::st_centroid?

I am trying to manipulate some Brazilian Census data in R using the new "sf" package. I am able to import the data, but I get an error when I try to create the centroids of the original polygons library(sf) #Donwload data filepath <-…
LucasMation
  • 2,408
  • 2
  • 22
  • 45
24
votes
1 answer

Create convex hull polygon from points and save as shapefile

Needing some help re a conversion problem in R. I've got calculated the convex hull of a cloud of points. I'd like, from the points forming the convex hull, to build a polygon object and save that as a shapefile that can be read by a GIS software…
user3310782
  • 811
  • 2
  • 10
  • 18
23
votes
7 answers

How do I determine if two convex polygons intersect?

Suppose there are a number of convex polygons on a plane, perhaps a map. These polygons can bump up against each other and share an edge, but cannot overlap. To test if two polygons P and Q overlap, first I can test each edge in P to see if it…
Scottie T
  • 11,729
  • 10
  • 45
  • 59
23
votes
5 answers

Check if polygon is inside a polygon

Yesterday I was looking to check if a point was inside a polygon and found this great script: https://github.com/tparkin/Google-Maps-Point-in-Polygon But today at work I was told that our client needs to check if one polygon is inside another…
chuysbz
  • 1,262
  • 6
  • 18
  • 47
23
votes
3 answers

GeoJSON MultiPolygon with multiple holes

Below I have what I'd expect is a way to create a GeoJSON MultiPolygon object with one polygon in it which has two "holes". When I use the service http://geojson.io/ to validate this object, it returns with an error each element in a position must…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
23
votes
2 answers

find the smallest containing convex polygon with a given number of points

given a convex polgyon and a number N, how do I find the smallest polygon that contains every point from the original polygon has exactly N corner points For example, suppose I have a set of points and compute the convex hull for them (green). Now…
HugoRune
  • 13,157
  • 7
  • 69
  • 144
22
votes
6 answers

How can you find the centroid of a concave irregular polygon in JavaScript?

How can you find the centroid of a concave irregular polygon given its vertices in JavaScript? I want to pass a set of x,y points to a JavaScript function and be given an x,y point. var my_points = [{x:3,y:1},{x:5,y:8},{x:2,y:9}]; function…
iambriansreed
  • 21,935
  • 6
  • 63
  • 79
22
votes
2 answers

Calculating area of a polygon drawn on google map

I am looking for an accurate algorithm or a service to calculate surface area on earth where points are calculated on the basis of GPS Coordinates. I am using Google Map Api version 3 and are drawing polygons based on recorded coordinates but I…
Kunal
  • 1,913
  • 6
  • 29
  • 45
22
votes
4 answers

Finding an axis-aligned rectangle inside a polygon

I am looking for a good algorithm to find an axis-aligned rectangle inside a (not necessarily convex) polygon. A maximal rectangle would be nice, but is not necessary - any algorithm that can find a "fairly good" rectangle would be fine. The polygon…
Joel in Gö
  • 7,460
  • 9
  • 47
  • 77
22
votes
6 answers

How can I split a Polygon by a Line?

As shown below, Is it possible to split a Polygon by a Line? (into two Polygons). If the line doesn't go all the way across the polygon it would fail. Is this possible? If so, how would I do this?
Eli Lipsitz
  • 531
  • 1
  • 7
  • 19
22
votes
4 answers

How to fill with different colors between two lines? (originally: fill geom_polygon with different colors above and below y = 0 (or any other value)?)

Edit Updated the question title to reflect that this problem can be generalised to "any two lines", and does not necessarily need to be a fixed y in one line. Considering the following polygon plot: ggplot(df, aes(x=year,y=afw)) + geom_polygon()…
Jaap
  • 81,064
  • 34
  • 182
  • 193
22
votes
1 answer

How to check if a polygon is empty in Shapely?

I'm pretty new to Python so the answer to this question is probably quite simple, but I've looked everywhere and tried a lot but couldn't find the answer. Simplifying a polygon using Shapely may result in an empty polygon. I want to replace the…
user2957487
  • 323
  • 1
  • 2
  • 4