spatial-query

What is the best way to query a database for records within n miles of a zip code?

I have a list of records in my database and each record is associated with a zip code. What is the "best-practice" for querying all the records in my database to find all entries that are within n miles of another zip code? Each zip code has a lat/long associated with it in the database so I know I'll have to use that. However, I can'...

Spatial Index Query in php

I'm trying to write a query in PHP for a spatial index. But I'm having trouble writing the query for the following line of code... SET @p = CONCAT('Polygon((',lat1,'',lon1,',',lat1,'',lon2,',',lat2,'',lon2,',',lat2,'',lon1,',',lat1,'',lon1,'))'); ...

Possible to calculate closest locations via lat/long in better than O(n) time?

I'm wondering if there is an algorithm for calculating the nearest locations (represented by lat/long) in better than O(n) time. I know I could use the Haversine formula to get the distance from the reference point to each location and sort ASC, but this is inefficient for large data sets. How does the MySQL DISTANCE() function perform...

Best Performance-Critical Algorithm for Solving Nearest Neighbor

We have a list of x,y pairs. Every pair represents a point on a 2D space. I want to find the closest point from this list, to a specific point xq,yq. What is the best performance-critical algorithm for this problem? Lisp of points is not going to change; which means I do not need to perform insertion and deletion. I want just to find the...

your favorite database for spatial temporal ?

hi, what is your favorite database for supporting of spatial temporal issues ? sql server 2008 has data types for spatial temporal data. please post your experience with sql server 2008, oracle spatial, post gis .... . licence cost does not matter here. apps anything like that: Suppose that we are interested in monitoring a city to s...

Linq & unsupported data types (Geography)

So, Linq does not support the Geography data type, which throws a major spanner in the works in the lovely 'drag table onto the Linq design surface' developemnt model. Is there any way that I can extend Linq to work with the Geography datatype? Or will I need to build a whole new datalayer and set of queries for whenever I need to use G...

How does SqlGeography.Reduce method works?

How does this API works? I am using some complex geography with ~2000 points (geometry of a river). While reducing with tolerance 2048, it works fine. But while reducing with tolerance factor 4096, it throws exception "24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each ...

MySQL Spatial search for HSV (color) values?

Is it possible to use MySQL's spacial search to find points inside of a 3D polygon? Or better still, is it possible to use MySQL to find the values on the surface of an HSV cylinder? ...

how to get nearest point on a SqlGeometry object from another SqlGeometry object?

I have a set of line and polygon object (SqlGeometry type) and a point object (SqlGeometry type). How can we find the the nearest point on each line from the given point object? Are there any API for doing this operation? ...

ibm informix spatial datablade select statement error

Hi I am using IBM informix spatial datablade module for some geo specific data. I am trying to find points in table xmlData lying in a specified region. But i am getting this error for select statement. SELECT sa.pre, sa.post FROM xmlData sa WHERE ST_Contains(('polygon((2 2,6 2,6 6,2 6,2 2)),sa.point) Query: select count(*) ...

IBM Informix Spatial datablade LIneFromText function

Hi Everybody, I am using IBM-Informix for my school project as part of "Informix on-campus" ativity conduted by IBM. however it is giving me error as "(USE31) - Too few points for geometry type in ST_LineFromText.", in the second linefromtext function. ...

Query to find shortest route in Oracle

Hello, fellow developers. I'm starting studies in Oracle 11g Spatial Databases and I want to know if is there a query that returns the shortest route (or path) between two points, or between a point and a linestring. I have a map with some linestring (hiking trails) and Polygons (geographic accidents) and I want to find the shortest ro...

Selecting a good SQL Server 2008 spatial index with large polygons

I'm having some fun trying to pick a decent SQL Server 2008 spatial index setup for a data set I am dealing with. The dataset is polygons, representing contours over the whole globe. There are 106,000 rows in the table, the polygons are stored in a geometry field. The issue I have is that many of the polygons cover a large portion of t...

Unable to retrieve computed distance in Spatial Solr queries

I'm using this plugin to allow spatial queries in Solr. I have followed the steps included in the documentation and I've got the spatial queries working fine. Now I want to retrieve the computed distance. I added these lines in the solrconfig.xml file: <searchComponent name="geodistance" class="nl.jteam.search.solrext.spatial.GeoDistan...

Data structure in python for 2d range counting queries

Hi, I need a data structure for doing 2d range counting queries (i.e. how many points are in a given rectangle). I think my best bet is range tree (it can count in log^2, or even log after some optimizations). Does it sound like a good choice? Does anybody know about a python implementation or will I have to write one myself? ...

Spatial querying, converting metres to radians?

I have geographic data that was loaded into the geography datatype. For very specific purposes, I now need to have store this as a geometry. However, I need to perform a query like this. DECLARE @radius INT -- e.g. 3000 metres DECLARE @geo geometry -- my starting shape SET @geo = @geo.STBuffer(@radius) -- this obviously doesnt work.. ...

Database procedure for locations

Hi, I'm trying to store a database of GPS locations and run queries which find the points within a given radius and also the closest points. I'm using mysql and have been looking at the spatial extensions. I am not sure if i see how to actually use the spatial extensions to do what I'm looking for in the location radius queries. So h...

How do you use MySQL spatial queries to find all records in X radius?

I have a table in a MySQL database with a spatial geometry column of type POINT. I'd like to be able to take a point at the center of a map and find all records within X miles (or whatever distance) of it. I can't seem to find a good example or explanation of how to do this that doesn't get heavily into geometric math. I'm happy to go th...

How to implement Spatial(Geo-Location) searching in Grails?

Hi, I am working on Grails 1.3.2 with MySql. I need to store the latitude and longitude of certain locations in the database and then on the basis of the user's current location, I need to return the items that are within a particular radius of that location. So, we basically have the following requirements: Search for places with-in ...

Uniform Grid Subdivision of Points in C#

Hello, I have a set P of 2D points that I could like to cluster in a 2D uniformly spaced grid, where each cell is length X. I want to do this because I am trying to create a heat map, and I have way to much information so I am hoping by clustering the points into a uniformly spaced grid I can just report the final count of each grid. ...