postgis的地图切割方案 by giser · 2019-04-03 点线面图层的sh脚本: 点图层: #!/usr/bin/sh export PGCLIENTENCODING=GBK LAYER=$1 POINT_SQL=”SELECT user_label,b.the_geom FROM ${LAYER} b ,ST_SetSRID(ST_MakeBox2D(ST_SetSRID(ST_MakePoint($2,$3),4326),ST_SetSRID(ST_MakePoint($4,$5),4326)),4326) a_geom where st_intersects(b.the_geom,a_geom) ;” pgsql2shp -f “/home/postgres/${LAYER}.shp” postgis_test “${POINT_SQL}” 线图层: #!/usr/bin/sh export PGCLIENTENCODING=GBK LAYER=$1 LINE_SQL=”SELECT b.user_label,(st_intersection(a_geom,b.the_geom)) as the_geom FROM ${LAYER} b ,ST_SetSRID(ST_MakeBox2D(ST_SetSRID(ST_MakePoint(120.0,20.0),4326),ST_SetSRID(ST_MakePoint(128.0,40.0),4326)),4326) a_geom where b.the_geom && a_geom and not ST_ISclosed(st_intersection(a_geom,b.the_geom)) ;” pgsql2shp -f “/home/postgres/${LAYER}.shp” postgis_test “${LINE_SQL}” 面图层: #!/usr/bin/sh export PGCLIENTENCODING=GBK LAYER=$1 PLOYGON_SQL=”SELECT b.user_label,(st_intersection(a_geom,b.the_geom)) as the_geom FROM ${LAYER} b ,ST_SetSRID(ST_MakeBox2D(ST_SetSRID(ST_MakePoint($2,$3),4326),ST_SetSRID(ST_MakePoint($4,$5),4326)),4326) a_geom where b.the_geom && a_geom and ST_ISclosed(st_intersection(a_geom,b.the_geom)) group by b.user_label,a_geom ,b.the_geom ;” pgsql2shp -f “/home/postgres/weih/Excursion/shp/${LAYER}.shp” postgis_test “${PLOYGON_SQL}” 然后可以通过Java的telnet与Ftp的实现对这些图层数据的控制。 转载自:https://blog.csdn.net/no_cross_no_crown/article/details/6213735 相关推荐postgreSQL和postGis安装笔记postgres+socket.io+nodejs实时地图应用实践ArcGIS10.1直连数据库做点Postgresql笔记postgis安装及shapefile导入postgresql中ST_Intersects用法