## geospatial

### SQL Server 2008 Geospatial queries

SQL Server 2008 has new geo data types. One thing I am wondering though is that if I have a table with geocoded addresses in it, can I write a query to display all records within a certain distance. For example, many websites have the option to search for items within a certain distance such as 50 miles and would like it if SQL 2008 prov...

### Lat/Lon + Distance + Heading --> Lat/Lon

Hello... So: I have the following function, adapted from a formula found online, which takes two lat/lon coordinates and finds the distance between them in miles (along a spherical Earth): public static double distance (double lat1, double lon1, double lat2, double lon2) { double theta = toRadians(lon1-lon2); lat1 = toRadians...

### Geospatial coordinates and distance in kilometers... (updated again)

This is a followup to this question. I seem to be stuck on this. Basically, I need to be able to convert back and forth to referring to coordinates either in the standard degree system OR by measuring a distance north from the south pole along the international date line, and then a distance east starting from that point on the date li...

### With SQL 2008 spatial functions, how can I construct a LINESTRING representing the line between two (or more) POINT instances?

Define a couple of points as follows: declare @p1 geography, @p2 geography set @p1 = 'POINT(1 2)' set @p2 = 'POINT(6 8)' Now I'd like to obtain the shortest line between these two points. What function can I use to get this line? (i.e., it should output a LINESTRING(1 2, 6 8) or LINESTRING(6 8, 1 2)) I know I could do this by formatt...

### How best to perform corridor range search over a set of latitude / longitude coordinates

Hi, What would be the best approach to finding the set of coordinates, from say about 5,00, which lie within a path of points, given a specified width. eg an aircraft following several waypoints. Is there a good way to also sort them in the same order as the route. Calculation speed would be more important than accuracy, since I'm l...

### Which algorithm can efficiently find a set of points within a certain distance of a path?

Given a set of points s (a set of x,y coordinates) and a path that is made up of line segments joining a set of points l, describe an efficient algorithm that can be used to find a subset of points from s that are within the specified distance d of the path l. A practical application of this may be to find a list of restaurants within 1...

### An effective algorithm for buffering a polyline to create a polygon?

I need to write some code that will buffer a line to create a polygon as shown below. http://www.sli.unimelb.edu.au/gisweb/BuffersModule/Buff_line.htm From following the steps outlined, I can create polygon shapes around simple lines that do not cross themselves or have too tight curves, but as the lines I'm trying to buffer are squigg...

### Regex to strip lat/long from a string

Anyone have a regex to strip lat/long from a string? such as: ID: 39.825 -86.88333 ...

### MS SQL Server 2008 Spatial Indexing - Does it work?

Has anyone tried using it and can say if it's well implemented? -- Assaf (who spent the last few weeks getting increasingly frustrated with MySQL's deficient implementation of OpenGIS functions and is now considering switching to MSSQL) ...

### How can I do efficient range searching + counting with latitude/longitude data?

I'm working with a large set of points represented by latitude/longitude pairs (the points are not necessarily unique, there could be several points in the set that are at the same location). The points are stored in a database. What I need to do is figure out a way to efficiently perform a search to get the number of points that lie wi...

### In SqlServer 2008, how would I generalize multiple adjacent polygons?

When you have a table with a Geometry type field (or Geography), you can call the Reduce() function to have the shapes reduced in number of vertices. Works very nicely. However, when sevral of the polygons are adjacent (they share parts of their borders), the reduced polygons do not necessarily do so. Example The SQL batch: CREATE TA...

### Heightmap generation algorithm?

I was looking around the internet and couldn't find a perfect algorithm for this particular problem: Our customer have a set of points and weight data along with each point as can be demonstrated by this image: Of which, we have a GIS program that could generate a "heightmap" or a sort of terrain data from these points and their weig...

### looking for good geospatial library

What's a good library for geospatial functions? I mean things like distance between two points on the globe coordinates of a circle of a given radius from a particular point etc. Bonus if there's an interface to the various ways different databases represent geolocations. I'm a geo-noob (in case this question didn't make it obvious...

### In Oracle Spatial (SDO), is there a way to get the centroid point of a polygon that is contained by the surface of the polygon?

I need to find the centroid of a polygon in Oracle Spatial that exists inside of the polygon itself. I cannot use the sdo_geom.sdo_centroid method because this returns a point outside of the shape if the shape resembles a horseshoe. I found sdo_geom.sdo_pointonsurface method, but it returns a point that is just on the edge of the pol...

### Generating Geo-Referenced Images in C#

I want to create some heat-map style tiles to overlay over our base maps using Open Layers. Basically, I want to divide some some bounding box into a grid, and display each square of the grid using a different color based on how many points of a sample fall within that grid square. The technologies involved are C#, OpenLayers, SQL Serv...

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

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 ar...

### Are all SQL Geospatial implementations database specific?

My team is looking into geospatial features offered by different database platforms. Are all of the implementations database specific, or is there a ANSI SQL standard, or similar type of standard, which is being offered, or will be offered in the future? I ask, because I would like the implemented code to be as database agnostic as pos...

### Does PostgreSQL implement Geospatial relationship queries?

My company is looking at different database providers, and how they implement Geospatial queries to get distances from a Lat/Long for a number of records. We are going to investigate PostgreSQL as a potential database platform. I've heard that PostGRE implements Geospatial queries. Is this correct? Is there a good reference somewhere...

### There are spatial data features for MS Sql Server 2005?

I wonder if there is any optimization I can do to achieve faster SELECTs for spatial data without moving to SQL SERVER 2008. There is for SQL Server 2005, natively or through plugins, any of the features below? Spatial field types Spatial indexes Arcsin math function for surface distance calculation on a sphere (Earth) ...

### What is the most efficient way to work with distances between two coordinates?

I have 2063 locations stored in a mysql table. In one of my processes I need to exclude certain results based on how far away they are from a given point of origin. The problem is, I will need to filter a couple of hundred, maybe a couple of thousand results at a time. So what would be the best way to do the distance math. Should I do i...