geoapplications development http rgeo wikience org
play

Geoapplications development http://rgeo.wikience.org Higher School - PowerPoint PPT Presentation

Geoapplications development http://rgeo.wikience.org Higher School of Economics, Moscow, www.cs.hse.ru 2 Agenda 3 Set of core geometries http://www.geopackage.org/spec/ https://en.wikipedia.org/wiki/Well-known_text 4 ISO


  1. Geoapplications development http://rgeo.wikience.org Higher School of Economics, Moscow, www.cs.hse.ru

  2. 2 Agenda • • •

  3. 3 Set of core geometries http://www.geopackage.org/spec/ https://en.wikipedia.org/wiki/Well-known_text

  4. 4 ISO 19107 Following on the addition of Envelope classes, there is a tiny introduction to the most basic ISO 19107 (geometry) objects. The root of all geometric objects in ISO 19107 is GM_Object. But GeoAPI uses the Geometry name instead. There are two objects representing points in ISO 19107: • GM_Point (simply named Point in GeoAPI) is a GM_Object (GeoAPI: Geometry) sub-type. Like every geometries, it may be relatively heavy depending on the geometry library implementation. • DirectPosition is a lightweight structure containing only ordinate values associated to a Coordinate Reference System (CRS). DirectPosition are *not* geometries in the classes hierarchy. • In C/C++, Position is a /union/ (in the C/C++ sense) of GM_Point and DirectPosition, allowing the same API to work with one or other type. Since unions do not exist in Java, GeoAPI simulate the union effect by defining Position as a parent interface of both Point and DirectPosition. In ISO 19107, Envelope is simply defined by the DirectPosition of 2 The base type for all types in corners. Like DirectPosition, Envelope is a relatively lightweight this package is not Geometry structure, not a geometry sub-type. GeoAPI and SIS define many additional methods for envelopes, but the internal structure stay lightweight: only the corner ordinate values and the CRS. http://mail-archives.apache.org/mod_mbox/sis-dev/201212.mbox/%3C50CF64BF.9000706@geomatys.fr%3E

  5. 5 LineString (Open GIS) package org.opengis.geometry.coordinate; import …; /** …skipped… */ org.geotools:gt-opengis:13- @UML(identifier= "GM_LineString" , specification= ISO_19107 ) SNAPSHOT2 public interface LineString extends CurveSegment { /** * Returns a sequence of positions between which the curve is linearly interpolated. * The first position in the sequence is the { @linkplain #getStartPoint start Point} * of this { @code LineString}, and the last point in the sequence is the * { @linkplain #getEndPoint end point} of this { @code LineString}. * * @return The control points between which the curve is linearly interpolated. */ @UML(identifier= "controlPoint" , obligation= MANDATORY , specification= ISO_19107 ) PointArray getControlPoints(); /** * Decomposes a line string into an equivalent sequence of line segments. * * @return The sequence of line segments. */ @UML(identifier= "asGM_LineSegment" , obligation= MANDATORY , specification= ISO_19107 ) List<LineSegment> asLineSegments(); }

  6. 6 LineString (Java Topology Suite) /* ... skipped ... */ package com . vividsolutions . jts . geom ; com.vividsolutions:jts:1.132 import com . vividsolutions . jts . algorithm . CGAlgorithms ; import com . vividsolutions . jts . operation . BoundaryOp ; /** * Models an OGC-style <code>LineString</code>. * A LineString consists of a sequence of two or more vertices, * ... skipped … */ public class LineString extends Geometry implements Lineal { private static final long serialVersionUID = 3110669828065365560L ; /** * The points of this <code>LineString</code>. */ protected CoordinateSequence points ; /* ... skipped ... */ }

  7. 7 JTS TestBuilder An easy way to visualize your geometries and get feeling of operations with them BTW, it is an example of a very good, proven software: • 197 Downloads (This Week) • Last Update: 2013-05-30 For Windows just run testbuilder.bat ; how to setup under MacOS: http://blog.perrygeo.net/2010/05/06/exploring-geometry/

  8. 8 List of operation types on geometries • • • • • • • • • • • •

  9. 9 WKT Specification Polygon Example: POLYGON ((200 300, 600 300, 600 100, 200 100, 200 300), (250 250, 350 250, 350 150, 250 150, 250 250), (400 250, 550 250, 550 200, 400 200, 400 250)) Holes Shell First is shell, everything next is a hole

  10. 10 Geometry validation Q: The syntax is correct, but what really happens to this polygon? POLYGON ((10 40, 60 40, 60 10, 10 10, 10 40), (20 35, 50 35, 50 20, 20 20, 20 35), (30 30, 40 30, 40 15, 30 15, 30 30)) Answer: polygon defined incorrectly (see SPECs in readings)

  11. 11 Geometry validation (2) Polygon holes must not overlap with each other

  12. 12 Geometry validation Q: The syntax is correct, but what really happens to this polygon? POLYGON ((130 300, 400 300, 400 200, 130 200, 130 300), (300 300, 400 300, 400 200, 300 200, 300 300)) Answer: polygon defined incorrectly (see SPECs in readings)

  13. 13 Geometry validation Q: The syntax is correct, but what really happens to this polygon? POLYGON ((130 300, 400 300, 400 200, 130 200, 130 300), (400 270, 400 230, 310 230, 310 270, 400 270)) Answer: polygon defined incorrectly (see SPECs in readings)

  14. 14 Set-oriented operations English Russian https://en.wikipedia.org/wiki/DE-9IM

  15. 15 Set-oriented operations: insights What is the Union result for polygons below? POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30)) POLYGON ((26.4 29.5, 30.5 30.9, 30 26, 26.4 29.5)) Result: MULTIPOLYGON (((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 30 20, 35 35, 20 30)), ((26.4 29.5, 30.5 30.9, 30 26, 26.4 29.5)))

  16. 16 JTS operations on geometries http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html import com . vividsolutions . jts . geom . Geometry ; import com . vividsolutions . jts . geom . GeometryFactory ; import com . vividsolutions . jts . geom . Polygon ; import com . vividsolutions . jts . io . ParseException ; import com . vividsolutions . jts . io . WKTReader ; import org . geotools . geometry . jts . JTSFactoryFinder ; GeometryFactory geometryFactory = JTSFactoryFinder . getGeometryFactory (null); WKTReader reader = new WKTReader ( geometryFactory ); Polygon polygonA = ( Polygon ) reader . read ( " POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10))" ); Polygon polygonB = ( Polygon ) reader . read ( "POLYGON ((20 30, 35 35, 30 20, 20 30))" ); Geometry result = polygonA .difference( polygonB ); System . out . println ( result );

  17. 17 Topology http://rgeo.wikience.org

  18. 18 Discussion GEOMETRYCOLLECTION ( POLYGON ((25 35, 35 37, 38 31, 29 25, 25 35)), LINESTRING (39 39, 30 43, 23 44), POINT (22 40), POINT (19 37), POINT (21 34), POINT (18 32), POINT (17 34), POINT (20 40)) // next slides show how to build this visually

  19. 19 “closure” property • • • Polygon polygonA = (Polygon) reader.read( "POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10))" ); Polygon polygonB = (Polygon) reader.read( "POLYGON ((20 30, 35 35, 30 20, 20 30))" ); Geometry result = polygonA.difference(polygonB); // POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30)) // see course site for Java code and Maven pom.xml

  20. 20 Empty features & Collections GEOMETRYCOLLECTION can combine all other types

  21. 21 Reprojection MathTransform transform = CRS.findMathTransform(crsFeatures, crsMap, true); geometry = JTS.transform(geometry, transform); CoordinateReferenceSystem crs = CRS . decode ( "EPSG:32637" ); String wkt = crs . toWKT (); System . out . println ( wkt );

  22. 22 Buffer Geometry buffer = polygon . buffer ( 10 ); System . out . println ( buffer ); https://desktop.arcgis.com/en/desktop/latest/manage-data/using-sql-with- gdbs/spatial-operation-functions-for-st-geometry.htm

  23. 23 Buffer: insights

  24. 24 Affine transformations // AFFINE TRANSFORMATIONS, view results at JTS TestBuilder result . apply ( AffineTransformation . rotationInstance ( 30 )); System . out . println ( result ); // or several transformations at once AffineTransformation transformation = AffineTransformation . scaleInstance ( 2 , 2 ). compose ( AffineTransformation . rotationInstance ( 45 )). compose ( AffineTransformation . translationInstance ( 10 , 10 )); result . apply ( transformation ); System . out . println ( result );

  25. 25 Line simplification • • • http://www.caliper.com/MAPTITUDE/GPS/default.htm http://www.namekdev.net/2014/06/iterative-version-of-ramer-douglas-peucker-line-simplification-algorithm

  26. 26 Readings

Recommend


More recommend