geospatial

Whats the fastest way to lookup big tables for points within radius MySQL (latitude longitude)

拥有回忆 提交于 2019-12-17 06:55:05
问题 Currently I have a few tables with 100k+ rows. I am trying to lookup the data like follows. SELECT *, SQRT(POW(69.1 * (latitude - '49.1044302'), 2) + POW(69.1 * ('-122.801094' - longitude) * COS(latitude / 57.3), 2)) AS distance FROM stops HAVING distance < 5 ORDER BY distance limit 100 But currently this method slows with high load. Some queries are taking 20+ seconds to complete. If anyone knows any better ways to optimize this would be great. 回答1: Well first of all if you have a lot of

Formulas to Calculate Geo Proximity

十年热恋 提交于 2019-12-17 04:11:24
问题 I need to implement a Geo proximity search in my application but I'm very confused regarding the correct formula to use. After some searches in the Web and in StackOverflow I found that the solutions are: Use the Haversine Formula Use the Great-Circle Distance Formula Use a Spatial Search Engine in the Database Option #3 is really not an option for me ATM. Now I'm a little confused since I always though that the Great-Circle Distance Formula and Haversine Formula were synonymous but

Magento geographical search and product recommendation

佐手、 提交于 2019-12-14 03:58:39
问题 I'm evaluating Magento for a travel company who will need to do product searches and recommendations based on geographical distance. The company is creating custom holiday packages based on various components (eg: accommodation, tours, restaurant vouchers, etc). These components potentially have overlapping locations (ie: a particular tour might be close enough to several hotels to be considered related to each of them). As a user builds up their custom package by adding stays at various

How can I plot a georeferenced dataset in R?

不打扰是莪最后的温柔 提交于 2019-12-13 20:01:09
问题 I have this gridded data that I want to plot on a US map: https://www.dropbox.com/s/9khcjgtv8ipo2u5/windspeed.txt?dl=0 library(ggplot2) library(RColorBrewer) library(rgdal) library(sp) library(maps) options(max.print=5.5E5) all_data = read.table("windspeed.txt",header = TRUE) res=0.01 #spacing of row and col coords pre-specified origin_lat_lon=c(24.55, -130) all_data$row=(all_data$row)*res+origin_lat_lon[1] all_data$col=(all_data$col)*res+origin_lat_lon[2] coords = cbind(all_data$col, all

Mongo group with geospatial condition

一世执手 提交于 2019-12-13 17:03:57
问题 I have an issue when I try to aggregate results with a geospatial condition : db.users.group({ reduce: function(obj, prev) { prev.sums = { y_levels: prev.sums.y_levels + obj.current_y_level, x_levels: prev.sums.x_levels + obj.current_x_level, count: prev.sums.count + 1 } }, cond: {current_position: { $near: [56.553823, 8.565619, 10]}}, initial: { sums: { y_levels: 0, x_levels: 0, count: 0 } } }); produces : uncaught exception: group command failed: { "errmsg" : "exception: manual matcher

Extract centroid of shape file object in R?

自闭症网瘾萝莉.ら 提交于 2019-12-13 16:44:17
问题 I have a shape file, uploaded at the following path: https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc I imported the data using the "read.shapefiles" function in "shapefiles" package: landuse<- read.shapefile("landuse") I now need to extract the lat/long centroids of all the shapes within the landuse object and add it to the landuse$dbf dataframe I tried two things: lu_df<-coordinates(landuse) lu_df<-SpatialPoints(landuse) Both gave me the following error: Error in coordinates(as

Cannot insert GeomFromText('POINT(..)') in MySQL

廉价感情. 提交于 2019-12-13 14:30:44
问题 I've created a database where one of the tables stores the geolocation of some points. I'm trying to fill that table, which a priori seems pretty easy with GeomFromText('POINT(39.48280 -0.34804)') , but it doesn't work. All the other columns, like id, name... do get their values, but the location column remains empty. So then I try to update the row I've just added with: UPDATE `pfc_db`.`poi` SET `location` = GeomFromText('POINT(39.48280 -0.34804)') WHERE id = 'poi00001'; And MySQLWorkbench

Allegrograph Geospatial Prolog Queries

与世无争的帅哥 提交于 2019-12-13 14:29:44
问题 I have some triples that represent the locations of several cities. I want to be able to fire off a Prolog query like (select (?x ?y ?dist) (q- ?x !exns:geolocation ?locx) (q- ?y !exns:geolocation ?locy) (geo-distance ?locx ?locy ?dist)) but I get this error: Server returned 400: attempt to call '#:geo-distance/3' which is an undefined function. I'd like to understand how to use the geospatial reasoning methods like geo-distance (I assumed it was built-in because they use it here. Is this not

How do I convert SRID 3857 to decimal degrees?

巧了我就是萌 提交于 2019-12-13 09:03:38
问题 How do I convert SRID 3857 formatted geometery coordinates into to decimal degrees? My current stack is SQL Server 2014 and C#. 回答1: You cannot convert them directly in SQL Server. Quite simply it wasn't built to reinvent the Reprojection of spatial data in one datum to another. When using SqlGeography, you can of course swap between SRIDs when both sets of coordinates use the same coordinate-type (decimal-degrees or grid-based), however when using SqlGeometry, they are simply planar

SQL-Server 2008 R2 geoSpatial query error for Circular String

徘徊边缘 提交于 2019-12-13 08:13:58
问题 SQL Spatial Features: SQL geometry Point, Linestring working well but the Circular string is not working. When i try to save the CircularString type data to my geometry datatype its throws the following error: My statement: DECLARE @g1 geometry = 'CIRCULARSTRING EMPTY'; "A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry": System.FormatException: 24114: The label CIRCULARSTRING EMPTY in the input well-known text (WKT) is not valid. Valid labels are