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
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 vector data structure ID TYPE Default Geometry Attributes (spatial and non spatial)
6 Geospatial vector data attributes
7 ESRI Shapefile mo-shape https://en.wikipedia.org/wiki/Shapefile http://wiki.openstreetmap.org/wiki/Shapefiles https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
8 Geospatial vector data roadmap (Source) /* 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 >
9 Geospatial vector data roadmap (Source) /* 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;
10 Geospatial vector data roadmap (Feature) /* 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.
11 Geospatial vector data roadmap (Geometry) /* 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
12 Open Street Map (OSM) 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
13 GeoJSON {"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 ],
14 GeoJSON.io Swath generated by wikience.org: http://www.wikience.org/ tropical-cyclones/wind- swaths/
15 XML – Extensible Markup Language 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: version – attribute <? xml version="1.0" encoding="UTF-8" ?> …. groupdId – tag < groupId >rgeo</ groupId > < artifactId >practice</ artifactId > < version >1.0-SNAPSHOT</ version >
16 KML: Keyhole Markup Language <?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
17 KML: feature definition
18 KML: OGC Standard Latest: http://docs.opengeospatial.org/is/12-007r2/12-007r2.htm
19 KML: Samples Let’s explore! Interactive: https://kml-samples.googlecode.com/svn/trunk/interactive/index.html or SVN checkout: https://code.google.com/p/kml-samples/
20 KMZ 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.
21 WKT: Well-Known Text • • https://en.wikipedia.org/wiki/Well-known_text
22 WKT: Well-Known Text (2) https://en.wikipedia.org/wiki/Well-known_text
23 WKT: Well-Known Text – JTS/GeoTools http://docs.geotools.org/latest/userguide/library/main/geometry.html JTS GeoTools itself More about JTS on the next slide…
24 Java Topology Suite (JTS) • • • •
25 WKT with JTS 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
Recommend
More recommend
Explore More Topics
Stay informed with curated content and fresh updates.