point-in-polygon

Mysql: ST_Contains with borders to detect if multipolygon contains point

穿精又带淫゛_ 提交于 2019-12-07 10:55:02
问题 I use mysql spatial functions. I have to understand if points lies withing multipolygon. Initially I used MBRContains but it works in a strange way, so I faced the following error: Mysql function MBRContains is not accurate My next step was switching to the functions ST_Contains . But I found out that if I use polygon(from multipolygon) vertex as argument - function returns false but I want to unclude all multipolygon borders. P.S. I found that where are function: ST_Touches(g1, g2) Two

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

POSTGIS: find all the points within a polygon

醉酒当歌 提交于 2019-12-06 04:08:18
I have a table containing point CREATE TABLE Points { pointID BIGSERIAL PRIMARY KEY NOT NULL, thePoint GEOGRAPHY(POINT) } CREATE TABLE Polygons { polygonID BIGSERIAL PRIMARY KEY NOT NULL, aPolygon GEOGRAPHY(POLYGON) NOT NULL, } I wish to find all the points that are contained in each polygon. i.e the result should look like polygonID| pointID ------------------- 1 | 1 1 | 2 1 | 5 1 | 7 2 | 2 2 | 3 ... I managed to go point by point and to figure out if it's in the polygon using ST_CoveredBy(thePoint, aPolygon) . Based on that the naive solution is going in a nested loop over all points and

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

给你一囗甜甜゛ 提交于 2019-12-06 02:23:30
问题 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

Search a table for Point in Polygon using MySQL

谁说我不能喝 提交于 2019-12-04 12:21:21
问题 I have create a table (municipal_border), in MySQL 5.5, that holds some boundaries. CREATE TABLE `municipal_border` ( `boundary` polygon NOT NULL, `municipalID` int(10) NOT NULL, ) ENGINE=InnoDB The field municipalID is not unique. I'm using the code below to test if a point belongs into a polygon. set @r = (SELECT municipal_border.boundary FROM municipal_border WHERE municipalID=9001); set @p = GeomFromText('POINT(24.1621 41.0548)'); select if(contains(@r, @p), 'yes', 'no'); The first

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

How to check if point is in polygon in Javascript

有些话、适合烂在心里 提交于 2019-12-03 20:23:39
I came across this piece of C code (i think) that's supposed to be a neat way to check if a point is within a (concave or convex) polygon and want to use it in my JS program: int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy) { int i, j, c = 0; for (i = 0, j = nvert-1; i < nvert; j = i++) { if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) ) c = !c; } return c; } nvert: Number of vertices in the polygon. Whether to repeat the first vertex at the end. vertx, verty: Arrays containing the x-

shapely and matplotlib point-in-polygon not accurate with geolocation

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 13:00:11
问题 I am testing the point-in-polygon function with matplotlib and shapely. Here is a map contains a Bermuda triangle polygon. Google maps 's point-in-polygon functions clearly shows testingPoint and testingPoint2 are inside of the polygon which is a correct result. if I test the two points in matplotlib and shapely, only point2 passes the test. In [1]: from matplotlib.path import Path In [2]: p = Path([[25.774252, -80.190262], [18.466465, -66.118292], [32.321384, -64.75737]]) In [3]: p1=[27

geopandas point in polygon

你说的曾经没有我的故事 提交于 2019-12-03 07:34:30
问题 I have a GeoDataFrame of polygons (~30) and a GeoDataFrame of Points (~10k) I'm looking to create 30 new columns (with appropriate polygon names) in my GeoDataFrame of Points with a simple boolean True/False if the point is present in the polygon. As an example, the GeoDataFrame of Polygons is this: id geometry foo POLYGON ((-0.18353,51.51022, -0.18421,51.50767, -0.18253,51.50744, -0.1794,51.50914)) bar POLYGON ((-0.17003,51.50739, -0.16904,51.50604, -0.16488,51.50615, -0.1613,51.5091)) The

Mysql function MBRContains is not accurate

亡梦爱人 提交于 2019-12-03 06:28:42
I have the following POLYGON (in the image you can see the area it covers) POLYGON((-74.05100448502202 4.7239278424321,-74.05092938316898 4.7241416902206,-74.04830618275201 4.7237460717602,-74.04643668306903 4.7234306460692,-74.04635688735101 4.7234105978214,-74.04636526925401 4.7233310730989,-74.046191260944 4.72327293317,-74.04579027069599 4.7232007594583,-74.04141290558402 4.7214258184083,-74.03746201170497 4.7197791822891,-74.03565688503801 4.7189879401666,-74.033484295736 4.7180897723398,-74.03098447693401 4.7170526009038,-74.028731840457 4.7161167561787,-74.02852820211899 4.7150714370973