geospatial

Mysql within distance query

半腔热情 提交于 2019-12-19 03:25:25
问题 Options $lat = '25.7742658'; $lng = '-80.1936589'; $miles = 30; Query SELECT *, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < $miles ORDER BY distance LIMIT 0, 20 I have a database table with 4 columns: unique id city name latitude (lat) longitude (lng) I'm using the query on top to return locations that are within a specified number of miles

MongoDB geospatial difference between $near and $within

三世轮回 提交于 2019-12-18 17:27:37
问题 What is the difference between $near and $within ? db.geodata.find({ "loc" : { "$within" : { "$center" : [ [ 12.91365 , 77.59395] , 4]}}}).limit(10); db.geodata.find({ "loc" : { "$near" : [ 12.91365 , 77.59395] , "$maxDistance" : 4}}).limit(10); Can anyone explain in detail? 回答1: The main differences are $near sorts based on distance from a point; $geoWithin tests for containment in a polygon or multipolygon with GeoJSON coordinates, or containment in one of a set of shapes for 2d coordinates

d3 US state map with markers, zooming transform issues

北城以北 提交于 2019-12-18 16:31:17
问题 I've created a d3 map with US states, following this example: http://bl.ocks.org/mbostock/4699541 and added markers following this SO question: Put markers to a map generated with topoJSON and d3.js The problem is that on zoom, the map markers stay in place. I believe I need to translate them into a new position, but not sure how to make that happen. var width = 900, height = 500, active = d3.select(null); var projection = d3.geo.albersUsa() .scale(1000) .translate([width / 2, height / 2]);

Find most recent & closest posts, limit 20

老子叫甜甜 提交于 2019-12-18 16:21:51
问题 Let's say I have a bunch of posts (for a feed, like a Twitter/Facebook/foursquare feed) in MongoDB, and each post has a location & a timestamp. What's the best way to get the most recent & closest posts, limited to 20 posts? This is also a subjective question. Let's say that you can specify $maxDistance and the max time since now (I'm not sure how you'd do it otherwise.). How would you specify them? Would you sort by most recent or closest, or keep it random or sort some other way? Which

Convert lat/lon to zipcode / neighborhood name

时光毁灭记忆、已成空白 提交于 2019-12-18 13:27:15
问题 I have a large collection of pictures with GPS locations, encoded as lat/lon coordinates, mostly in Los Angeles. I would like to convert these to (1) zipcodes, and (2) neighborhood names. Are there any free web services or databases to do so? The best I can come up with so far is scrape the neighborhood polygons from the LA times page and try to find out in which polygon every coordinate is. However this might be quite a lot of work, and not all of my coordinates are in LA. As for the

How do I calculate the Azimuth (angle to north) between two WGS84 coordinates

亡梦爱人 提交于 2019-12-18 11:11:50
问题 I have got two WGS84 coordinates, latitude and longitude in degrees. These points are rather close together, e.g. only one metre apart. Is there an easy way to calculate the azimuth of the line between these points, that is, the angle to north? The naive approach would be to assume a Cartesian coordinate system (because these points are so close together) and just use sin(a) = abs(L2-L1) / sqrt(sqr(L2-L1) + sqr(B2-B1)) a = azimuth L1, L2 = longitude B1, B2 = latitude The error will be larger

Python module for storing and querying geographical coordinates

﹥>﹥吖頭↗ 提交于 2019-12-18 11:07:45
问题 Is there a Python module where I can create objects with a geographical location coordinate (latitude and longitude), and query all the objects for ones which are within a 5km distance (i.e. radius) of a given coordinate? I've been trying to store the latitude and longitude as keys in dictionaries (as they're indexed by key) and use some distance finding algorithms to query them. But this feels like a horrible hack. Essentially something like PostGIS for PostgreSQL, but all within my Python

Selecting a good SQL Server 2008 spatial index with large polygons

若如初见. 提交于 2019-12-18 10:55:26
问题 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 the globe. This seems to make it very hard to get a spatial index that will eliminate many rows in the primary filter. For example, look at the following query:

Determining the distance between two ZIP codes (alternatives to mapdist)

好久不见. 提交于 2019-12-18 10:36:16
问题 I want to calculate the distance between approx. 100,000 different ZIP codes. I know about the mapdist function in the ggmap package mapdist works perfectly: library(ggmap) mapdist('Washington', 'New York', mode = 'driving') # from to m km miles seconds minutes hours # 1 Washington New York 366284 366.284 227.6089 13997 233.2833 3.888056 mapdist('20001', '10001', mode = 'driving') # from to m km miles seconds minutes hours # 1 20001 10001 363119 363.119 225.6421 13713 228.55 3.809167 However,

Geospatial Analytics in Python

£可爱£侵袭症+ 提交于 2019-12-18 09:38:53
问题 I have been doing some investigation to find a package to install and use for Geospatial Analytics The closest I got to was https://github.com/harsha2010/magellan - This however has only scala interface and no doco how to use it with Python. I was hoping if you someone knows of a package I can use? What I am trying to do is analyse Uber's data and map it to the actual postcodes/suburbs and run it though SGD to predict the number of trips to a particular suburb. There is already lots of data