SlideShare a Scribd company logo
1 of 52
GeoScript Spatial Capabilities for Scripting Languages Justin Deolivera, Tim Schaub, and Jared Erickson
Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scripting Platform for JVM Languages ,[object Object],[object Object]
Groovy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JavaScript ,[object Object],[object Object],[object Object],[object Object],[object Object]
Python ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Scala
On the shoulders of giants...
GeoScript Modules
Geometry ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geometry >>>  from geoscript import geom >>>  geom.Point(30, 10) POINT(30 10)
Geometry >>>  import geoscript.geom.* >>>  line = new LineString([[111.0, -47], [123.0, -48], [110.0, -47]]) LINESTRING (111 -47, 123 -48, 110 -47)
Geometry js>  var poly = geom.Point([10, 30]).    >      buffer(5) js>  poly <Polygon [[[15, 30], [14.90...> js>  poly.area 78.03612880645133
Geometry - I/O >>>  from geoscript import geom >>>  point = geom.Point(30, 10) >>>  geom.writeKML(point) <kml:Point xmlns:kml=&quot;http://earth.google.com/kml/2.1&quot;>   <kml:coordinates>0.0,0.0</kml:coordinates> </kml:Point>
Geometry - I/O >>>  import geoscript.geom.Point >>>  import geoscript.geom.io.Gml2Writer >>>  p = new Point(111, -47) >>>  gml = new Gml2Writer() >>>  gml.write(p) <gml:Point>   <gml:coordinates>111.0,-47.0</gml:coordinates> </gml:Point>
Geometry - I/O js>  var geom = require(&quot;geoscript/geom&quot;); js>  var point = geom.Point([1, 2]) js>  point.json {&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[1,2]}
Geometry - Visualization >>>  from geoscript.render import plot >>> from geoscript import geom >>> poly = geom.Polygon([(35,10), (10,20), (15,40), (45,45), (35,10)], [(20,30), (35,35), (30,20), (20,30)]) >>>  plot(poly)
Geometry - Visualization js>  var geom = require(&quot;geoscript/geom&quot;) js>  require(&quot;geoscript/viewer&quot;).bind()   js>  var poly1 = geom.Point([0, 0]).buffer(1) js>  var poly2 = poly1.transform({dx: 0.5, dy: 0.5}) js>  poly1.difference(poly2) <Polygon [[[0.9095298326166407, -0.409529...>
Projection ,[object Object],[object Object],[object Object]
Projection js>  var proj = require(&quot;geoscript/proj&quot;); js>  var p = proj.Projection(&quot;epsg:4326&quot;); js>  p.wkt GEOGCS[&quot;WGS 84&quot;,     DATUM[&quot;World Geodetic System 1984&quot;,     ...
Projection >>> from geoscript import geom >>> from geoscript.proj import Projection >>> p = Projection('epsg:4326') >>>  p.transform((-111, 45.7), 'epsg:26912') (500000.0, 5060716.313515949) >>> g = geom.Point(0, 0).buffer(4) >>> g = reduce(lambda x,y:x.union(y),[geom.transform(g,dx=x,dy=y)        for x,y in [(3,0),(0,3),(-3,0),(0,-3)]]) >>>  p.transform(g, 'epsg:26912') >>>  p.transform(g, 'epsg:3005') Reprojection WGS 84 UTM Albers
Data Access ,[object Object],[object Object],[object Object],[object Object],[object Object]
Data Access - Workspace js>  var ws = require(&quot;geoscript/workspace&quot;);         js>  var dir = ws.Directory(&quot;data&quot;);    js>  dir            <Directory [&quot;states&quot;]> js>  var states = dir.get(&quot;states&quot;); js>  states <Layer name: states, count: 49>
Data Access - Workspace >>  from geoscript.workspace import PostGIS >>  pg = PostGIS('spearfish') >>  pg.layers() ['archsites', 'bugsites', ..., 'streams'] >>  l = pg['archsites']
Data Access - Workspace >>>  import geoscript.workspace.H2 >>>  import geoscript.geom.Point >>>  import geoscript.feature.Feature >>>  h2 = new H2(&quot;name&quot;, &quot;path&quot;) >>>  layer = h2.create(&quot;points&quot;, [      new Field(&quot;geom&quot;,&quot;Point&quot;),      new Field(&quot;name&quot;,&quot;String&quot;) ]) >>>  layer.add([new Point[1,1],&quot;one&quot;])
Data Access - Layers >>>  from geoscript.layer import Shapefile >>>  states = Shapefile('states.shp') >>>  states = states.reproject('epsg:3005')
Data Access - Layer Info >>>  import geoscript.layer.Shapefile >>>  shp = new Shapefile(&quot;states.shp&quot;) >>>  shp.count 49 >>>  shp.bounds (-124.73142200000001, 24.955967,-66.969849, 49.371735, EPSG:4326) >>>  shp.schema.fields.each {    fld -> println fld} the_geom: MultiPolygon(EPSG:4326) STATE_NAME: String STATE_FIPS: String SUB_REGION: String STATE_ABBR: String
Data Access - Layers js>  var ws = require(&quot;geoscript/workspace&quot;);        js>  var dir = ws.Directory(&quot;data&quot;);    js>  var states = dir.get(&quot;states&quot;); js>  states.query(&quot;STATE_ABBR like 'M%'&quot;).forEach(    >      function(feature) {    >          print(feature.get(&quot;STATE_NAME&quot;));    >      }    >  ) Maryland Missouri Mississippi ...
Styling and Rendering ,[object Object],[object Object],[object Object],[object Object]
Styling - Stroke >>>  from geoscript.style import Stroke >>>  Stroke('#000000', width=2) >>>  Stroke('black', width=2, dash=[5,5]) >>>  Stroke((0,0,0),width=2).hatch('vertline')
Styling - Fill >>>  import geoscript.style.Fill >>>  new Fill(&quot;gray&quot;) >>>  new Fill(&quot;gray&quot;, 0.5)) >>>  new Fill(&quot;gray&quot;).hatch(&quot;backslash&quot;) >>>  new Stroke(&quot;red&quot;,2) + new Fill(&quot;gray&quot;).hatch(&quot;times&quot;)
Styling - Shape and Icon js>  var style = require(&quot;geoscript/style&quot;); js>  style.Shape({name: &quot;star&quot;, fill: &quot;yellow&quot;}) <Shape name: 'star', size: 6> js>  style.Icon(&quot;rainy.svg&quot;) <Icon url: 'rainy.svg'>
Styling - Labels >>>  from geoscript.style import Label,Stroke,Fill,Shape >>>  font = 'bold 16px Arial' >>>   Shape() +  Label('name',font)       .point(displace=(20,0)) >>>   Stroke() +  Label('name',font)       .linear(offset=10) >>>   Fill() +  Label('name',font).halo('white',2)
Styling - Scale >>>  new Shape('#004d96', 5).range(3000)  + new Icon('school20.png').range(1500, 3000) + new Icon('school40.png').range(-1, 1500)
Styling - Theming >>> from geoscript.style Stroke, Fill, Label >>> style = Stroke() + Label('STATE_ABBR', 14, 'Serif') >>> style += Fill('#4DFF4D', 0.7)        .where('PERSONS < 2000000') >>> style += Fill('#FF4D4D', 0.7)       .where('PERSONS BETWEEN 2000000 AND 4000000') >>> style += Fill('#4D4DFF', 0.7)       .where('PERSONS > 4000000')
Demos
Voronoi Diagram Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Gradient  Example var Directory = require(&quot;geoscript/workspace&quot;).Directory; var {Fill, gradient} = require(&quot;geoscript/style&quot;); var Map = require(&quot;geoscript/map&quot;).Map; var states = Directory(&quot;data&quot;).get(&quot;states&quot;); states.style = gradient({      expression: &quot;PERSONS / LAND_KM&quot;,       values: [0, 200],       styles: [Fill(&quot;#000066&quot;), Fill(&quot;red&quot;)],      classes: 10,       method: &quot;exponential&quot; }).and(      Fill(&quot;red&quot;).where(&quot;PERSONS / LAND_KM > 200&quot;) ); var map = Map([states]); map.render({path: &quot;states.png&quot;});
Shapefile to PostGIS from geoscript.workspace import Directory, PostGIS shps = Directory('shapefiles') shps.layers() archsites = shps['archsites'] archsites.proj.id pg = PostGIS('demo') pg.layers() for layer in shps:    reprojected = shps[layer].reproject('epsg:4326')    pg.add(reprojected, name=layer) pg.layers() archsites = pg['archsites'] archsites.proj.id
Road Map ,[object Object],[object Object],[object Object],[object Object]
Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank you!
Centroids ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Shapefiles to PostGIS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
USGS Earth Quakes Read RSS Feed to a Shapefile
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Web Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Graffiti Micro Web Framework
Geometry Web Services 
Geometry Web Services Open Layers function centroid() {     var features = vectorLayer.features;     if (features.length == 0) {        alert(&quot;Please add some features!&quot;);     } else {        OpenLayers.loadURL('centroid', {              geom: wktFormat.write(features)           },            this,            function(request) {              var wkt = request.responseText;              var features = wktFormat.read(wkt);              if (features) vectorLayer.addFeatures(features);           },            function() {              alert(&quot;Error calculating centroids!&quot;);           }        );     } }
WMS Server ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
WMS Server... import geoscript.map.Map import geoscript.style.* import geoscript.layer.Shapefile import geoscript.geom.Bounds def file = new File(&quot;states.shp&quot;) def shp = new Shapefile(file) shp.style = new Fill(&quot;steelblue&quot;) + new Stroke(&quot;wheat&quot;, 0.1) def map = new Map(      width: 256,       height: 256,       layers: [shp],      proj: shp.proj,      fixAspectRatio: false ) def bbox = request.getParameter(&quot;BBOX&quot;).split(&quot;,&quot;) def bounds = new Bounds(bbox[0] as double, bbox[1] as double, bbox[2] as double, bbox[3] as double) map.bounds = bounds response.contentType = &quot;image/png&quot; map.render(response.outputStream) map.close()
Geometry Command line  ,[object Object],def cli = new CliBuilder(usage: 'geoscript-groovy geom_buffer.groovy -d') cli.d(longOpt: 'distance', 'buffer distance', args:1) cli.h(longOpt: 'help', 'Show usage information and quit') def opt = cli.parse(args) if(!opt) return if (opt.h || !opt.d) cli.usage() else println geoscript.geom.Geometry.fromWKT(System.in.text).buffer(opt.d as double).wkt def cli = new CliBuilder(usage: 'geoscript-groovy geom_envelope.groovy') cli.h(longOpt: 'help', 'Show usage information and quit') def opt = cli.parse(args) if(!opt) return if (opt.h) cli.usage() else println geoscript.geom.Geometry.fromWKT(System.in.text).bounds.geometry.wkt geom_buffer.groovy geom_envelope.groovy

More Related Content

What's hot

Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architectureJung Kim
 
RubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mrubyRubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mrubyyamanekko
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184Mahmoud Samir Fayed
 
Minimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityMinimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityDerek Lee Boire
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseSages
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJSKyung Yeol Kim
 
Build Lightweight Web Module
Build Lightweight Web ModuleBuild Lightweight Web Module
Build Lightweight Web ModuleMorgan Cheng
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015Fernando Hamasaki de Amorim
 
Relaxing With CouchDB
Relaxing With CouchDBRelaxing With CouchDB
Relaxing With CouchDBleinweber
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented NetworkingMostafa Amer
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopSages
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersRick Beerendonk
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingDavid Gómez García
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaHermann Hueck
 

What's hot (20)

Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
 
RubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mrubyRubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mruby
 
Map kit light
Map kit lightMap kit light
Map kit light
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184
 
Minimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityMinimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team Productivity
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
Build Lightweight Web Module
Build Lightweight Web ModuleBuild Lightweight Web Module
Build Lightweight Web Module
 
High Performance tDiary
High Performance tDiaryHigh Performance tDiary
High Performance tDiary
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
 
Relaxing With CouchDB
Relaxing With CouchDBRelaxing With CouchDB
Relaxing With CouchDB
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
 
OneRing @ OSCamp 2010
OneRing @ OSCamp 2010OneRing @ OSCamp 2010
OneRing @ OSCamp 2010
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript Scripting
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from Scala
 

Similar to GeoScript - Spatial Capabilities for Scripting Languages

Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2tonvanbart
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinChad Cooper
 
Intro To PostGIS
Intro To PostGISIntro To PostGIS
Intro To PostGISmleslie
 
Yahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from InternetYahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from Internetdrgath
 
Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...Javeline B.V.
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Matteo Collina
 
Google MAP API
Google MAP APIGoogle MAP API
Google MAP APIEric Lee
 
Use of django at jolt online v3
Use of django at jolt online v3Use of django at jolt online v3
Use of django at jolt online v3Jaime Buelta
 
JavaOne 2009 - 2d Vector Graphics in the browser with Canvas and SVG
JavaOne 2009 -  2d Vector Graphics in the browser with Canvas and SVGJavaOne 2009 -  2d Vector Graphics in the browser with Canvas and SVG
JavaOne 2009 - 2d Vector Graphics in the browser with Canvas and SVGPatrick Chanezon
 
PART 4: GEOGRAPHIC SCRIPTING
PART 4: GEOGRAPHIC SCRIPTINGPART 4: GEOGRAPHIC SCRIPTING
PART 4: GEOGRAPHIC SCRIPTINGAndrea Antonello
 
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Sergey Ilinsky
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005Tugdual Grall
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free ProgrammingStephen Chin
 
How data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield HeroesHow data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield HeroesElectronic Arts / DICE
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGISmleslie
 

Similar to GeoScript - Spatial Capabilities for Scripting Languages (20)

Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
 
Google maps
Google mapsGoogle maps
Google maps
 
Google maps
Google mapsGoogle maps
Google maps
 
Intro To PostGIS
Intro To PostGISIntro To PostGIS
Intro To PostGIS
 
Yahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from InternetYahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from Internet
 
Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
 
Google MAP API
Google MAP APIGoogle MAP API
Google MAP API
 
Use of django at jolt online v3
Use of django at jolt online v3Use of django at jolt online v3
Use of django at jolt online v3
 
JavaOne 2009 - 2d Vector Graphics in the browser with Canvas and SVG
JavaOne 2009 -  2d Vector Graphics in the browser with Canvas and SVGJavaOne 2009 -  2d Vector Graphics in the browser with Canvas and SVG
JavaOne 2009 - 2d Vector Graphics in the browser with Canvas and SVG
 
PART 4: GEOGRAPHIC SCRIPTING
PART 4: GEOGRAPHIC SCRIPTINGPART 4: GEOGRAPHIC SCRIPTING
PART 4: GEOGRAPHIC SCRIPTING
 
GWT
GWTGWT
GWT
 
Gooogle Web Toolkit
Gooogle Web ToolkitGooogle Web Toolkit
Gooogle Web Toolkit
 
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
 
How data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield HeroesHow data rules the world: Telemetry in Battlefield Heroes
How data rules the world: Telemetry in Battlefield Heroes
 
Groovy
GroovyGroovy
Groovy
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGIS
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

GeoScript - Spatial Capabilities for Scripting Languages

  • 1. GeoScript Spatial Capabilities for Scripting Languages Justin Deolivera, Tim Schaub, and Jared Erickson
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. On the shoulders of giants...
  • 10.
  • 11. Geometry >>> from geoscript import geom >>> geom.Point(30, 10) POINT(30 10)
  • 12. Geometry >>>  import geoscript.geom.* >>> line = new LineString([[111.0, -47], [123.0, -48], [110.0, -47]]) LINESTRING (111 -47, 123 -48, 110 -47)
  • 13. Geometry js> var poly = geom.Point([10, 30]).   >     buffer(5) js> poly <Polygon [[[15, 30], [14.90...> js> poly.area 78.03612880645133
  • 14. Geometry - I/O >>>  from geoscript import geom >>>  point = geom.Point(30, 10) >>>  geom.writeKML(point) <kml:Point xmlns:kml=&quot;http://earth.google.com/kml/2.1&quot;>   <kml:coordinates>0.0,0.0</kml:coordinates> </kml:Point>
  • 15. Geometry - I/O >>> import geoscript.geom.Point >>> import geoscript.geom.io.Gml2Writer >>> p = new Point(111, -47) >>> gml = new Gml2Writer() >>> gml.write(p) <gml:Point>   <gml:coordinates>111.0,-47.0</gml:coordinates> </gml:Point>
  • 16. Geometry - I/O js> var geom = require(&quot;geoscript/geom&quot;); js> var point = geom.Point([1, 2]) js> point.json {&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[1,2]}
  • 17. Geometry - Visualization >>>  from geoscript.render import plot >>> from geoscript import geom >>> poly = geom.Polygon([(35,10), (10,20), (15,40), (45,45), (35,10)], [(20,30), (35,35), (30,20), (20,30)]) >>>  plot(poly)
  • 18. Geometry - Visualization js> var geom = require(&quot;geoscript/geom&quot;) js> require(&quot;geoscript/viewer&quot;).bind()   js> var poly1 = geom.Point([0, 0]).buffer(1) js> var poly2 = poly1.transform({dx: 0.5, dy: 0.5}) js> poly1.difference(poly2) <Polygon [[[0.9095298326166407, -0.409529...>
  • 19.
  • 20. Projection js> var proj = require(&quot;geoscript/proj&quot;); js> var p = proj.Projection(&quot;epsg:4326&quot;); js> p.wkt GEOGCS[&quot;WGS 84&quot;,    DATUM[&quot;World Geodetic System 1984&quot;,    ...
  • 21. Projection >>> from geoscript import geom >>> from geoscript.proj import Projection >>> p = Projection('epsg:4326') >>>  p.transform((-111, 45.7), 'epsg:26912') (500000.0, 5060716.313515949) >>> g = geom.Point(0, 0).buffer(4) >>> g = reduce(lambda x,y:x.union(y),[geom.transform(g,dx=x,dy=y)        for x,y in [(3,0),(0,3),(-3,0),(0,-3)]]) >>>  p.transform(g, 'epsg:26912') >>>  p.transform(g, 'epsg:3005') Reprojection WGS 84 UTM Albers
  • 22.
  • 23. Data Access - Workspace js> var ws = require(&quot;geoscript/workspace&quot;);        js> var dir = ws.Directory(&quot;data&quot;);    js> dir           <Directory [&quot;states&quot;]> js> var states = dir.get(&quot;states&quot;); js> states <Layer name: states, count: 49>
  • 24. Data Access - Workspace >>  from geoscript.workspace import PostGIS >>  pg = PostGIS('spearfish') >>  pg.layers() ['archsites', 'bugsites', ..., 'streams'] >> l = pg['archsites']
  • 25. Data Access - Workspace >>> import geoscript.workspace.H2 >>> import geoscript.geom.Point >>> import geoscript.feature.Feature >>> h2 = new H2(&quot;name&quot;, &quot;path&quot;) >>> layer = h2.create(&quot;points&quot;, [     new Field(&quot;geom&quot;,&quot;Point&quot;),     new Field(&quot;name&quot;,&quot;String&quot;) ]) >>> layer.add([new Point[1,1],&quot;one&quot;])
  • 26. Data Access - Layers >>> from geoscript.layer import Shapefile >>> states = Shapefile('states.shp') >>> states = states.reproject('epsg:3005')
  • 27. Data Access - Layer Info >>> import geoscript.layer.Shapefile >>> shp = new Shapefile(&quot;states.shp&quot;) >>> shp.count 49 >>> shp.bounds (-124.73142200000001, 24.955967,-66.969849, 49.371735, EPSG:4326) >>> shp.schema.fields.each {   fld -> println fld} the_geom: MultiPolygon(EPSG:4326) STATE_NAME: String STATE_FIPS: String SUB_REGION: String STATE_ABBR: String
  • 28. Data Access - Layers js>  var ws = require(&quot;geoscript/workspace&quot;);        js>  var dir = ws.Directory(&quot;data&quot;);    js>  var states = dir.get(&quot;states&quot;); js> states.query(&quot;STATE_ABBR like 'M%'&quot;).forEach(   >     function(feature) {   >         print(feature.get(&quot;STATE_NAME&quot;));   >     }   > ) Maryland Missouri Mississippi ...
  • 29.
  • 30. Styling - Stroke >>>  from geoscript.style import Stroke >>>  Stroke('#000000', width=2) >>>  Stroke('black', width=2, dash=[5,5]) >>>  Stroke((0,0,0),width=2).hatch('vertline')
  • 31. Styling - Fill >>> import geoscript.style.Fill >>>  new Fill(&quot;gray&quot;) >>>  new Fill(&quot;gray&quot;, 0.5)) >>>  new Fill(&quot;gray&quot;).hatch(&quot;backslash&quot;) >>>  new Stroke(&quot;red&quot;,2) + new Fill(&quot;gray&quot;).hatch(&quot;times&quot;)
  • 32. Styling - Shape and Icon js> var style = require(&quot;geoscript/style&quot;); js> style.Shape({name: &quot;star&quot;, fill: &quot;yellow&quot;}) <Shape name: 'star', size: 6> js> style.Icon(&quot;rainy.svg&quot;) <Icon url: 'rainy.svg'>
  • 33. Styling - Labels >>>  from geoscript.style import Label,Stroke,Fill,Shape >>>  font = 'bold 16px Arial' >>> Shape() + Label('name',font)       .point(displace=(20,0)) >>> Stroke() + Label('name',font)       .linear(offset=10) >>>   Fill() + Label('name',font).halo('white',2)
  • 34. Styling - Scale >>> new Shape('#004d96', 5).range(3000)  + new Icon('school20.png').range(1500, 3000) + new Icon('school40.png').range(-1, 1500)
  • 35. Styling - Theming >>> from geoscript.style Stroke, Fill, Label >>> style = Stroke() + Label('STATE_ABBR', 14, 'Serif') >>> style += Fill('#4DFF4D', 0.7)       .where('PERSONS < 2000000') >>> style += Fill('#FF4D4D', 0.7)       .where('PERSONS BETWEEN 2000000 AND 4000000') >>> style += Fill('#4D4DFF', 0.7)       .where('PERSONS > 4000000')
  • 36. Demos
  • 37.
  • 38. Gradient  Example var Directory = require(&quot;geoscript/workspace&quot;).Directory; var {Fill, gradient} = require(&quot;geoscript/style&quot;); var Map = require(&quot;geoscript/map&quot;).Map; var states = Directory(&quot;data&quot;).get(&quot;states&quot;); states.style = gradient({     expression: &quot;PERSONS / LAND_KM&quot;,      values: [0, 200],      styles: [Fill(&quot;#000066&quot;), Fill(&quot;red&quot;)],     classes: 10,      method: &quot;exponential&quot; }).and(     Fill(&quot;red&quot;).where(&quot;PERSONS / LAND_KM > 200&quot;) ); var map = Map([states]); map.render({path: &quot;states.png&quot;});
  • 39. Shapefile to PostGIS from geoscript.workspace import Directory, PostGIS shps = Directory('shapefiles') shps.layers() archsites = shps['archsites'] archsites.proj.id pg = PostGIS('demo') pg.layers() for layer in shps:   reprojected = shps[layer].reproject('epsg:4326')   pg.add(reprojected, name=layer) pg.layers() archsites = pg['archsites'] archsites.proj.id
  • 40.
  • 41.
  • 43.
  • 44.
  • 45. USGS Earth Quakes Read RSS Feed to a Shapefile
  • 46.
  • 47.
  • 49. Geometry Web Services Open Layers function centroid() {     var features = vectorLayer.features;     if (features.length == 0) {       alert(&quot;Please add some features!&quot;);     } else {       OpenLayers.loadURL('centroid', {             geom: wktFormat.write(features)           },            this,            function(request) {             var wkt = request.responseText;             var features = wktFormat.read(wkt);             if (features) vectorLayer.addFeatures(features);           },            function() {             alert(&quot;Error calculating centroids!&quot;);           }       );     } }
  • 50.
  • 51. WMS Server... import geoscript.map.Map import geoscript.style.* import geoscript.layer.Shapefile import geoscript.geom.Bounds def file = new File(&quot;states.shp&quot;) def shp = new Shapefile(file) shp.style = new Fill(&quot;steelblue&quot;) + new Stroke(&quot;wheat&quot;, 0.1) def map = new Map(     width: 256,      height: 256,      layers: [shp],     proj: shp.proj,     fixAspectRatio: false ) def bbox = request.getParameter(&quot;BBOX&quot;).split(&quot;,&quot;) def bounds = new Bounds(bbox[0] as double, bbox[1] as double, bbox[2] as double, bbox[3] as double) map.bounds = bounds response.contentType = &quot;image/png&quot; map.render(response.outputStream) map.close()
  • 52.