postgis常用操作手册
查询所有函数:
SELECT * FROM pg_proc;
更新坐标系st_setsrid,查看坐标系:st_srid
创建空间索引:
CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometryfield] );
example:create index idx_poi5_geom on poi5 using gist(geom); 使用空间查询:
select count(*) from poi5 a,poi5 b
where a.pid='20080243019'
and st_within(b.geom,st_buffer(a.geom,0.001));
执行计划:

如果不使用空间索引执行计划:

两个geometry之间关系:within、disjoint、intersects、union、intersection,difference
St_within(geom A,geom B)返回A是否处于B中
St_disjoint(geom A,geom B)返回A是否不在B中
St_intersects(geom A,geom B)返回A是否和B有接触
St_union(geom A,geom B)返回A+B两个几何的合并
St_intersection(geom A,geom B)返回A和B的交集
St_difference(geom A,geom B)返回A与B不相交的部分几何
select
st_difference(
st_buffer(
st_geomfromtext('Point(116 39)'),0.7),
st_buffer(
st_geomfromtext('Point(117 39)'),0.7)) geom
判断几何是否空:st_isempty(geom A)
几何类型转换:
wkt转geometry:st_geomfromtext(wkt)
select st_geomfromtext('Point(122 33)')
geometry转wkt:st_astext(geometry)
select st_astext(st_geomfromtext('Point(122 33)'))
geometry转geojson:st_asgeojson(geometry)
select st_asgeojson(st_geomfromtext('Point(122 33)'))
geojson转geometry:st_geomfromgeojson(geojson)
select
st_geomfromgeojson(
st_asgeojson(st_geomfromtext('Point(122 33)')))
geometry转geohash:st_geohash(geometry)
select st_geohash(st_geomfromtext('Point(116 39)'))
geohash转geometry:st_geomfromgeohash
select st_geomfromgeohash('wwfmzesx7yvjugxr3nzv')
获取几何信息:
得到几何类型:st_geometrytype(geometry A)
根据经纬度,获取两点距离(单位:米):st_distance_sphere(point a,point b)
select
st_distance_sphere(st_geomfromtext('Point(116 39)'),
st_geomfromtext('Point(117 39)'))
如果两个几何在指定范围内,则返回true,否则false:st_dwithin(geom A,geom B)
select count(*) from poi5 a,poi5 b
where a.pid='20080243019'
and st_dwithin(b.geom,a.geom,0.001);
postgis常用操作手册的更多相关文章
- VIM常用操作手册
VIM常用操作手册 1.多行操作,多行注释,多行取消注释 https://jingyan.baidu.com/article/9c69d48f43ed6d13c8024e7b.html 2.常用操作 ...
- Docker系列之常用命令操作手册
目录 1.安装虚拟机 2.安装Docker 3.Docker镜像操作 4.Docker容器操作 Docker系列之常用命令操作手册 继上一篇博客Docker系列之原理简单介绍之后,本博客对常用的Doc ...
- SharePoint2010升级到SharePoint2013操作手册
SharePoint2010升级到SharePoint2013操作手册 目 录 第一章 前言 3 第二章 升级前准备 3 第三章 升级流程图 5 第四章 升级过程 5 4.1 ...
- UBoot常用命令手册
UBoot常用命令手册 U-Boot还提供了更加详细的命令帮助,可以通过”?”显示支持的命令列表,通过help [CommandName]命令还可以查看每个命令的参数说明. 1.bootm bootm ...
- Redis常用命令手册:服务器相关命令
Redis提供了丰富的命令(command)对数据库和各种数据类型进行操作,这些command可以在Linux终端使用.在编程时,比如各类语言包,这些命令都有对应的方法.下面将Redis提供的命令做一 ...
- [置顶] linux常用命令手册
前言:整理了一份linux常用命令手册,与大家分享.这是一些比较常用的命令. 我已经整理成一份PDF带书签的手册,可以到CSDN免费下载. 下载地址:http://download.csdn.net/ ...
- vim常用操作技巧与配置
vi是linux与unix下的常用文本编辑器,其运行稳定,使用方便,本文将分两部分对其常用操作技巧和配置进行阐述,其中参考了网上的一些文章,对作者表示感谢 PART1 操作技巧 说明: 以下的例子中 ...
- PostGis常用函数中文介绍
记录常用PostGis常用函数: 1.OGC标准函数 管理函数: 添加几何字段 AddGeometryColumn(, , , , , ) 删除几何字段 DropGeometryColumn(, , ...
- pslq常用操作
1,登录后默认自动选中My Objects 默认情况下,PLSQL Developer登录后,Brower里会选择All objects,如果你登录的用户是dba,要展开tables目录,正常情况都 ...
随机推荐
- 概率图模型PGM——D map, I map, perfect map
若F分布的每个条件独立性质都反映在A图中,则A图被称为F分布的D map. 若A图表现出的所有条件独立性质都在F分布中满足(与F分布不矛盾),则A图被称为F分布的I map. 弱A图既是F分布的D m ...
- Distribute Candies
Given an integer array with even length, where different numbers in this array represent different k ...
- python之路第二篇(基础篇)
入门知识: 一.关于作用域: 对于变量的作用域,执行声明并在内存中存在,该变量就可以在下面的代码中使用. if 10 == 10: name = 'allen' print name 以下结论对吗? ...
- K相邻算法
刚开始学习机器学习,先跟这<机器学习实战>学一些基本的算法 ----------------------------------分割线--------------------------- ...
- 解决VMware下安装Ubuntu 16.04 不支持1920X1080分辨率的问题
解决方法: flashmx@ubuntu:~$ cvt # 192.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz Modeline -hsync +vsync fl ...
- apache一个ip多个端口虚拟主机
1.打开httpd.conf,查找Listen:80,在下面一行加入Listen:8080:2.查找#Include conf/extra/httpd-vhosts.conf,将此行前面的#去掉:3. ...
- For in 与For of 区别
For in 与For of 区别 for in遍历的是数组的索引(即键名)一般用于遍历对象:for(var index in obj):而for of遍历的是数组元素值:for(var value ...
- IOS应用FFMPEG库
1.引用资源 build-ffmpeg ffmpeg库生成 -sh开源地址: https://gist.github.com/m1entus/6983547 iFrameExtractor ffmp ...
- git的使用(入门篇)
1.Git 的安装 Window 下的安装 从 http://git-scm.com/download 上下载window版的客户端,然后一直下一步下一步安装git即可,请注意,如果你不熟悉每个选项的 ...
- 从零开始搭建框架SSM+Redis+Mysql(一)之摘要
从零开始搭建框架SSM+Redis+Mysql(一)之摘要 本文章为本人实际的操作后的回忆笔记,如果有步骤错漏,希望来信307793969@qq.com或者评论指出. 本文章只体现过程,仅体现操作流程 ...