geography

Calculating Distance Between 2 Cities [closed]

独自空忆成欢 提交于 2019-11-29 21:05:18
How do you calculate the distance between 2 cities? Dana the Sane If you need to take the curvature of the earth into account, the Great-Circle distance is what you're looking for. The Wikipedia article probably does a better job of explaining how the formula works than me, and there's also this aviation formulary page that covers that goes into more detail. The formulas are only the first part of the puzzle though, if you need to make this work for arbitrary cities, you'll need a location database to get the lat/long from. Luckily you can get this for free from Geonames.org , although there

How to find nearest cities in a given radius?

限于喜欢 提交于 2019-11-29 13:25:53
问题 Do you know some utility or a web site where I can give US city,state and radial distance in miles as input and it would return me all the cities within that radius? Thanks! 回答1: Here is how I do it. You can obtain a list of city, st, zip codes and their latitudes and longitudes. (I can't recall off the top of my head where we got ours) edit: http://geonames.usgs.gov/domestic/download_data.htm like someone mentioned above would probably work. Then you can write a method to calculate the min

Radius of multiple latitude/longitude points

≯℡__Kan透↙ 提交于 2019-11-29 09:40:38
问题 I have a program that takes as input an array of lat/long points. I need to perform a check on that array to ensure that all of the points are within a certain radius. So, for example, the maximum radius I will allow is 100 miles. Given an array of lat/long (coming from a MySQL database, could be 10 points could be 10000) I need to figure out if they will all fit in a circle with radius of 100 miles. Kinda stumped on how to approach this. Any help would be greatly appreciated. 回答1: Find the

SQL Server 2008 GEOGRAPHY STDistance() value

蓝咒 提交于 2019-11-29 09:03:00
I am using geography.STDistance() to return the distance between two single point locations. I'm curious as to which measurement is used for the return value? Is it in KM's, miles or perhaps some other? I'm getting results back upwards of 250k but i've no idea if im doing something wrong with my TSQL as these are historical locations(i.e. they no longer exist) so I can't just do a quick lookup. declare @p1 geography declare @p2 geography SELECT @p1 = Location from tblLocations where Id = 1 SELECT @p2 = Location from tblLocations where Id = 2 select @p1.STDistance(@p2) I think the return

Moving a Point along a Path in SQL Server 2008

核能气质少年 提交于 2019-11-29 05:07:38
I have a geography field stored in my database, holding a linestring path. I want to move a point n meters along this linestring, and return the destination. For example, I want the destination point 500 meters along the linestring starting from its beginning. Here's an example -- what is the YourFunctionHere ? Or, is there another way? DECLARE @g geography; SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656, -122.310 47.690)', 4326); SELECT @g.YourFunctionHere(100).ToString(); Daniel Vassallo This is a little bit tricky, but it is certainly possible. Let's start

Convert geography to geometry SQL Server 2008R2

一世执手 提交于 2019-11-29 00:34:52
Hello, i have the following code in SQL Server, why if i want to calculate the sTArea of @geog fails and with @geom succeed?, how can i convert this polygon from geometry to geography datatype in order to get the STArea?, thank you. DECLARE @geom geometry; SET @geom = geometry::STGeomFromText('POLYGON ((-99.213546752929688 19.448402404785156, -99.2157974243164 19.449802398681641, -99.2127456665039 19.450002670288086, -99.213546752929688 19.448402404785156))', 4326); select @geom.STArea(); DECLARE @geog geography; SET @geog = geography::STGeomFromText('POLYGON ((-99.213546752929688 19

SQL 2008 geography & geometry - which to use?

风格不统一 提交于 2019-11-28 20:47:23
I'm creating a Google map mashup and am using SQL 2008. I will have a large number of points on the earth and will want to perform various calculations on them in SQL - such as selecting all points contained within a particular polygone, or select all points within 10km of XY. I have never used and SQL spatial features before. Should I use the geography or the geometry datatype for this? Geography is the type that is intended for plotting points on the earth. If you have a table that stores Google Maps points like this: CREATE TABLE geo_locations ( location_id uniqueidentifier NOT NULL,

NHibernate.Spatial and Sql 2008 Geography type - How to configure

人走茶凉 提交于 2019-11-28 17:34:37
I am trying to use Nhibernate with the Sql 2008 Geography type and am having difficulty. I am using Fluent Nhibernate to configure which I am fairly new to so that may be the problem as well. First, the class I am trying to persist looks something like: public class LocationLog : FluentNHibernate.Data.Entity { public virtual new int Id {get;set;} public virtual DateTime TimeStamp {get;set;} public virtual GisSharpBlog.NetTopologySuite.Geometries.Point Location {get;set;} } The mapping class looks like: public class LocationLogMap : ClassMap<LocationLog> { ImportType<GisSharpBlog

Python: speeding up geographic comparison

浪子不回头ぞ 提交于 2019-11-28 09:17:36
I've written some code that includes a nested loop where the inner loop is executed about 1.5 million times. I have a function in this loop that I'm trying to optimize. I've done some work, and got some results, but I need a little input to check if what I'm doing is sensible. Some background: I have two collections of geographic points (latitude, longitude), one relatively small collection and one relatively huge collection. For every point in the small collection, I need to find the closest point in the large collection. The obvious way to do this would be to use the haversine formula. The

SQL Server 2008 GEOGRAPHY STDistance() value

帅比萌擦擦* 提交于 2019-11-28 02:43:31
问题 I am using geography.STDistance() to return the distance between two single point locations. I'm curious as to which measurement is used for the return value? Is it in KM's, miles or perhaps some other? I'm getting results back upwards of 250k but i've no idea if im doing something wrong with my TSQL as these are historical locations(i.e. they no longer exist) so I can't just do a quick lookup. declare @p1 geography declare @p2 geography SELECT @p1 = Location from tblLocations where Id = 1