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

geoapplications development http rgeo wikience org
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Geoapplications development http://rgeo.wikience.org

Higher School of Economics, Moscow, www.cs.hse.ru

slide-2
SLIDE 2

Agenda

2

slide-3
SLIDE 3

Set of core geometries

3

http://www.geopackage.org/spec/

https://en.wikipedia.org/wiki/Well-known_text

slide-4
SLIDE 4

ISO 19107

4

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

  • corners. Like DirectPosition, Envelope is a relatively lightweight

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

The base type for all types in this package is not Geometry

slide-5
SLIDE 5

LineString (Open GIS)

5

package org.opengis.geometry.coordinate; import …; /** …skipped… */ @UML(identifier="GM_LineString", specification=ISO_19107) 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(); }

  • rg.geotools:gt-opengis:13-

SNAPSHOT2

slide-6
SLIDE 6

LineString (Java Topology Suite)

6

com.vividsolutions:jts:1.132

/* ... skipped ... */ package com.vividsolutions.jts.geom; 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 ... */ }

slide-7
SLIDE 7

JTS TestBuilder

7

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/

An easy way to visualize your geometries and get feeling of

  • perations

with them

slide-8
SLIDE 8

List of operation types on geometries

8

slide-9
SLIDE 9

WKT Specification

9

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)) Shell First is shell, everything next is a hole Holes

slide-10
SLIDE 10

Geometry validation

10

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)

slide-11
SLIDE 11

Geometry validation (2)

11

Polygon holes must not

  • verlap with

each other

slide-12
SLIDE 12

Geometry validation

12

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)

slide-13
SLIDE 13

Geometry validation

13

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)

slide-14
SLIDE 14

Set-oriented operations

14

https://en.wikipedia.org/wiki/DE-9IM

English Russian

slide-15
SLIDE 15

Set-oriented operations: insights

15

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)))

slide-16
SLIDE 16

JTS operations on geometries

16

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);

slide-17
SLIDE 17

Topology

17

http://rgeo.wikience.org

slide-18
SLIDE 18

Discussion

18

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

slide-19
SLIDE 19

“closure” property

19

  • 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

slide-20
SLIDE 20

Empty features & Collections

20

GEOMETRYCOLLECTION can combine all other types

slide-21
SLIDE 21

Reprojection

21

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);

slide-22
SLIDE 22

Buffer

22

https://desktop.arcgis.com/en/desktop/latest/manage-data/using-sql-with- gdbs/spatial-operation-functions-for-st-geometry.htm

Geometry buffer = polygon.buffer(10); System.out.println(buffer);

slide-23
SLIDE 23

Buffer: insights

23

slide-24
SLIDE 24

Affine transformations

24

// 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);

slide-25
SLIDE 25

Line simplification

25

  • http://www.caliper.com/MAPTITUDE/GPS/default.htm

http://www.namekdev.net/2014/06/iterative-version-of-ramer-douglas-peucker-line-simplification-algorithm

slide-26
SLIDE 26

Readings

26

slide-27
SLIDE 27