Questions tagged [spatial-query]

a special type of database query on geodata

A spatial query is a special type of database query supported by geodatabases and spatial databases.

Unlike non-spatial SQL queries, these queries use geometry data types such as points, lines and polygons and they consider the spatial relationship between these geometries.

Implementations vary between databases, for instance by adding an extension like for PostgreSQL or using a planar spatial data type like geometry in Microsoft SQL Server.

416 questions
13
votes
3 answers

What is a good data structure for storing and searching 2d spatial coordinates in Java

I am currently writing a plugin for a game where one feature includes the ability to set areas defined by 2 two dimensional coordinates ( The upper left and lower right areas of a rectangle). These regions are then to be stored, and will have…
Sethcran
  • 153
  • 1
  • 5
12
votes
1 answer

Find if a POINT is inside a POLYGON in MySQL 5.7

I need to find all properties that are contained in a user searched location; a location can be a city, county etc. Every property has a lat and long which can be used to create a POINT in MySQL. The locations are of type GEOMETRY, most of them are…
Gorjan Mishevski
  • 182
  • 3
  • 10
12
votes
4 answers

Spatial Datatype (geometry) to GeoJSON

I want to convert geom (geometry) datatype to GeoJSON. How could I do that? For example, the geometry in WKT: POLYGON((455216.346127297 4288433.28426224,455203.386722146 4288427.76317716,455207.791765017 4288417.51116228,455220.784166744…
12
votes
3 answers

Selecting a good SQL Server 2008 spatial index with large polygons

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…
12
votes
2 answers

SQL Geometry find all points in a radius

I am fluent in SQL but new to using the SQL Geometry features. I have what is probably a very basic problem to solve, but I haven't found any good resources online that explain how to use geometry objects. (Technet is a lousy way to learn new…
Roger Hill
  • 3,677
  • 1
  • 34
  • 38
9
votes
3 answers

how do I cluster a list of geographic points by distance?

I have a list of points P=[p1,...pN] where pi=(latitudeI,longitudeI). Using Python 3, I would like to find a smallest set of clusters (disjoint subsets of P) such that every member of a cluster is within 20km of every other member in the…
Lars Ericson
  • 1,952
  • 4
  • 32
  • 45
8
votes
2 answers

how do i create a circle Geometry with a radius and co-ordinates of center, using MySQL Spatial Extensions?

I am trying to create a Circle Geometry in MySQL using the co-ordinates of the center and a radius. I searched everywhere...all i could find in the MySQL doc on the site were for polygons. May be i am looking in the wrong place. can anybody help me…
user2052129
  • 231
  • 4
  • 11
7
votes
2 answers

How to implement Spatial(Geo-Location) searching in Grails?

I am working on Grails 1.3.2 with MySql. I need to store the latitude and longitude of certain locations in the database and then on the basis of the user's current location, I need to return the items that are within a particular radius of that…
Himanshu
  • 196
  • 1
  • 5
7
votes
2 answers

Spatial query using my SQL

I am writing from two varChar formatted columns named 'lattitude' and 'longitude' to a Point formatted column named 'coordinate' using the statement below. "UPDATE table_name SET coordinate = PointFromText(CONCAT('POINT(',table_name.longitude,'…
Ben Pearce
  • 6,884
  • 18
  • 70
  • 127
6
votes
1 answer

Most efficient way to get points within radius of a point with sql server spatial

I am trying to work out the most efficient query to get points within a radius of a given point. The results do not have to be very accurate so I would favor speed over accuracy. We have tried using a where clause comparing distance of points using…
Luke Lowrey
  • 3,203
  • 3
  • 28
  • 40
6
votes
4 answers

What is the best way to query a database for records within n miles of a zip code?

I have a list of records in my database and each record is associated with a zip code. What is the "best-practice" for querying all the records in my database to find all entries that are within n miles of another zip code? Each zip code has a…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
6
votes
4 answers

Adding simple AND after JOIN kills performance

I have a table containing about 500 points and am looking for duplicates within a tolerance. This takes less than a second and gives me 500 rows. Most have a distance of zero because it gives the same point (PointA = PointB) DECLARE @TOL AS…
Land Surveyor
  • 99
  • 1
  • 7
6
votes
5 answers

Best Performance-Critical Algorithm for Solving Nearest Neighbor

We have a list of x,y pairs. Every pair represents a point on a 2D space. I want to find the closest point from this list, to a specific point xq,yq. What is the best performance-critical algorithm for this problem? Lisp of points is not going to…
6
votes
2 answers

Spatial queries on AWS SimpleDB

I would like to know what people suggest as efficient ways of doing a spatial query in an Amazon Web Services SimpleDB? By spatial query I mean finding objects in a given radius of a latitude and longitude.
user293895
  • 1,465
  • 3
  • 22
  • 39
5
votes
2 answers

Calculating the outer boundary of several Geometry objects in SQL Server 2008

I have lots of Polygons of datatype Geometry in SQL Server 2008. The image below shows how a select of all these Geometrys looks visualized. What I need to do is create a Polygon which represents the outer boundary of all these polygons. So I used…
Peter Bridger
  • 9,123
  • 14
  • 57
  • 89
1
2 3
27 28