point-in-polygon

MySql Geospatial bug..?

This question is for Mysql geospatial-extension experts. The following query doesn't the result that I'm expecting: create database test_db; use test_db; create table test_table (g polygon not null); insert into test_table (g) values (geomfromtext('Polygon((0 5,5 10,7 8,2 3,0 5))')); insert into test_table (g) values (geomfromtext('...

Adding a polygon directly in Geodjango/PostGIS

I'm messing around with Geodjango, and I just want to add a simple polygon field to a database and then run a point-in-polygon on it to to make sure everything is working okay. Here's my code in views.py: #adding a polygon pe = PolygonExample.objects.create(name="uk_polygon", poly="POLYGON((58.768200159239576, -12.12890625, 58....

Delete holes in a Polygon

I have a polygon determined by an Array of Points. This polygon is crossing itself making some holes in the polygon itself. My questions is: How can I omit this holes and just get the exterior points of the polygon? Or what will be the same and probably easier: Which Algorithm for checking if a point is inside a Polygon should I use t...

Calculate pixels within a polygon

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 slo...

Does this mySQL Stored Procedure Work?

Hi, I got the following stored procedure from http://dev.mysql.com/doc/refman/5.1/en/functions-that-test-spatial-relationships-between-geometries.html Does this work? CREATE FUNCTION myWithin(p POINT, poly POLYGON) RETURNS INT(1) DETERMINISTIC BEGIN DECLARE n INT DEFAULT 0; DECLARE pX DECIMAL(9,6); DECLARE pY DECIMAL(9,6); DECLARE ls...

Point of latitude and longitude inside a complex spherical polygon

Question What R package has a function that can determine if a coordinate is within a closed, complex spherical polygon (i.e., a point inside a polygon on Earth's surface)? Related Links JPL: Formulae and explanation Java: Spheres software SO: Point inside or outside polygon SO: Point straddling the meridian SO: Point in polygon hit ...

Border-Line Cases: MySQL Point-in_Polygon Function Results in Duplicates When the Point is on the Border

Hi, I'm using MySQL to pull lat longs from a database and check whether or not they are in a particular neighborhood. Everything works great, except if the point is on the border between two neighborhoods. Then, the point is included in both neighborhoods. It gets duplicated. What's the best way to handle points that are on borders? ...

Reading in polygons from a Object File Format (.off) file

Hi I need to read in a list of polygons from a Object File Format (.off) file (in c++). The format of .off files is basically like this: Header infomation x y z //co-ords for each vertex ... NVertices v1 v2 v3 ... vN //Number of vertices for each polygon, //followed by each vertex's index ... .off files all...

SciPy Create 2D Polygon Mask

I need to create a numpy 2D array which represents a binary mask of a polygon, using standard Python packages. input: polygon vertices, image dimensions output: binary mask of polygon (numpy 2D array) (Larger context: I want to get the distance transform of this polygon using scipy.ndimage.morphology.distance_transform_edt.) Can any...

Algorithm for fast point lookup and line of sight traversal

I'm putting together a small library that consumes Geographic Information System (GIS) data and allows for fast point in feature, point near feature, and line of sight queries. Much of this data will consist of big areal features with enormous numbers of vertices. An R Tree variant might work, though I wonder how those perform on the p...

Check whether or not a point is in a polygon (Google Maps API)

So I have a map here How can I, using Google Maps API, detect whether or not a given coordinate is within that polygon? Is that possible? Thanks in advance. ...

Retrieve set of rectangles containing a specified point

I can't figure out how to implement this in a performing way, so I decided to ask you guys. I have a list of rectangles - actually atm only squares, but I might have to migrate to rectangles later, so let's stick to them and keep it a bit more general - in a 2 dimensional space. Each rectangle is specified by two points, rectangles can ...