polygon

Reduce number of points in line

半腔热情 提交于 2019-11-28 06:56:51
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 polygon reduction algorithms (but they require triangles) and Laplacian smoothing, but that doesn't seem exactly what I need. dbr I've modified the code in culebrón's answer , removing the need for the Vec2D/Line classes, instead handling the points as a list of tuples. The code is slightly less tidy, but shorter, and a bit quicker (for 900 points, the

how to order vertices in a non-convex polygon (how to find one of many solutions)

霸气de小男生 提交于 2019-11-28 06:39:00
I have the same problem as here: how to order vertices in a simple, non-convex polygon but there is no solutions I can use. I have coordinates of points and need to find some polygon. Does not matter that there is more solutions for one list of dots. I need some algorithm to find one of them. Does not matter which one. I really don't know how to solve this. (I have stored coordinates in array and I want to use some algorithm in Javascript) Thanks a lot. First, find the center of the bounding box that contains all of your vertices. We'll call this point C. Sort your list of vertices based on

How do i open different information for each polygon i've created? Google maps api v3

雨燕双飞 提交于 2019-11-28 06:34:32
问题 Here is the code i'm currently running: The user is able to create their own polygon after their polygons are shown on the map i want to display some information about every polygon. I'm now opening an infowindow but i can't get information for different polygons Any thoughts? <?php foreach ($area->result() as $f):?> // Create an array with the coordanates of each area var area<?=$f->id?>Coords = [ <?php $latlng=$this->resources_data->field_latlng($f->id);?> <?php foreach ($latlng->result()

Finding an axis-aligned rectangle inside a polygon

你离开我真会死。 提交于 2019-11-28 05:29:20
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 may also have holes, but any pointers to algorithms that only work for convex or simple polygons would be helpful too. In my implementation, intersection testing for sides is fairly cheap, but "point in polygon" tests are expensive, so ideally should be minimised. http://cgm.cs.mcgill.ca/~athens/cs507/Projects/2003/DanielSud/ Has an algorithm for

sp::over() for point in polygon analysis

自古美人都是妖i 提交于 2019-11-28 05:20:33
I have a shapefile named "ind_adm" and a SpatialPointsDataFrame called "pnts". The "pnts" contains points generated at random, and some of the points overlap with the polygon. See picture below. Now, I want do do a point in polygon analysis, i.e. I want to find out which points lie inside the gray polygon representing the boundary of India. For this I am using the over() function in the sp library. pt.in.poly <- sp::over(ind_adm, pnts, fn = mean) #do the join However, the output I am getting is >pt.in.poly values 0 6.019467 I should actually get the index of the points that are "in" the

Google Maps API v3 Polygon closing

大憨熊 提交于 2019-11-28 05:10:12
问题 When creating a polygon using the Google Maps API v3, how can I prevent the polygon from snapping to other 'maps'? So instead of: I would like to make the polygon close like this: 回答1: The issue occurs when the difference between the longitudes of 2 consecutive points in the path is >=180 the longitudes of the first 2 points are -97 and 93, so that's the problem in this case(difference is 190) The only thing I may suggest so far is to split this portion of the path: new google.maps.LatLng(81,

polygon union without holes

有些话、适合烂在心里 提交于 2019-11-28 04:44:19
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 and also output polygon should not have holes in it. Polygons are represented in counter-clockwise manner. What I mean is presented on a picture. As you can see even if there is a hole in union of polygons I dont need it in the output. Input polygons are for sure without holes. I think without holes it should be easier to do but still I dont have

How to draw a n sided regular polygon in cartesian coordinates?

懵懂的女人 提交于 2019-11-28 04:33:32
I have been trying to figure out how to write a simple program to compute the x,y points for creating a regular polygon of n sides. Can someone give me some code examples that don't use preexisting functions that draw polygons? I want to understand the process, which I assume is something like this: pick an angle to start from a radius and a center point somehow calculate the x,y position at that distance from the center(how?) divide 360 by the number of sides, move that distance and draw the next line from the first x,y point continue until the angle=360 divided by that number. Assuming that

Algorithm to generate random 2D polygon

僤鯓⒐⒋嵵緔 提交于 2019-11-28 03:57:20
I'm not sure how to approach this problem. I'm not sure how complex a task it is. My aim is to have an algorithm that generates any polygon. My only requirement is that the polygon is not complex (i.e. sides do not intersect). I'm using Matlab for doing the maths but anything abstract is welcome. Any aid/direction? EDIT: I was thinking more of code that could generate any polygon even things like this: There's a neat way to do what you want by taking advantage of the MATLAB classes DelaunayTri and TriRep and the various methods they employ for handling triangular meshes. The code below follows

How to attach a simple data.frame to a SpatialPolygonDataFrame in R?

南笙酒味 提交于 2019-11-28 03:56:54
I have (again) a problem with combining data frames in R. But this time, one is a SpatialPolygonDataFrame ( SPDF ) and the other one is usual data.frame ( DF ). The SPDF has around 1000 rows the DF only 400. Both have a common column, QDGC Now, I tried oo <- merge(SPDF,DF, by="QDGC", all=T) but this only results in a normal data.frame, not a spatial polygon data frame any more. I read somewhere else, that this does not work, but I did not understand what to do in such a case (has to do something with the ID columns, merge uses) oooh such a hard question, I quess... Thanks! Jens Let df = data