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 GDAL/OGR: vector formats 4 Supported formats (less than raster) 5 Geospatial


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

GDAL/OGR: vector formats

3

slide-4
SLIDE 4

Supported formats (less than raster)

4

slide-5
SLIDE 5

Geospatial vector data structure

5

ID TYPE Default Geometry Attributes (spatial and non spatial)

slide-6
SLIDE 6

Geospatial vector data attributes

6

slide-7
SLIDE 7

ESRI Shapefile

7

mo-shape

https://en.wikipedia.org/wiki/Shapefile http://wiki.openstreetmap.org/wiki/Shapefiles https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

slide-8
SLIDE 8

Geospatial vector data roadmap (Source)

8

/*physical source of features (SHP, Service, Database, etc.*/ package org.geotools.data; interface DataStore DataStore dataStore = DataStoreFinder.getDataStore(map);

WATCH OUT: GeoTools may return null in RUNTIME, check maven dependencies for the required driver! e.g.:

<dependency> <groupId>org.geotools</groupId> <artifactId>gt-shapefile</artifactId> <version>${geotools.version}</version> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-geojson</artifactId> <version>${geotools.version}</version> </dependency>

slide-9
SLIDE 9

Geospatial vector data roadmap (Source)

9

/*physical source of features (SHP, Service, Database, etc.*/ package org.geotools.data; interface DataStore DataStore dataStore = DataStoreFinder.getDataStore(map); DataStore // names of feature types dataStore.getTypeNames() – String[]

/* does not retrieve immediately; retrieves all, filtered, by query */ package org.geotools.data; FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName); FeatureCollection<T, F> getFeatures() throws IOException; FeatureCollection<T, F> getFeatures(Filter filter) throws IOException; FeatureCollection<T, F> getFeatures(Query query) throws IOException;

slide-10
SLIDE 10

Geospatial vector data roadmap (Feature)

10

/* Collection of features, often handled as a result set.*/ package org.geotools.feature; interface FeatureCollection

/* Iterate over features…*/

System.out.println("Features: "); try (FeatureIterator iterator = source.getFeatures().features()) { while (iterator.hasNext()) { Feature feature = iterator.next(); System.out.println(String.format("[%s] %s", feature.getIdentifier(), feature.getName())); } }

Try out Moscow SHP. Use filters, queries. Convert features to WKT.

slide-11
SLIDE 11

Geospatial vector data roadmap (Geometry)

11

/* A representation of a planar, linear vector geometry.*/ package com.vividsolutions.jts.geom; public abstract class Geometry package org.opengis.feature.simple; public interface SimpleFeature extends Feature Object getDefaultGeometry(); // Q: is this method public? FeatureIterator<SimpleFeature> // let’s parameterize Geometry geometry = (Geometry) feature.getDefaultGeometry(); // Yes, this way

slide-12
SLIDE 12

Open Street Map (OSM)

12

https://www.openstreetmap.org/ https://en.wikipedia.org/wiki/OpenStreetMap http://beryllium.gis- lab.info/project/osmshp/region/RU-MOW http://rgeo.wikience.org ) ~300 MB unpacked

slide-13
SLIDE 13

GeoJSON

13

{"type": "FeatureCollection", "features": [{ "type": "Feature", "id": 18, "properties": { "wind_speed": 18.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -91.875, 26.516671812287743 ], [ - 91.901141782148713, 26.625 ], [ -91.961139731313935, 26.875 ], [

  • 92.005164395414226, 27.125 ], [ -92.028132647185842, 27.375 ],
slide-14
SLIDE 14

GeoJSON.io

14

Swath generated by wikience.org:

http://www.wikience.org/ tropical-cyclones/wind- swaths/

slide-15
SLIDE 15

XML – Extensible Markup Language

15

https://en.wikipedia.org/wiki/XML XML is very widely used. HTML is similar to XML, but less strict XML allows you to define your own tags & attributes Look at pom.xml in your IDE for our course:

<?xml version="1.0" encoding="UTF-8"?>

version – attribute

…. <groupId>rgeo</groupId>

groupdId – tag

<artifactId>practice</artifactId> <version>1.0-SNAPSHOT</version>

slide-16
SLIDE 16

KML: Keyhole Markup Language

16

<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>Distance illustrations</name> <description>Content</description> KML is very expressive

https://developers.google.com/kml/ https://en.wikipedia.org/wiki/Keyhole_Markup_Language

slide-17
SLIDE 17

KML: feature definition

17

slide-18
SLIDE 18

KML: OGC Standard

18

Latest: http://docs.opengeospatial.org/is/12-007r2/12-007r2.htm

slide-19
SLIDE 19

KML: Samples

19

Let’s explore! Interactive: https://kml-samples.googlecode.com/svn/trunk/interactive/index.html

  • r SVN checkout: https://code.google.com/p/kml-samples/
slide-20
SLIDE 20

KMZ

20

GeoTools (very tricky):

http://docs.geotools.org/latest/userguide/extension/xsd/kml.html http://docs.geotools.org/latest/userguide/library/xml/geometry.html

Micromata:

http://labs.micromata.de/projects/jak.html https://github.com/micromata/javaapiforkml http://stackoverflow.com/questions/15636303/extract-coordinates-from-kml-file-in-java Go to course site, download code and parse KML samples. Try to write your own KML file.

slide-21
SLIDE 21

WKT: Well-Known Text

21

  • https://en.wikipedia.org/wiki/Well-known_text
slide-22
SLIDE 22

WKT: Well-Known Text (2)

22

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

slide-23
SLIDE 23

WKT: Well-Known Text – JTS/GeoTools

23

http://docs.geotools.org/latest/userguide/library/main/geometry.html

JTS GeoTools itself More about JTS on the next slide…

slide-24
SLIDE 24

Java Topology Suite (JTS)

24

slide-25
SLIDE 25

WKT with JTS

25

import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; 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 ); LineString line = (LineString) reader.read("LINESTRING(0 2, 2 0, 8 6)"); Polygon polygon = (Polygon) reader.read("POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))"); TODO: write out KML/GeoJSON by defining features using WKT JTS (check course web page) display on Google Earth or GeoJSON.io

slide-26
SLIDE 26