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
2
votes
3 answers

Surface mesh triangles: query space within

I have a surface mesh of triangles. Assume, the surface mesh is closed. I intend to do a spatial query to figure out whether a space is within my surface mesh or not. Space unit can be represented by a bounding box, a voxel or any other spatial…
Megidd
  • 7,089
  • 6
  • 65
  • 142
2
votes
1 answer

SQL Server create centroid of a polygon inside of a polygon

I would like to create a centroid of a polygon (type geometry) such that the centroid falls inside of the polygon I have tried with function shape.STCentroid() which is creating the centroid but for my shape/polygon the centroid is falling outside…
2
votes
1 answer

How can i store geographic files such as shapefile (.shp) in SQL Server database?

I have some shapefiles with extension (.shp) in my pc. But I know that any single shapefile is composed of three mandatory files which are .shp, .shx and .dbf. These files are what makes a shapefile be recognised as shapefile. I want to write some…
user8820917
2
votes
2 answers

ST_Area() for latitude and longitude

I have a polygon that contains multiple coordinates in MariaDB: POLYGON((50.4668 -6.90665,51.73607 0.14657,55.3032 -4.52724,50.4668 -6.90665)) I want to calculate area of this polygon with MariaDB like this: SELECT…
Sky
  • 4,244
  • 7
  • 54
  • 83
2
votes
1 answer

Finding the index of all nearest elements in a table of (lat,long) coords, for given distance function

Given a specific lon and lat point c(lon, lat), and a table data that contains a list of lat and lon, we want to: calculate the distance between this point to all other lat and lon points in the data and return all points from the table that are…
2
votes
1 answer

How to calculate the nearest neighbor distance for 10000 points in a table

I am using PostgreSQL and I am using PostGIS extension. I am able to compare one point with this query: SELECT st_distance(geom, 'SRID=4326;POINT(12.601828337172 50.5173393068512)'::geometry) as d FROM pointst1 ORDER BY d but I want to compare…
luftgekuhltlover
  • 107
  • 1
  • 15
2
votes
0 answers

Alternative to Geometry.IsValidDetailed()

Is there an alternative method that I can use to get a detailed message on why a Geometry is invalid? Geometry.IsValidDetailed() is not available in SQL Server 2008 R2, so I need a work around to get this message. Here is an example: Using SQL…
Kyle B
  • 2,328
  • 1
  • 23
  • 39
2
votes
1 answer

What's the proper way to do a spatial join in Oracle?

Oracle has a table function called SDO_JOIN that is used to do join tables based on spatial relations. An example query to find what neighbourhood a house is in is something like this: select house.address, neighbourhood.name from…
all_ice
  • 65
  • 1
  • 6
2
votes
1 answer

Can I use direct SQL queries instead of using Nominatim or other geo decoders?

I looked at source code of Nominatim and it's look like that mostly of it's functionality is just preparing SQL query and formating it's result. And possible other geo(de)coders works in same way. Can I use direct SQL queries to get data from…
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
2
votes
1 answer

SQL Server PolyTab.GeometryCol.STContains(PointTab.GeometryCol) = 1 not Allowed

I have two basic tables with geometry column types in them. One has polygons and the other points, and I am trying to join them using the following basic query: Select dbo.PointTab.*, dbo.PolyTab.Name from dbo.PointTab Inner Join…
2
votes
3 answers

Inserting spatial data into MySQL database

I tried to insert data into point() datatype column from PHP this way: INSERT INTO table (coordinates) VALUES ("48.20 14.80"); or INSERT INTO table (coordinates) VALUES ("POINT(48.20 14.80)"); And then I applied triggers before every insert or…
KRiSTiN
  • 429
  • 1
  • 4
  • 11
2
votes
1 answer

Fastest way of querying geospatial data in mongodb

Currently I have my geojson data stored in this format: coord: [long, lat], time: unix timestamp, property: some property I would like to find the nearest location with the closest timestamp (lte). The way how I am doing it right now is: …
acbh
  • 167
  • 1
  • 8
2
votes
0 answers

Manipulating Entity Framework sql query

Is there any way to manipulate the entity framework query. I have a class that has a geometry column. public class Geom { public Guid Id { get; set; } public string Name { get; set; } public string Geometry { get; set; } } Database…
barteloma
  • 6,403
  • 14
  • 79
  • 173
2
votes
1 answer

MySQL spatial geometry validate wkt

In MySQL < 5.7 the spatial functions returned NULL when given invalid WKT, eg: mysql> select astext(geomfromtext('polygon()')); +-----------------------------------+ | astext(geomfromtext('polygon()')) | +-----------------------------------+ | NULL…
Simon Nuttall
  • 394
  • 1
  • 3
  • 12
2
votes
2 answers

How to insert points coming from sub-query as an object of SDO_GEOMETRY in Oracle spatial database?

Say, I have a table named buildings which could be created by the following query: create table buildings( building_id number primary key, building_name varchar2(32), shape sdo_geometry ); I can insert a rectangle into it by the following…
Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56