Geospatial for Java


Published on

See for workbooks associated with this presentation.

Are you new to GeoSpatial? Does scientific mumbo-jumbo make your head hurt? Are you (gasp!) just out to get the job done? Come to this work shop and go home happy.

This GeoTools session is back by popular demand in a new long format workshop. Offering a visual introduction for Java developers we will exploring how you can integrate GIS services into your next project. For those new to the GeoSpatial scene we provide an introduction to current concepts and projects, and how to avoid common pitfalls.
We start off with something nice, fun and visual - displaying local files using the development environment of your choice. Covering both the concepts and the science of map making the workbooks serve as an excellent reference, but the focus is always on you and the code you need to get the job done.

We explore the concept of a Feature (literally something you can draw on a map), Geometry (what to actually draw) and details like coordinate reference systems, units and projections. The good news is all this stuff is captured at the Java level as nice normal objects by the GeoTools and Java Topology Suite projects. There are utility classes around so we can avoid going down into crazy scientific detail.

The workshop offers a steady series of workbooks introducing:
Feature creation
Geometry, Coordinate Reference Systems and Re-projection
Spatial Queries
Handling large format rasters
Working with Style

We will work with a couple of common GeoSpatial data formats, the use of PostGIS, Web Map Servers (such as GeoServer and MapServer) and Web Feature Servers.
Attend this workshop and be well-versed for the Java presentations at this years conference. Attend this workshop and receive one million randomly generated points free of charge. Just show up - it will be fun.

Published in: Technology
1 Comment
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Found in the Ukraine, 10-12,000 years old, Carved onto a Mammoth tusk.
  • The stick maps are really cool – they are actually really big – and the navigator lies down on them to read them. Snow's use of mapping represents the usual start of “western” GIS. The point of all this is to convey information - communicate Where to hunt What is nearby Solve problems Visualise data to discover patterns Answer otherwise unsolvable questions Analysis to support decisions, find trends, etc
  • How much is a lot? GeoTools “bin” download ships ready-to-use with 148 jars! Only 58 of those are “geotools”
  • Looks like everything has been set up just fine; so while there will be a DVD for your amusement you can start when ready.
  • Mapping is already object oriented; indeed they use the same plato ideas of classification as we do – and they started in th 1400s
  • The ISO 19107 geometry ideas used by GML3 have not been implemented yet as open source ... they have been implemented as data structures (indeed twice in GeoTools) – but the important operations have not yet been done. People convert to JTS and then covert back.
  • Geospatial for Java

    1. 1. GeoSpatial for Java Introduction to GIS for the Java Developer
    2. 2. GeoSpatial for Java <ul><li>This is a quick introduction to Geospatial concepts and ideas for the Java developer
    3. 3. We will make use of number of Java projects
    4. 4. However the focus is on the ideas (we just happen to be using running code) </li></ul>
    5. 5. Schedule <ul><li>We have three hours; and a break for caffeine </li></ul>Introduction Quickstart 30 min Feature 25 min Geometry and CRS 25 min Caffeine Filter 25 min Image 25 min Style 25 min
    6. 6. Introduction Jody <ul><li>Jody Garnett </li><ul><li>Australia
    7. 7. GeoTools since 2003
    8. 8. Spent the first 2 months being unable to compile
    9. 9. Decided to contribute to documentation
    10. 10. Not done yet </li></ul></ul><ul><li>Australia
    11. 11. Founded 1994
    12. 12. Integration
    13. 13. End to end </li><ul><li>Solutions
    14. 14. Services
    15. 15. Support </li></ul></ul>
    16. 16. Introduction Justin <ul><li>Justin DeOlivera </li><ul><li>Canada
    17. 17. GeoTools since 2005
    18. 18. Spends his time pruning complicated api
    19. 19. Strangely enough Justin is not done yet either </li></ul></ul><ul><li>Commercial arm of the Open Planning Project
    20. 20. OpenGeo Stack
    21. 21. Responsible for the majority of GeoTools development at present </li></ul>
    22. 22. Geographic Information Systems <ul><li>Humans have been doing this for a long time
    23. 23. Cave Art or map to the best hunting ground?
    24. 24. A common theme is representation of walking time rather than distance. Allows map to be used as a planning tool. </li></ul>
    25. 25. Navigation and Problem Solving <ul><li>Polynesian stick maps </li><ul><li>Used for navigating in the pacific ocean.
    26. 26. Depicted islands, wave patterns and current direction. </li></ul><li>1854 Broad Street cholera outbreak </li><ul><li>John Snow discovered the source of the outbreak by mapping cases of cholera.
    27. 27. Cholera victims all used the same water source </li></ul></ul>
    28. 28. GeoTools – Java GIS Toolkit <ul><li>1994 - Present (Really old for Java)
    29. 29. Started in Leads University
    30. 30. OSGeo Project in 2006
    31. 31. Active / Diverse committers </li></ul><ul><li>Open Source </li><ul><li>LGPL </li></ul><li>Open Development </li><ul><li>Public Process
    32. 32. Anyone can Play </li></ul></ul>
    33. 33. GeoTools and “Standards” <ul><li>GeoTools 1 had more users then documentation </li><ul><li>Solution was to fire the users
    34. 34. ... and GeoTools 2 was formed </li></ul><li>GeoTools 2 leans on the OGC standards </li><ul><li>OGC provides public standards anyone can download
    35. 35. Easier to follow standards than having to invent names
    36. 36. So the “best” docs are often the standards </li></ul><li>Standards are not intended to as a limitation </li><ul><li>Only a common starting point
    37. 37. Get it Done </li></ul></ul>
    38. 38. GeoTools and Collaboration <ul><li>In the spirit of “Get it Done” </li><ul><li>We make use of existing projects early and often
    39. 39. This is the “Do not repeat yourself” principle in action </li></ul><li>The project practices “open development” </li><ul><li>Easy to take part
    40. 40. However we are LGPL so we get lots of forks (mostly buried in commercial apps) </li></ul><li>We will introduce these other projects as we go </li><ul><li>using code as often as possible </li></ul><li>This does however mean that we will use a lot of jars </li><ul><li>Maven is the tool we use to manage jars
    41. 41. Do you use maven for your project? </li></ul></ul>
    42. 42. This is Hands On Programming <ul><li>Recommend you pair up with a friend (or make a new friend)
    43. 43. The machines have the software we are using today already downloaded
    44. 44. There is a DVD being passed around; copy the “GeospatialForJava” folder
    45. 45. If you succeed raise your hand and you will get a “Quickstart” workbook! </li></ul>+ + ICON_Person_Q308 ICON_Person_Q308 ICON_CD-DVD_Q308
    46. 46. Eclipse or Netbeans Quickstart <ul><li>Start when ready
    47. 47. You have about 30 mins </li></ul>ICON_Person_Q308 NetBeans Quickstart Eclipse Quickstart Jars Maven M2Eclipse Jars Maven
    48. 48. Feature
    49. 49. Feature Definition <ul><li>Definition </li><ul><li>a prominent or conspicuous part or characteristic
    50. 50. When drawing a person you will often draw the features of a persons face (nose, ears, eyes, mouth)
    51. 51. When drawing a map we draw the features that make up the landscape </li></ul><li>When mapping a real world object </li><ul><li>We draw the shape (the Geometry)
    52. 52. We also record where the object is </li></ul></ul>
    53. 53. Feature for Java Developers <ul><li>Explaining the concept of a Feature to Java Developers is easy </li><ul><li>A Feature is an Object </li></ul><li>Just like an Object (ie an “instance”) that represents an entity in the real world </li><ul><li>Feature is an “instance” </li></ul><li>You can record information about the real world entity </li><ul><li>Feature attributes record information </li></ul><li>You can group several features that are similar into classes and form these classes into a hierarchy </li><ul><li>Feature Type is a “class” </li></ul><li>Like Java Objects, features can be ideas or concepts (like a “urban growth” or rainfall) </li></ul>
    54. 54. Feature for Java cheatsheet <ul><li>Here is a handy table showing the similarities
    55. 55. This is a “dynamic type system” </li></ul>GeoSpatial Java Feature Object Attribute Field Operation method FeatureType Class properties {
    56. 56. Feature Model <ul><li>Here is what that looks like in Java </li><ul><li>Lots of ways to access attributes </li></ul><li>“SimpleFeature” for a flat record / tuple data structure </li></ul>
    57. 57. GeoAPI <ul><li>Originally started to promote collaboration between GeoTools and the deegree project </li><ul><li>Mostly failed at this objective
    58. 58. Collaboration requires both parties to have funding at the same time </li></ul><li>Adopted as an “OGC” working group to promote the development of common Java API </li><ul><li>GeoAPI javadocs are an alternative to reading standards </li></ul><li>Summary </li><ul><li>GeoAPI defines the Interfaces
    59. 59. GeoTools implements the Objects </li></ul></ul>
    60. 60. Feature Workbook <ul><li>CSV2SHP
    61. 61. Great example of building features by hand
    62. 62. Data Model </li><ul><li>Feature, FeatureType </li></ul><li>Data Acess </li><ul><li>DataStore / FeatureSource / FeatureStore </li></ul></ul>
    63. 63. Geometry and CRS
    64. 64. JTS Topology Suite <ul><li>Remember we need both: </li><ul><li>The shape to draw (ie the Geometry)
    65. 65. The location to draw the shape in </li></ul><li>Geometry is provided by the JTS project </li><ul><li>Implementation of OGC “Simple Features for SQL”
    66. 66. Numerically stable
    67. 67. This is the rocket science of GIS
    68. 68. Literally the foundation of our open source spatial industry </li></ul><li>Team made up of a single canadian developer </li><ul><li>Martin Davis
    69. 69. </li></ul></ul>
    70. 70. Geometry - Point <ul><li>In the beginning… </li><ul><li>Point
    71. 71. A single coordinate of two to four dimensions </li></ul></ul>x=151.211111 y=-33.859972
    72. 72. GeometryFactory and WKT
    73. 73. Geometry - LineString <ul><li>A set of two of more coordinates linear interpretation of a path between coordinates
    74. 74. Translation: </li><ul><li>Java String is a “string of characters”
    75. 75. LineString is a string of straight line segments </li></ul></ul>
    76. 76. Geometry - Polygon <ul><li>A set of one or more linestrings </li><ul><li>One ring defines the exterior boundary
    77. 77. The remaining rings define the “holes” in the polygon </li></ul><li>Represents an Area </li></ul>
    78. 78. Concept - Coverage <ul><li>Polygons that share an edge, completely covering an area </li><ul><li>Examples: Land use, Soil types, Zones </li></ul><li>Often represented as a collection of features
    79. 79. Efficient “wing edge” data structures to represent a coverage </li><ul><li>I don't know a good implementation in Java </li></ul></ul>
    80. 80. What is the Point <ul><li>With Geometry we can draw the shape of our “feature”
    81. 81. We are still missing an important bit of information </li><ul><li>“Where” the feature is! </li></ul><li>This is similar to the idea of “distance” </li><ul><li>Q: how far?
    82. 82. A: 3 </li></ul><li>We really need to know 3 “what”
    83. 83. The units of distance are important
    84. 84. We really need the meaning of a shape </li></ul>
    85. 85. Coordinate <ul><li>Coordinate –ordered list of measurements </li><ul><li>X / Y
    86. 86. Latitude / Longitude
    87. 87. Longitude / Latitude </li></ul><li>An important part is defining what is being measured </li><ul><li>Latitude and Longitude in degrees
    88. 88. Distances measured in meters </li></ul></ul>
    89. 89. Coordinate Reference System <ul><li>CRS is the definition of what coordinates are measuring </li><ul><li>Positions are always in 3D space
    90. 90. We often “cheat” and only write down two numbers (the ordinates in co-ordinates) </li></ul><li>How is this possible?
    91. 91. We treat the numbers as measurements against a model of the earth
    92. 92. Earth model? (ie Geodetic Datum) </li><ul><li>Ellipsoid – shape kind of like a sphere
    93. 93. Geoid – gravity field – kind of like sea level </li></ul></ul>
    94. 94. Where to measure from Easy on a flat surface Not as straight forward on a sphere Start with a point of origin Latitude – degrees north or south of the Equator Longitude – degrees east or west of the Prime Meridian
    95. 95. Axis order Issue <ul><li>Map makers have been recording information using northing/easting order ... because of Sextant
    96. 96. However Computer GIS systems often expect x/y order
    97. 97. But the map makers never really agreed </li><ul><li>So there is confusion
    98. 98. You need to check the data </li></ul></ul>
    99. 99. Feature and Geometry Standards <ul><li>Simple </li><ul><li>Point
    100. 100. Line
    101. 101. Polygon </li></ul><li>Standards </li><ul><li>GML2
    102. 102. SFSQL </li></ul><li>Implementation </li><ul><li>JTS </li></ul></ul><ul><li>Complex </li><ul><li>Point
    103. 103. Curve
    104. 104. Surface </li></ul><li>Standards </li><ul><li>GML3
    105. 105. ISO19107 </li></ul><li>Implementation </li><ul><li>data structure only </li></ul></ul>
    106. 106. Geometry CRS Lab <ul><li>The Shape of GIS
    107. 107. And what it means </li></ul>
    108. 108. Filter
    109. 109. Filter used to Select information <ul><li>Filter is used as part of a Query to “select” information
    110. 110. Think of it as the WHERE clause in an SQL statement
    111. 111. Several formats </li><ul><li>XML (used by WFS)
    112. 112. Common Query Langague (CQL) </li></ul><li>You can run the resulting Filter object yourself </li><ul><li>filter.evaulate( object ) </li></ul><li>Makes use of “Filter Expressions” used to access data </li><ul><li>expression.evaualte( object, String.class ) </li></ul><li>Both filter and expression work on Feature and Java Beans </li></ul>
    113. 113. Filter Workbook <ul><li>This is where it get's cool; add hock query against </li><ul><li>Shapefile
    114. 114. PostGIS
    115. 115. WFS </li></ul><li>Using the same code! </li></ul>
    116. 116. Raster Data
    117. 117. Grid Coverage <ul><li>Remember a Coverage is a collection of features that complete “cover” an area
    118. 118. A grid coverage is a special case – the coverage forms a regular grid of features
    119. 119. This looks so much like “pixels” we end up using the same file formats (jpeg, png, tiff, etc..) with a text file for location
    120. 120. Spatial formats record location in file metadata (ecw, geotiff) </li></ul>
    121. 121. Not Pixels but Measurements <ul><li>Grid Coverages are used to record measurements </li><ul><li>Height (called a Digital Elevation Model or DEM)
    122. 122. Height and Depth – Bathymetry
    123. 123. Vegetation Index </li></ul><li>Some have Red, Green, Blue measurements
    124. 124. The file metadata can tell you what the values are for </li></ul>
    125. 125. Image Lab <ul><li>Working with raster files </li><ul><li>Grayscale
    126. 126. Color
    127. 127. Multi-band </li></ul></ul>
    128. 128. Style
    129. 129. Cartography - Scale <ul><li>Cartography is the practice of map making
    130. 130. Focus on purpose </li><ul><li>What is the map trying to communicate?
    131. 131. Who will be using it?
    132. 132. What projection, scale and symbology are best? </li></ul><li>Scale </li><ul><li>Appropriate for task at hand (floor plan vs interstate)
    133. 133. Graphical Representation of Scale works even when altered/printed </li></ul></ul>
    134. 134. Cartography – Projection and Symbols <ul><li>Choosing projection is hard (equal area to measure distance or WGS84 to show world)
    135. 135. Choose symbols appropriate to audience (and their training) </li><ul><li>MIL2525B symbols for tactical response
    136. 136. Happy Face for planning lunch </li></ul></ul>
    137. 137. Cartography - Color <ul><li> </li><ul><li>Qualitative
    138. 138. Sequential
    139. 139. Diverging </li></ul><li>Color brewer palettes built-in to GeoTools </li></ul>
    140. 140. Map Definition and Style <ul><li>MapContext </li><ul><li>Layer – data and style used to draw </li></ul><li>StyleLayerDescriptor </li><ul><li>FeatureTypeStyle – instructions for how to draw features </li><ul><li>Rule – choose which features </li><ul><li>PolygonSymbolizer
    141. 141. PointSymbolizer
    142. 142. LineSymbolizer
    143. 143. TextSymbolizer
    144. 144. RasterSymbolizer </li></ul></ul></ul></ul>
    145. 145. Style Layer Descriptor – Mostly Ignore
    146. 146. FeatureTypeStyle – the Good Stuff
    147. 147. constraint Content Style Portrayal (ie Drawing) Composition line symbolizer line symbolizer point symbolizer text symbolizer NAME point symbolizer text symbolizer NAME point symbolizer Features Raster type=City type=Road constraint surface=hiway Rule max scale: 50k Rule Pop > 500000 max scale: 50k Rule Other Rule capital=true Rule Queanbeyan
    148. 148. Style Lab <ul><li>Going to work on putting a Style together </li><ul><li>Using a simple dialog
    149. 149. From an XML file
    150. 150. By hand </li></ul><li>Advanced </li><ul><li>Dynamically Generate a Style to Show Selection </li></ul></ul>
    151. 151. Other Java Projects
    152. 152. Much More to Do <ul><li>Graph module </li><ul><li>Shortest route </li></ul><li>Web Formats </li><ul><li>GML
    153. 153. GeoJson
    154. 154. SVG </li></ul></ul><ul><li>Processes </li><ul><li>RasterToVector </li></ul></ul>
    155. 155. There are Many More Java Projects <ul><li>Projects using GeoTools </li><ul><li>52North
    156. 156. Atlas Styler
    157. 157. GeoPublisher
    158. 158. Geomajas
    159. 159. GeoServer
    160. 160. OpenTripPlanner
    161. 161. uDig </li></ul></ul><ul><li>Also at FOSS4G </li><ul><li>deegree (LGPL)
    162. 162. gvSig (GPL)
    163. 163. Open Jump </li></ul></ul>
    164. 164. Questions
    165. 165. Thanks! <ul><li>Thanks for Attending this Workshop
    166. 166. Shout out to Micheal Bedward who wrote many of the source code examples
    167. 167. Thanks to co-workers who reviewed </li></ul>