geotools中的空间关系（Geometry Relationships）和空间操作（Geometry Operations）

1、测试数据

```			String wktPoint = "POINT(103.83489981581 33.462715497945)";
String wktLine = "LINESTRING(108.32803893589 41.306670233001,99.950999898452 25.84722546391)";
String wktPolygon = "POLYGON((100.02715479879 32.168082192159,102.76873121104 37.194305614622,107.0334056301 34.909658604412,105.96723702534 30.949603786713,100.02715479879 32.168082192159))";
String wktPolygon1 = "POLYGON((96.219409781775 32.777321394882,96.219409781775 40.240501628236,104.82491352023001 40.240501628236,104.82491352023001 32.777321394882,96.219409781775 32.777321394882))";```

2、空间关系

```			GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null );
System.out.println("-------空间关系判断-------");
System.out.println(polygon.contains(point));
System.out.println(polygon.intersects(line));
System.out.println(polygon.overlaps(polygon1));```

3、空间操作

```			System.out.println("\r\n-------空间计算-------");
WKTWriter write = new WKTWriter();
Geometry intersection = polygon.union( polygon1 );
Geometry union = polygon.union( polygon1 );
Geometry difference = polygon.difference( polygon1 );
Geometry symdifference = polygon.symDifference( polygon1 );
System.out.println("\t+++++++++++叠加分析+++++++++++");
System.out.println(write.write(intersection));
System.out.println("\t+++++++++++合并分析+++++++++++");
System.out.println(write.write(union));
System.out.println("\t+++++++++++差异分析+++++++++++");
System.out.println(write.write(difference));
System.out.println("\t+++++++++++sym差异分析+++++++++++");
System.out.println(write.write(symdifference));```

intersect

union

Difference

SymDifference

263 篇文章56 人订阅

0 条评论

相关文章

20660

11510

...

10120

280100

15430

Java中类型参数“<T>”和无界通配符“<?>”的区别

List<T>最应该出现的地方，应该是定义一个泛型List容器 但List是库里自带的容器，看看ArrayList的源码头一行：

34710

1341 与3和5无关的数

1341 与3和5无关的数 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 白银 Silver 题目描述 Description ...

29240

12520

16530