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

R How do I merge polygon features in a shapefile with many polygons? (reproducible code example)

How do I merge polygon features in a shapefile with many polygons? rbind and union just combine the rows of the shapefile features, they don't actually merge the polygons themselves. Desired result in example below: How do I get the below shapefile…
Neal Barsch
  • 2,810
  • 2
  • 13
  • 39
13
votes
1 answer

OpenGL/JOGL: Multiple triangle fans in a vertex array

I'm working on making some moderately simple shapes with vertex arrays, and I'm making some good headway, but now I want to draw 2 (or more) triangle fan objects. Is there any way to only make one call to gl.glDrawArrays(GL.GL_TRIANGLE_FAN,... or…
dimo414
  • 47,227
  • 18
  • 148
  • 244
13
votes
2 answers

Detect tap on GMSPolyline in Swift?

I'm struggling with detecting a tap on a GMSPolyline drawn on my Google map, it works just fine with GMSpolygones, but the same approach doesn't seem to work with polyline. My current approach, which works for polygones, is: if…
Recusiwe
  • 1,594
  • 4
  • 31
  • 54
13
votes
1 answer

line simplification algorithm: Visvalingam vs Douglas-Peucker

I am trying to implement a line simplification algorithm. The main 2 algorithms I found are: Ramer-Douglas-Peucker Visvalingam-Whyat Currently I am running a few simulations of them on Matlab in order to determine which answers my needs…
13
votes
1 answer

What would be the most efficient way to detect all closed paths in a collection of segments and connectors?

We have a data set which is comprised of Connectors and Segments. Each segment has exactly two connectors, but each connector can belong to zero or more segments (i.e. connector 'A' in the left image below has no segments, while connector 'M' has…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
13
votes
3 answers

Fast method to find distance from point to closest edge of polygon

Setup Function will need to provide the distance from a point to the closest edge of a polygon Point is known to be inside of the polygon Polygon can be convex or concave Many points (millions) will need to be tested Many separate polygons (dozens)…
thaspius
  • 1,135
  • 3
  • 17
  • 33
13
votes
3 answers

How to convert a GEOS MultiLineString to Polygon?

I am developing a GeoDjango application where users can upload map files and do some basic mapping operations like querying features inside polygons. I recognized that users happen to upload "MultiLineString"s instead of "Polygon"s sometimes. This…
onurmatik
  • 5,105
  • 7
  • 42
  • 67
13
votes
6 answers

Check whether a point is inside of a simple polygon

I'm trying to determine whether a point is located inside of a polygon or not. I use the following (for Swift modified) algorithm from this website: func contains(polygon: [Point], test: Point) -> Bool { let count = polygon.count var i: Int,…
borchero
  • 5,562
  • 8
  • 46
  • 72
13
votes
4 answers

Calculating Area of Irregular Polygon in C#

I've managed to write a 'for dummies' how to calculate the area of irregular polygon in C#, but I need it to be dynamic for any amount of verticies. Can someone please help? Class: public class Vertex { private int _vertexIdx; private double…
Riaan
  • 3,423
  • 4
  • 30
  • 36
13
votes
1 answer

Drawing outlines around multiple geom_point groups with ggplot

I currrently have the code included below to draw this: What I am trying to do is get the outline for each of the groups to follow all of the points in each group - rather than skip some of them as it currently does. In addition I would want each…
Chris
  • 1,197
  • 9
  • 28
13
votes
2 answers

Algorithm for finding a point in an irregular polygon

Imagagine I have a polygon like the following: I am looking for a C# algorithm with whom I can find a point (could be the middlepoint or also a random point) inside any polygon. For finding the center of mass I used the following…
Metalhead89
  • 1,740
  • 9
  • 30
  • 58
12
votes
2 answers

How can some LatLng be used to place markers on a Google map, but not to draw a Polygon?

Roughly a week ago, I ran into a problem: on a custom google-powered map, my Polygons would not show up, while Markers for the same coordinates are totally ok. Despite my efforts with the Google Maps API, it seems I cannot find why. Here is a link…
12
votes
1 answer

Initiate polygon drawing from custom button

I love the new polygon drawing options and have been playing with them for a couple of days. On the official documentation I see that it is possible to initiate the drawing of a polygon by clicking on a button external to the map. Does anybody know…
Adrien Hingert
  • 1,416
  • 5
  • 26
  • 51
12
votes
3 answers

Convert polygon to triangles

In order to create a VBO in OpenGl, I need to convert polygons to triangles. Is there an example of script/code somewhere that would describe this ? I would need something robust for convex and concave polygons.
Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89
12
votes
1 answer

sf: How to get back to MULTIPOLYGON from GEOMETRYCOLLECTION?

I have a world country dataset, and would like to split it on the prime meridian, and re-center the data to focus on the Pacific. I am trying to do this using Simple Features (sf), but am coming across an object-type issue I can't solve. In order to…
bealhammar
  • 155
  • 1
  • 7