20. MySQLのspatial関数群
要素の抜き出し等に関する関数
ST_Latitude() Return latitude of Point Property(Point)
ST_Longitude() Return longitude of Point Property(Point)
ST_X() Return X coordinate of Point Property(Point)
ST_Y() Return Y coordinate of Point Property(Point)
ST_EndPoint() End Point of LineString Property(Line)
ST_Length() Return length of LineString Property(Line)
ST_NumPoints() Return number of points in LineString Property(Line)
ST_PointN() Return N-th point from LineString Property(Line)
ST_StartPoint() Start Point of LineString Property(Line)
ST_Area() Return Polygon or MultiPolygon area Property(Poly)
ST_Centroid() Return centroid as a point Property(Poly)
ST_ExteriorRing() Return exterior ring of Polygon Property(Poly)
ST_InteriorRingN() Return N-th interior ring of Polygon Property(Poly)
ST_NumInteriorRing(),
ST_NumInteriorRings()
Return number of interior rings in Polygon Property(Poly)
ST_GeometryN() Return N-th geometry from geometry collection Property(Coll)
ST_NumGeometries() Return number of geometries in geometry collection Property(Coll)
21. MySQLのspatial関数群
比較に関する関数
ST_Contains() Whether one geometry contains another Compare(ST)
ST_Crosses() Whether one geometry crosses another Compare(ST)
ST_Disjoint() Whether one geometry is disjoint from another Compare(ST)
ST_Equals() Whether one geometry is equal to another Compare(ST)
ST_Intersects() Whether one geometry intersects another Compare(ST)
ST_IsClosed() Whether a geometry is closed and simple Compare(ST)
ST_IsSimple() Whether a geometry is simple Compare(ST)
ST_IsValid() Whether a geometry is valid Compare(ST)
ST_Overlaps() Whether one geometry overlaps another Compare(ST)
ST_Touches() Whether one geometry touches another Compare(ST)
ST_Within() Whether one geometry is within another Compare(ST)
MBRContains() Whether MBR of one geometry contains MBR of another Compare(MBR)
MBRCoveredBy() Whether one MBR is covered by another Compare(MBR)
MBRCovers() Whether one MBR covers another Compare(MBR)
MBRDisjoint() Whether MBRs of two geometries are disjoint Compare(MBR)
MBREquals() Whether MBRs of two geometries are equal Compare(MBR)
MBRIntersects() Whether MBRs of two geometries intersect Compare(MBR)
MBROverlaps() Whether MBRs of two geometries overlap Compare(MBR)
MBRTouches() Whether MBRs of two geometries touch Compare(MBR)
MBRWithin() Whether MBR of one geometry is within MBR of another Compare(MBR)
22. MySQLのspatial関数群
その他の便利な関数
ST_Distance() The distance of one geometry from another Convenience
ST_Distance_Sphere() Minimum distance on earth between two geometries Convenience
ST_MakeEnvelope() Rectangle around two points Convenience
ST_Simplify() Return simplified geometry Convenience
ST_Validate() Return validated geometry Convenience
ST_SwapXY() Return argument with X/Y coordinates swapped Convert
ST_Buffer() Return geometry of points within given distance from geometry Operator
ST_Buffer_Strategy() Produce strategy option for ST_Buffer() Operator
ST_ConvexHull() Return convex hull of geometry Operator
ST_Difference() Return point set difference of two geometries Operator
ST_Intersection() Return point set intersection of two geometries Operator
ST_SymDifference() Return point set symmetric difference of two geometries Operator
ST_Transform() Transform coordinates of geometry Operator
ST_Union() Return point set union of two geometries Operator
ST_Dimension() Dimension of geometry Property
ST_Envelope() Return MBR of geometry Property
ST_GeometryType() Return name of geometry type Property
ST_IsEmpty() Placeholder function Property
ST_SRID() Return spatial reference system ID for geometry Property
23. MySQLのspatial関数群
GeoHash / GeoJSONに関する関数
ST_GeoHash() Produce a geohash value GeoHash
ST_LatFromGeoHash() Return latitude from geohash value GeoHash
ST_LongFromGeoHash() Return longitude from geohash value GeoHash
ST_PointFromGeoHash() Convert geohash value to POINT value GeoHash
ST_AsGeoJSON() Generate GeoJSON object from geometry GeoJSON
ST_GeomFromGeoJSON() Generate geometry from GeoJSON object GeoJSON
MySQL固有のデータ生成関数
Point() Construct Point from coordinates Create
LineString() Construct LineString from Point values Create
Polygon() Construct Polygon from LineString arguments Create
MultiPoint() Construct MultiPoint from Point values Create
MultiLineString() Contruct MultiLineString from LineString values Create
MultiPolygon() Construct MultiPolygon from Polygon values Create
GeomCollection() Construct geometry collection from geometries Create
GeometryCollection() Construct geometry collection from geometries Create
38. MySQLでの地理座標系の座標の表し方
■テーブルの作成。SRIDを指定する。
CREATE TABLE mygeo3
(id INTEGER,
pnt POINT SRID 4326);
INSERT INTO mygeo3 VALUES (1,
ST_GeomFromText('POINT(43.057265 141.389053)', 4326));
■データの挿入。SRIDを指定する。
■SRIDを指定しないとエラーになる
mysql> INSERT INTO mygeo3 VALUES (1, ST_GeomFromText('POINT(43.057265 141.389053)'));
ERROR 3643 (HY000): The SRID of the geometry does not match the SRID of the column
'pnt'. The SRID of the geometry is 0, but the SRID of the column is 4326.
Consider changing the SRID of the geometry or the SRID property of the column.
SRIDがちゃうで。カラムで 4326 言うてるんやから、0なんて呉れたら、
あかんて。(指定しない時は 0 が与えられたものとして動作する)