spatial-query

How to Load Spatial Data using the Hadoop GIS framework

不打扰是莪最后的温柔 提交于 2020-01-16 10:13:26
问题 I am trying to use the Hadoop GIS Framework, in order to add Spatial support to hive. One of the things I want to do is to create a spatial table from external data (from PostGIS). Unfortunately, the serializer provided by ESRI maps to a ESRI JSON format, rather than standards such as WKT, GeoJSON. What I ended up doing, was a bit of a workaround. The first thing, was to export my PostGIS data as a tab separated file, transforming the geometric field into GeoJSON. \COPY (select id, ST

How to Load Spatial Data using the Hadoop GIS framework

一笑奈何 提交于 2020-01-16 10:13:22
问题 I am trying to use the Hadoop GIS Framework, in order to add Spatial support to hive. One of the things I want to do is to create a spatial table from external data (from PostGIS). Unfortunately, the serializer provided by ESRI maps to a ESRI JSON format, rather than standards such as WKT, GeoJSON. What I ended up doing, was a bit of a workaround. The first thing, was to export my PostGIS data as a tab separated file, transforming the geometric field into GeoJSON. \COPY (select id, ST

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

被刻印的时光 ゝ 提交于 2020-01-11 03:26:04
问题 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 cluster. Distance between two points is computed using the Vincenty method. To make this a little more concrete, suppose I have a set of points such as from numpy import * points = array([[33. , 41. ], [33.9693, 41.3923], [33.6074, 41.277 ], [34.4823, 41.919

Spatial index/query (finding k nearest points)

时光总嘲笑我的痴心妄想 提交于 2020-01-01 03:57:05
问题 I have +10k points (latitude, longitude) and I'm building an app that shows you the k nearest points to a user's location. I think this is a very common problem and I don't want to reinvent the wheel. I'm learning about Quadtrees. It seems to be a good approach to solve this spatial problem. I'm using these tools: Python 2.5 MySQL MongoDb Building the Quadtree is not that hard: http://donar.umiacs.umd.edu/quadtree/points/pointquad.html But once I've created the tree and saved it to a db

Optimizing mysql query to select all points with in polygon using spatial indexes

别等时光非礼了梦想. 提交于 2019-12-23 17:23:37
问题 Firstly, I admit that my experience with spatial functions is very minimal. I have a table in MySQL with 20 fields and 23549187 records that contain geographical data. One of the fields is 'point' which is of point data type and has spatial index on it. I have a query that selects all points within a polygon which looks like this, select * from `table_name` where ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON((151.186 -23.497,151.207 -23.505,151.178 -23.496,151.174 -23.49800000000001,151.176 -23.496

Create geometry (f.e. LineString()) from stored points. MySQL spatial

故事扮演 提交于 2019-12-23 05:52:13
问题 Is there any way to create some Geometry (f.e. LineString(pt1,pt2,...) ) from MySQL query (where pt1,pt2,... is a result of another query, in other words pt1,pt2,... stored in MySQL table)? Example: SELECT LineString(SELECT point FROM points) AS line; Thanks! 回答1: I had a similar problem and solved it in this way: SELECT pt1, pt2, pt3, pt4, @Line_string := GEOMFROMTEXT(CONCAT('LINESTRING(',pt1,' ',pt2,', ',pt3,' ',pt4,')')) FROM table; 回答2: LineString(pt1,pt2) MySQL and MariaDB both support

Using STCrosses() with a Spatial Index in SQL Server

三世轮回 提交于 2019-12-23 03:22:45
问题 Does The Microsoft StCrosses() function for Geography data support Spatial Index? When I try to execute this function with Spatial Index I get this error message: "The query processor could not produce a query plan for a query with a spatial index hint. Reason: Spatial indexes do not support the method name supplied in the predicate. Try removing the index hints or removing SET FORCEPLAN" 回答1: No. Indexing spatial data is nontrivial, and the class you are discussing can contain arbitrarily

Mysql select where polygon contains point always false

天涯浪子 提交于 2019-12-22 08:34:24
问题 I have tried various functions like MBRWithin, MBRContains, Intersects, Contains (all of them found in a plenty of posts around here) but no luck yet. This is the simplified query: SELECT * FROM users WHERE Intersects( GeomFromText( 'POINT(50 50)' ), GeomFromText( 'POLYGON(0 0, 100 0, 100 100, 0 100, 0 0)' ) ); I expected it to evaluate that condition as true (like 1=1) and return all users, however this did not happen. Please tell me, what am I doing wrong? I am running MySql 5.5 回答1: This

Selecting a good SQL Server 2008 spatial index with large polygons

若如初见. 提交于 2019-12-18 10:55:26
问题 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 geometry field. The issue I have is that many of the polygons cover a large portion of the globe. This seems to make it very hard to get a spatial index that will eliminate many rows in the primary filter. For example, look at the following query:

MySQL spatial geometry validate wkt

一笑奈何 提交于 2019-12-14 03:55:20
问题 In MySQL < 5.7 the spatial functions returned NULL when given invalid WKT, eg: mysql> select astext(geomfromtext('polygon()')); +-----------------------------------+ | astext(geomfromtext('polygon()')) | +-----------------------------------+ | NULL | +-----------------------------------+ 1 row in set (0.00 sec) But with newer MySQL the same input gives: ERROR 3037 (22023): Invalid GIS data provided to function st_geometryfromtext. Is there a way of checking whether the WKT is valid before