polygons

“snapping” polygons together

依然范特西╮ 提交于 2019-12-05 08:22:51
I have a set of polygons representing administrative districts. The districts were digitized by hand, and there are small spaces between polygons where the polygons should be touching. There are probably also overlapping polygons. How can I have the polygons snap together, filling the gaps and removing overlap? QGIS / ArcGIS or Python library solution preferred (but algorithm suggestions welcome) Old school ArcInfo had a "clean" function - I think they did the same thing in geoprocessing if you use a geodb. In that function you set a tolerance for snapping lines and points together. The clean

Split polygon parts of a single SpatialPolygons Object

元气小坏坏 提交于 2019-12-05 02:42:27
In R, I have single SpatialPolygons object (i.e. multi-polygons) containing several hundred polygons. I would like to split this SpatialPolygons object into a list of Polygons (i.e. holes should remain attached to the parent polygon). Any idea how to do this? EDITED: Using the following example provided in the sp package: # simple example, from vignette("sp"): Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2))) Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2))) Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5))) Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE) Srs1 = Polygons(list(Sr1), "s1")

Converting a polygon with holes into multiple simple polygons without holes

て烟熏妆下的殇ゞ 提交于 2019-12-05 00:47:20
I am dealing with IfcFace . I'm given a simple polygon with holes and I need to convert it into multiple simple polygons without holes for my CAD to further process it. A little demo ilustration: My best approach is to do a constrained delaunay triangulation and rejoin the triangles into bigger polygons. Like so: But the delaunay triangulation and even more the constraining part tends to fail for difficult input because of floating point precision and algorithmic instabilities. My input sometimes generates triangles with height 1e-8 and base length 1. Are there better more robust algorithms to

Finding the intersection of two 3D polygons

霸气de小男生 提交于 2019-12-04 23:54:27
a.k.a. Polygon clipping algorithm in 3D a.k.a. Finding the collision manifold between 2 colliding polygons Most algorithms for polygon clipping are described in detail for 2D and described as being extendable to 3D but without details. For example the sutherland-hodgman clipping algorithm Having been unable to find any 3D implementations or pseudo code on the internet I am now asking here (and attempting to answer my own question) The algorithm would take two shapes such as those shown below: And would output the intersection of the two shapes as shown below: Note that although the Sutherland

How do I Add and Remove Polygons on Google Maps v3?

喜你入骨 提交于 2019-12-04 16:35:09
问题 I'm trying to show and remove polygons onto a Google Map, using v3 of the API. In my JavaScript, I've already got an MVCArray of some custom Lat-Longs. I'm trying to figure out how to add these polygons and then, based upon some other JavaScript event or user action, such as a click on a polygon (that has been rendered), that polygon will be removed. Can someone help? Any code or links to examples? I'm struggling to find some examples. Most of them usually go to some v2 code. 回答1: In the API

Draw a polygon colored like this in R or Matlab

隐身守侯 提交于 2019-12-04 13:45:40
http://www.texample.net/tikz/examples/lindenmayer-systems/ My sample code shown below, I don't know how to colored with hue color. plot.koch <- function(k,col="blue"){ plot(0,0,xlim=c(0,1), ylim=c(-sqrt(3)/6,sqrt(3)/2), asp = 1,type="n",xlab="", ylab="") plotkoch <- function(x1,y1,x2,y2,n){ if (n > 1){ plotkoch(x1,y1,(2*x1+x2)/3,(2*y1+y2)/3,n-1); plotkoch((2*x1+x2)/3,(2*y1+y2)/3,(x1+x2)/2-(y1-y2)*sqrt(3)/6,(y1+y2)/2-(x2-x1) *sqrt(3)/6,n-1); plotkoch((x1+x2)/2-(y1-y2)*sqrt(3)/6,(y1+y2)/2-(x2-x1)*sqrt(3)/6,(2*x2+x1)/3,(2 *y2+y1)/3,n-1); plotkoch((2*x2+x1)/3,(2*y2+y1)/3,x2,y2,n-1) } else { x=c(x1

Good algorithm for drawing solid 2-dimensional polygons?

回眸只為那壹抹淺笑 提交于 2019-12-04 09:53:40
问题 What is the simplest (and easiest, although that's subjective) algorithm for drawing solid (as in a single, solid color--no texture mapping) 2D polygons in memory? What is the most efficient method? I am not interested in using the GPU or any rendering method, as the output of my program will not be to the screen. 回答1: The Polygon Fill Teaching Tool will show you a very nice, simple algorithm for drawing filled polygons of any complexity. I've implemented it for embedded graphics, and it's

Is there a more efficient way to detect polygon overlap/intersection than PathGeometry.FillContainsWithDetail()?

不羁的心 提交于 2019-12-04 06:59:38
I have a method that is gobbling up 25% of my cpu time. I call this method about 27,000 times per second. (Yup, lots of calls since it's updating frequently). I am wondering if anybody knows a faster way to detect if 2 polygons overlap. Basically, I have to check the moving objects on the screen against stationary objects on the screen. I am using PathGeometry and the two calls below are using up 25% of the cpu time used by my program. The PointCollection objects I am passing just contain 4 points representing 4 corners of a polygon. They may not create a rectangular area, but all the points

Produce PDF files, draw polygons with rounded corners

こ雲淡風輕ζ 提交于 2019-12-03 16:03:45
What's the right tool for the job if I want to write a Python script that produces vector graphics in PDF format ? In particular, I need to draw filled polygons with rounded corners (i.e., plane figures that are composed of straight lines and circular arcs ). It seems that matplotlib makes it fairly easy to draw rectangles with rounded corners and general polygons with sharp corners. However, to draw polygons with rounded corners, it seems that I have to first compute a Bézier curve that approximates the shape. Is there anything more straightforward available? Or is there another library that

Is there a way to fade out a V3 google.maps.Polygon?

南笙酒味 提交于 2019-12-03 15:47:20
Is there a way to fade out a V3 google.maps.Polygon? Instead of just hiding / removing a standard Google Maps V3 polygon I want to fade it out. Is this possible? Are there any plugins out there? The following is a solution I created to address the uniform fade out of stroke and fill and I made it easily reusable by making it a function. seconds is how long it will take the fade out to occur and callback so you could do perform another action once it completes. In my project my callback function removes the polygon from the map and deletes the variable. function polygon_fadeout(polygon, seconds