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
5
votes
1 answer

Do I need specific configuration for Spatialite with GeoDjango?

According to https://docs.djangoproject.com/en/1.3/ref/contrib/gis/db-api/, Spatialite supports GeoQuerySet.distance(). However, having imported an area list (MultiPolygon as mpoly attribute), I'm trying to do the…
Nikolai Prokoschenko
  • 8,465
  • 11
  • 58
  • 97
5
votes
2 answers

Querying SQL Server geospatial data from R

Edited: I have added login details to a demo SQL Server 2017. I am querying an SQL Server from R using the FreeTDS driver (preferred over the Microsoft odbc driver as it supports Windows authentication in Linux). I'm struggling to interpret the…
fifthace
  • 506
  • 1
  • 10
  • 33
5
votes
1 answer

Cannot call methods on bit

I am trying to check whether two geographic objects intersect and remove the overlapping parts (not doing this part in the code segment below). Please find the code below. It gives me error Cannot call methods on bit. I am using mssql library and…
Safeer Raees
  • 400
  • 2
  • 11
5
votes
2 answers

What ADO type is the Geography spatial type from SQL Server 2008?

I am looking to refactor this method (from Massive.cs by Rob Conery): public static void AddParam(this DbCommand cmd, object item) { var p = cmd.CreateParameter(); p.ParameterName = string.Format("@{0}", cmd.Parameters.Count); if (item…
Chaddeus
  • 13,134
  • 29
  • 104
  • 162
5
votes
1 answer

Need help to optimize potentially erroneous spatial SQL query

Update: Since writing this post we decided to migrate our geospatial data to an ElasticSearch database, which yielded better results. I'm new to SQL and I need help to optimize a spatial query so that it runs under in under 2 seconds. We have…
5
votes
2 answers

Mysql: ST_Contains with borders to detect if multipolygon contains point

I use mysql spatial functions. I have to understand if points lies withing multipolygon. Initially I used MBRContains but it works in a strange way, so I faced the following error: Mysql function MBRContains is not accurate My next step was…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
5
votes
0 answers

Find K Closest pairs in a spatial database (Without specific query object)

Input: • N points {P1, …. , Pn} - each point is from the same dimension t: Pi = {x_1, …., x_t} where k is between 18-30 . • Distance function – dist(Pi, Pj) - returns a number that is the distance between the points. (The function is a…
5
votes
1 answer

Spatial Intersect of two SQL Server layers/tables

I need to do a spatial intersection between two spatial tables with a geometry column in each within SQL Server 2016. I have a piece of T-SQL where I take a single set of polygons from one table (tableA), and then use each polygon and perform a…
user3047431
  • 91
  • 1
  • 4
5
votes
3 answers

LINQ to Entity does not support DbGeography conditions

I'm using .NET 4.5 and EF 6.0 (also tried with 6.1.3). I have Location geography column in an Entities table (System.Data.Entity.Spatial.DbGeography). using System.Data.Spatial; //also tried Entity one public class Entity { public DbGeography…
dr11
  • 5,166
  • 11
  • 35
  • 77
5
votes
1 answer

How do you use MySQL spatial queries to find all records in X radius?

I have a table in a MySQL database with a spatial geometry column of type POINT. I'd like to be able to take a point at the center of a map and find all records within X miles (or whatever distance) of it. I can't seem to find a good example or…
Preston Crawford
  • 330
  • 1
  • 5
  • 15
5
votes
2 answers

Getting list of spatial points from polygon within query

I have a database with various defined polygons which represent the outer boundarys of buildings on a map of a business park. If I perform a Select within Management Studio, I get a result similar to the following: LocationCode LocationPolygon 1 …
KingCronus
  • 4,509
  • 1
  • 24
  • 49
5
votes
2 answers

Linq & unsupported data types (Geography)

So, Linq does not support the Geography data type, which throws a major spanner in the works in the lovely 'drag table onto the Linq design surface' developemnt model. Is there any way that I can extend Linq to work with the Geography datatype? Or…
Mr. Flibble
  • 26,564
  • 23
  • 69
  • 100
5
votes
0 answers

View with geospatial and non geospatial keys with CouchDB

I'm using CouchDB and GeoCouch and I'm trying to understand if it were possible to build a geospatial index and "query" the database both by using a location and a value from another field. Data { "_id": "1", "profession": "medic", …
Dexter
  • 2,482
  • 27
  • 40
4
votes
1 answer

IsWithinDistance could not be translated

I'm trying to return a list of items that are within say 50 Miles of a given location. My table (simplified) is as follows: Id Longitude Latitude Status Active I've got an initial query: var query = db.MyTable.Where(o=> o.Status == "New" &&…
4
votes
1 answer

How to split polygons with overlapping polygons AND count overlaps in PostgreSQL?

I am trying to create an SQL query (PosgreSQL + PostGIS) on a single table that contains 1000’s of overlapping polygons (multi-part, some with holes) that will: . cut polygons into non-overlapping pieces, and for each piece . count how many times…
edaus
  • 179
  • 1
  • 1
  • 11
1
2
3
27 28