geospatial

kdtree for geospatial point search

℡╲_俬逩灬. 提交于 2019-12-04 22:02:16
I'm attempting to find nearest neighbors for point geometry with latitude and longitude information available to me. After much search I concluded that using a kd-tree based approach would be the best option. I have so far tried three different approaches with kd-tree, none of which have worked. Using mercator (UTM) projections. This was least useful as the distance calculation turned out to be completely wrong particularly since the points are spread all over the globe. Using latitude and longitude system of co-ordinates itself. KdTree alternates between lat and long for splitting plane. This

Improving performance of spatial MySQL query

谁都会走 提交于 2019-12-04 17:55:13
I have a query that returns all records, ordered by distance from a fixed point, compared to a POINT field in my MySQL 5.7 database. For a simple example, lets say it looks like this: SELECT shops.*, st_distance(location, POINT(:lat, :lng)) as distanceRaw FROM shops ORDER BY distanceRaw LIMIT 50 My actual query also has to do a few joins to get additional data for the results. The issue is, that in order to sort the data by distance, it needs to calculate the distance over every single record in the database (currently around 100,000 records). I can't cache the query, as it would only be

Why is geosearching/location based searches returning zero results?

徘徊边缘 提交于 2019-12-04 17:48:29
I am trying to use app engine's search API to search locations: https://developers.google.com/appengine/docs/python/search/overview#Performing_Location-Based_Searches The problem is no matter what I do, I get zero results. I set the search lat/lng as the the exact point on a document's GeoPoint property and it still returns zero. I know the regular search is working because if I change the query to be a regular full-text search, it works. Here is an example of my data (this is actually from the example app here: http://www.youtube.com/watch?v=cE6gb5pqr1k ) Full Text Search > stores1 Document

MongoDB Geospatial Query Count Issue (Always 100)

对着背影说爱祢 提交于 2019-12-04 17:45:49
It appears there is an issue with the count operation on a geospatial query that contains more than 100 results. If I run the following query I still get a count of 100 no matter what. db.locations.find({"loc":{$nearSphere:[50, 50]}}).limit(1000).count() I understand that the default size limit on a query that uses the "near" syntax is 100 but it appears you cannot return more than that. Am I doing something wrong or is there a workaround for this? Try "within" instead of "near". This works for me, center = [50, 50]; radius = 1/111.12; //convert it to KM. db.places.count({"loc" : {"$within" :

Error : increasing 'x' and 'y' values expected in persp {fields}

左心房为你撑大大i 提交于 2019-12-04 16:46:30
I have 500 points in space with lat , lng as : lng=runif(100,1,4) lat=runif(100,40,40.1) Let's say that we have there (density) as z=rnorm(1000) I've tried to plot 3d surface using persp persp(lng,lat,z) But I have this error : Error : increasing 'x' and 'y' values expected I sorted x and y using data=data.frame(lng,lat) data=data[ order(data[,1],data[,2]), ] And I tried again persp(data[,1],data[,2],z) But I still have the same problem. How can I do it ? Thank you. The problem is the argument z and the ordering of both x and y . As shadow mentions in the comments this needs to be a matrix of

Is there a convenient way to create spatial index with Sqlalchemy or Geoalchemy?

我怕爱的太早我们不能终老 提交于 2019-12-04 16:21:19
Yesterday someone told me that Geoalchemy was a good choice to support spatial extensions if I want to use Sqlalchemy. It really did good. Thanks for him a lot. But I have not found a convenient way to create spatial index with Geoalchemy. Must I run this SQL directly? CREATE SPATIAL INDEX sp_index ON my_class ( geom_col ); Is there a convenient way to do it without directly writing the SQL? Thanks! When creating a table with table.create() GeoAlchemy will automatically create an index for the geometry column. Also, SQLAlchemy Index instances have a create method. See the "Indexes" section in

Geography data type vs. Geometry data type in SQL Server

♀尐吖头ヾ 提交于 2019-12-04 15:51:40
Environment: SQL Server 2012 I'm using an online tool, the only one I could find so far, to plot polygons and points on the earth. http://www.birdtheme.org/useful/googletool.html I have two tables. One stores "areas" as polygons and the other table stores points amongst other things irrelevant to my question. For simplicity, I'll just reduce my scenario to sql variables. In the query below, I'm using the geography data type for well known points of interest. I drew a polygon around Robben Island, a point in Robben Island and a point in Alcatraz. DECLARE @robben_island geography = ('POLYGON((18

Filter Documents by Distance Stored in Document with $near

∥☆過路亽.° 提交于 2019-12-04 15:20:12
I am using the following example to better explain my need. I have a set of points(users) on a map and collection schema is as below { location:{ latlong:[long,lat] }, maxDistance:Number } i have another collection with events happening in the area. schema is given below { eventLocation:{ latlong:[long,lat] } } now users can add their location and the maximum distance they want to travel for to attend an event and save it. whenever a new event is posted , all the users satisfying their preferences will get a notification. Now how do i query that. i tried following query on user schema { $where

combine geoNear query with another query for a value

℡╲_俬逩灬. 提交于 2019-12-04 15:12:30
I have an api for geo data realised with node.js mongodb and mongoose. I want to query my data with two criteria. First i use geoNear to get all locations in a given radius which works fine. Second i want to filter the locations further by its type. This is my schema: var GeoLocationSchema = new Schema({ name: String, type: String, loc: { type: { type: String, required: true, enum: ["Point", "LineString", "Polygon"], default: "Point" }, coordinates: [Number] } }); // ensure the geo location uses 2dsphere GeoLocationSchema.index({ loc : "2dsphere" }); and this is my geoNear query: router.route(

Geospatial Indexing with Redis & Sinatra for a Facebook App

匆匆过客 提交于 2019-12-04 14:50:17
I'm rebuilding Lovers on Facebook with Sinatra & Redis, and I want: Set operations for managing requests & relationships between users Geospatial indexing to display nearby app users Current Redis Implementation Each user has two Redis ordered sets ( reqSent & reqRecv ) that store uids. The SCORE that we order the requests by is the time (UNIX timestamp) the request was made. I am using ordered sets instead of lists because a user may only make The request type (rid) is encoded as a number and prepended to the uid. (rid|uid) E.g., for the user with uid=100, we might have: 100:reqSent => ["1