geospatial

Create & Find GeoLocation in mongoose

為{幸葍}努か 提交于 2019-12-03 09:14:54
问题 I'm trying to save the longitude/latitude of a location in my user Model and query it with $geoNear . I've looked at almost any page I could find on that topic, but still I'm not sure how to 1) create the model appropriately and how to query it. here's the part of my model: loc: { //type: 'Point', // see 1 //type: String, // see 2 coordinates: [Number], index: '2dsphere' // see 3 }, @1: According the documentation the type must be 'Point' if I want to store a point, but it throws TypeError:

Spatial index/query (finding k nearest points)

孤人 提交于 2019-12-03 09:02:58
I have +10k points (latitude, longitude) and I'm building an app that shows you the k nearest points to a user's location. I think this is a very common problem and I don't want to reinvent the wheel. I'm learning about Quadtrees. It seems to be a good approach to solve this spatial problem. I'm using these tools: Python 2.5 MySQL MongoDb Building the Quadtree is not that hard: http://donar.umiacs.umd.edu/quadtree/points/pointquad.html But once I've created the tree and saved it to a db (MySQL or MongoDb), how I run the query? I need to run queries like these: Find all points within 10 km of

MySQL INSERT/UPDATE on POINT column

不羁岁月 提交于 2019-12-03 08:22:59
I'm trying to populate my DB with geographical places of my country. One of my tables have 4 fields: ID[PK], latitude. longitude ande geoPoint EDIT `SCDBs`.`Punto_Geografico`; SET @lat = 18.469692; SET @lon = -63.93212; SET @g = 'POINT(@lat @lon)'; UPDATE Punto_Geografico SET latitude = @lat, longitude =@lon, geoPoint =@g WHERE idpunto_geografico = 0; im getting the following error: Error Code: 1416 Cannot get geometry object from data you send to the GEOMETRY field I'm pretty sure that 'geoPoint' field is a POINT field with a spatial index. Am i missing anything.14 Marc B Try doing it without

Find N Nearest LineString From A Point Using MySQL Spatial Extensions

你说的曾经没有我的故事 提交于 2019-12-03 08:02:36
I'm using MySQL Spatial Extensions to store data about roads and hotels. I store the hotel data as a Point while I store the road data as LineString. The tables look like this CREATE TABLE IF NOT EXISTS `Hotels` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `name` text, `coordinate` point NOT NULL, PRIMARY KEY (`id`), SPATIAL KEY `coordinate` (`coordinate`), ) CREATE TABLE IF NOT EXISTS `Roads` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `name` text, `route` linestring NOT NULL, PRIMARY KEY (`id`), SPATIAL KEY `coordinate` (`route`), ) The visualization of an instance would be like this. My

MongoDB Geospacial Query Spheres Overlapping Single Point

老子叫甜甜 提交于 2019-12-03 07:44:36
I am trying to create a geospacial query in MongoDB that finds all circles (with varying radius) that overlap a single point. My data looks something like this: { name: "Pizza Hut", lat: <latitude> lon: <longitude> radius: 20 ... } Basically, I am trying to do exactly what is described in this SO post but with MongoDB - Get all points(circles with radius), that overlap given point geoIntersects ( http://docs.mongodb.org/manual/reference/operator/query/geoIntersects/ ) looks like what I need. But in my case, the lat, lon, and radius is stored with each mongodb document and is not a fixed radius

MongoDB Bound Queries: How do I convert mile to radian?

守給你的承諾、 提交于 2019-12-03 07:11:55
问题 I have a collection of stores with a geospacial index on the location propery. What I am trying to do is given the user's latitude, latitude and a search radius (mi), I want to return the list of stores that are within those parameters. I saw the following example on the MongoDB documentation (http://www.mongodb.org/display/DOCS/Geospatial+Indexing), but it looks like the distance is in radians. center = [50, 50] radius = 10 db.places.find({"loc" : {"$within" : {"$center" : [center, radius]}}

spatial clustering in R (simple example)

倾然丶 夕夏残阳落幕 提交于 2019-12-03 07:04:57
I have this simple data.frame lat<-c(1,2,3,10,11,12,20,21,22,23) lon<-c(5,6,7,30,31,32,50,51,52,53) data=data.frame(lat,lon) The idea is to find the spatial clusters based on the distance First, I plot the map (lon,lat) : plot(data$lon,data$lat) so clearly I have three clusters based in the distance between the position of points. For this aim, I've tried this code in R : d= as.matrix(dist(cbind(data$lon,data$lat))) #Creat distance matrix d=ifelse(d<5,d,0) #keep only distance < 5 d=as.dist(d) hc<-hclust(d) # hierarchical clustering plot(hc) data$clust <- cutree(hc,k=3) # cut the dendrogram to

Joins on spatial mysql indexes

冷暖自知 提交于 2019-12-03 06:49:06
I have two tables: one with points, the other with polys. CREATE TABLE `points` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `point` point NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM; CREATE TABLE `ranges` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `poly` polygon NOT NULL, PRIMARY KEY (`id`), SPATIAL KEY `poly` (`poly`) ) ENGINE=MyISAM; I want to join ranges to points on points inside polys. Queries look simple: SELECT * FROM points LEFT JOIN ranges ON MBRCONTAINS(poly, point) WHERE points.id = 2; This query works fast and uses indexes, part of explain: table | type | possible_keys

R_Extracting coordinates from SpatialPolygonsDataFrame

二次信任 提交于 2019-12-03 06:44:06
Is it only me who have the problem with extracting coordinates of a polygon from SpatialPolygonsDataFrame object? I am able to extract other slots of the object ( ID , plotOrder ) but not coordinates ( coords ). I don't know what I am doing wrong. Please find below my R session where bdryData being the SpatialPolygonsDataFrame object with two polygons. > bdryData An object of class "SpatialPolygonsDataFrame" Slot "data": ID GRIDCODE 0 1 0 1 2 0 Slot "polygons": [[1]] An object of class "Polygons" Slot "Polygons": [[1]] An object of class "Polygon" Slot "labpt": [1] 415499.1 432781.7 Slot "area

Create a SqlGeography polygon-circle from a center and radius

白昼怎懂夜的黑 提交于 2019-12-03 06:28:36
I would like to save a circle in a sql-server 2008 geography field, using c#. In c# I have a latitude, a longitude and a radius but I just can't find a way to calculate the polygon that would represent the circle and create a SqlGeography from it. I have tried to following function to create the polygon: private List<Coordinate> getCirclePoints(Coordinate center, int radius, int speed) //speed 1: draws 360 sides, 2 draws 180 etc... { var centerLat = (center.Latitude * Math.PI) / 180.0; //rad var centerLng = (center.Longitude * Math.PI) / 180.0; //rad var dist = (float)radius / 6371.0; //d =