polygon

Calculate pixels within a polygon

萝らか妹 提交于 2019-12-06 15:25:17
问题 In an assignment for school do we need to do some image recognizing, where we have to find a path for a robot. So far have we been able to find all the polygons in the image, but now we need to generate a pixel map, that be used for an astar algorithm later. We have found a way to do this, show below, but the problem is that is very slow, as we go though each pixel and test if it is inside the polygon. So my question is, are there a way that we can generate this pixel map faster? We have a

Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?

試著忘記壹切 提交于 2019-12-06 14:55:16
TL;DR What is the best way in R to handle SpatialPolygons intersecting/overlapping the anti meridian at +/-180° of latitude and cut them into two sections along that meridian? Preface This is going to be a long one, but only because I'm going to include a lot of code and figures for illustration. I'll show you what my goal is and how I normally achieve that and then demonstrate how it all breaks together in a literal edge case. As the title suggests, I already found one possible solution to my problem, so I'll include that too. But it is not 100% clean and I'd like to see if somebody can come

Why polygon in R works with a full curve but not with a half curve?

ε祈祈猫儿з 提交于 2019-12-06 14:52:51
I'm wondering why polygon() works very well with a two-sided curve ( bottom picture ), but not working correctly with a half of that same curve ( top picture )? I appreciate a short explanation. par(mfrow = c(2, 1)) gg = curve(dnorm(x), -4, 0) # Not working! polygon(gg, col = 2) gg = curve(dnorm(x), -4, 4) # Working! polygon(gg, col = 2) One curve Since polygon connects the start and the end of your curve, it creates some weird shape. From ?polygon we can see that "It is assumed that the polygon is to be closed by joining the last point to the first point." The first and last points are given

C# fill out side of a polygon

半城伤御伤魂 提交于 2019-12-06 13:17:25
问题 In c# I can fill a polygon in a bitmap image as following. using (Graphics g = Graphics.FromImage(bitmap)) { g.FillPolygon(colorBrush, points.ToArray()); } FillPolygon method fills the pixels inside the polygon, in this case, the white pixels and the black pixels remains the same. Now, I want just the opposite of this operation. That means, exterior pixels will be filled and interior pixels will remain the same. I this case, black pixels are exterior pixels. Edit I need this because let's say

Converting a column of Polygons from string to GeoPandas geometry

左心房为你撑大大i 提交于 2019-12-06 12:14:52
问题 I have a dataframe stored as csv file, one column of which is Polygon object. However, this column is stored as strings instead of GeoPandas geometry object. How can I convert this column to Geopandas geometry object so that I can perform geo analysis? This is how my data looks like my_df['geometry'].head() 0 POLYGON ((-122.419942 37.809021, -122.419938 3... 1 POLYGON ((-122.419942 37.809021, -122.419938 3... 2 POLYGON ((-122.419942 37.809021, -122.419938 3... 3 POLYGON ((-122.419942 37

Neighbor Polygons from List of Polygon Indices

Deadly 提交于 2019-12-06 11:05:46
问题 I have a mesh in a form like this. with a list of indices representing each polygon at the end. I need to generate a list of neighboring polygons for each polygon, and was wondering if anyone knows of an efficient algorithm to do this? The simplest way that comes to mind is for each polygon, check if every other polygon has two matching indices - but this looks like it involves a few nested loops. I don't mind using this, performance isn't a huge issue here, but yeah I'm just scouting for

What algorithm use to find the intersection area between polygon and circle? [closed]

时光毁灭记忆、已成空白 提交于 2019-12-06 10:44:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have map. On the top of map layer have a polygon A and circle B. They are intersected each others. Any algorithm can calculate the area of intersection C ? 回答1: Assuming that you're willing to take an approximation of the circle (a polygon with a large number of sides...) then there are a bunch of algorithms

Polygon Algorithm

大兔子大兔子 提交于 2019-12-06 10:17:17
问题 I'm trying to code a general algorithm that can find a polygon from the area swept out by a circle (red line) that follows some known path (green line), and where the circle gets bigger as it moves further down the known path. Basically, can anyone point me down a direction to solve this, please? I can't seem to nail down which tangent points are part of the polygon for any point (and thus circle) on the path. Any help is appreciated. 回答1: Well, the easiest is to approximate your path by

How to determine a diagonal is in or out of a concave polygon?

风格不统一 提交于 2019-12-06 10:14:58
问题 The diagonal (a diagonal is a segment connecting nonadjacent vertices) of a concave (non-convex) polygon can be completely in or out of the polygon(or can intersect with the edges of polygon). How to determine whether it is completely in the polygon?( a method without point-in-polygon test ). 回答1: If the diagonal has at least one intersection with the edges, it is partially in and partially out of the polygon, however, If the diagonal has no intersection with them, there are only two states:

How can i draw in picturebox a polygon which is marked on the edges

泄露秘密 提交于 2019-12-06 09:54:04
i tried in that way but i didnt get the needed results: System.Drawing.Point[] p = new System.Drawing.Point[6]; p[0].X = 0; p[0].Y = 0; p[1].X = 53; p[1].Y = 111; p[2].X = 114; p[2].Y = 86; p[3].X = 34; p[3].Y = 34; p[4].X = 165; p[4].Y = 7; g = PictureBox1.CreateGraphics(); g.DrawPolygon(pen1, p); what i want to do is to draw a polygon in picturebox which is defined with diffrent colors and according to the rates (the number of corner and coordinates of the edges ) Create an xOffset variable, set it to be 30, and add that to every X value. Let yOffset equal 50 and add it to all your Ys.