SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Rendering Maps in
GeoScript
Jared Erickson
CUGOS September 2012
Friday, September 21, 2012
What is GeoScript?
• Geospatial Scripting on the JVM
• One API Four Languages
• Python
• JavaScript
• Scala
• Groovy
• Built on the shoulders of giants (GeoTools, JTS)
Friday, September 21, 2012
Java Tribe
Friday, September 21, 2012
GeoScript Modules
Friday, September 21, 2012
Styling
• geoscript.style module
• Symbolizer and Composite
• Symbolizer
• where: Filter
• range: min and max scale
• zindex: drawing order
• Composite:Two or more Symbolizers
Friday, September 21, 2012
Rendering
• geoscript.render module
• Draw and Plot shortcuts
• draw/plot to image, gui, or file
• Map for complicate rendering
• Image, PDF, SVG, GUI outputs
Friday, September 21, 2012
Stroke
• Symbolizer for Linear geometries
• color, width, opacity, dash, cap, join, hatch,
shape
1 import geoscript.layer.Shapefile
2 import geoscript.style.Stroke
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Stroke("#999999",0.1)
7 draw(shp)
Friday, September 21, 2012
Fill
• Symbolizer for Polygon geometries
• color, opacity,hatch,icon
1 import geoscript.layer.Shapefile
2 import geoscript.style.Fill
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Fill("wheat",0.5)
7 draw(shp, out: "fill.png")
Friday, September 21, 2012
Shape
• Symbolizer for Point geometries
• type, color, size, opacity, rotation, stroke
1 import geoscript.layer.Shapefile
2 import geoscript.style.Shape
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states_centroids.shp")
6 shp.style = new Shape("#008080", 8, "circle", 0.55)
7 draw(shp, out: "shape.png")
Friday, September 21, 2012
Icon
• Symbolizer using external files
• url, format (svg, png, gif, jpeg), size
1 import geoscript.layer.Shapefile
2 import geoscript.style.Icon
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states_centroids.shp")
6 shp.style = new Icon("library.svg", "image/svg", 12)
7 draw(shp, out: "icon.png")
Friday, September 21, 2012
Composite
• Two or more Symbolizers
• Used to create complicated styles
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Fill("wheat",0.5) + new Stroke("black",0.2)
7 draw(shp, out: "composite.png")
Friday, September 21, 2012
Where
• Apply Symbolizers to some features
• Uses CQL or Common Query Language
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Stroke("black",0.1) + new Label(property:
"STATE_ABBR", font: new Font(size: 14, family: "Serif"))
7 shp.style += new Fill("#4DFF4D", 0.7).where("PERSONS < 2000000")
8 shp.style += new Fill("#FF4D4D", 0.7).where("PERSONS BETWEEN
2000000 AND 4000000")
9 shp.style += new Fill("#4D4DFF", 0.7).where("PERSONS > 4000000")
10 draw(shp, out: "where.png")
Friday, September 21, 2012
Z-index
• Order Symbolizers
1 import geoscript.layer.Shapefile
2 import geoscript.style.Stroke
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Stroke("black",2.0).zindex(0) +
new Stroke("white", 0.1).zindex(1)
7 draw(shp, out: "zindex.png")
Friday, September 21, 2012
Scale
• Scale dependent styles
1 import geoscript.geom.Bounds
2 import geoscript.layer.Shapefile
3 import geoscript.style.*
4 import static geoscript.render.Draw.*
5
6 shp = new Shapefile("states.shp")
7 shp.style = (new Fill("wheat",0.5) + new Stroke("black",0.2)) + new
Label("STATE_ABBR").font(size:24).range(max: 16000000)
8 draw(shp, out: "scale1.png")
9 draw(shp, out: "scale2.png", bounds: new Bounds(-105, 35, -95, 45))
Friday, September 21, 2012
Transform
• Dynamically transform values
• String/Date formatting
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = (new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)) +
7 (new Shape("#66CCff", 6, "circle").stroke("#004080") + new
Transform("centroid(the_geom)")).zindex(1) +
8 (new Label("STATE_ABBR").font(new Font("normal", "bold", 10,
"serif")).fill(new Fill("#004080")))
9
10 draw(shp, out: "function.png")
Friday, September 21, 2012
Expressions
• geoscript.filter module
• Most style properties are Expressions
• Expression, Property, Function, Color
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import geoscript.filter.Function
4 import static geoscript.render.Draw.*
5
6 shp = new Shapefile("states.shp")
7 shp.style = (new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)) +
8 (new Label(new Function("strToLowerCase(STATE_ABBR)")).font
(new Font("normal", "bold", 20, "serif")).fill(new Fill("#004080")))
9
10 draw(shp, out: "expression.png")
Friday, September 21, 2012
Gradient
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import geoscript.filter.Expression
4 import static geoscript.render.Draw.*
5
6 shp = new Shapefile("states.shp")
7 shp.style = new Gradient(
8 new Expression("PERSONS / LAND_KM"),
9 [0,200],
10 [new Fill("#000066") + new Stroke("black",0.1),
11 new Fill("red") + new Stroke("black", 0.1)],
12 10,
13 "exponential")
14
15 draw(shp, out: "gradient.png")
Friday, September 21, 2012
Another Gradient
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Gradient(shp, "WORKERS", "Quantile", 5, "Greens")
7 draw(shp, out: "gradient2.png")
• Color brewer: geoscript.filter.Color
• getPaletteNames(String type = “all”)
• getPaletteColors(String name, int count = -1)
Friday, September 21, 2012
UniqueValues
• Symbolizer for unique values
• colors can be palette name, closure, or list
1 import geoscript.layer.Shapefile
2 import geoscript.style.UniqueValues
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new UniqueValues(shp, "STATE_ABBR", "Greens")
7 draw(shp, out: "uniquevalues.png")
Friday, September 21, 2012
SLD
• The standard way of styling GIS data
• Kind of verbose
• geoscript.style.io module can read and
write SLD
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import geoscript.style.io.*
4 import static geoscript.render.Draw.*
5
6 def style = new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)
7 new SLDWriter().write(style, new File("states.sld"))
8
9 shp = new Shapefile("states.shp")
10 shp.style = new SLDReader().read(new File("states.sld"))
11 draw(shp, out: "sld.png")
Friday, September 21, 2012
1 <?xml version="1.0" encoding="UTF-8"?>
2 <sld:UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
3 <sld:Name>Default Styler</sld:Name>
4 <sld:Title/>
5 <sld:FeatureTypeStyle>
6 <sld:Name>name</sld:Name>
7 <sld:Rule>
8 <sld:PolygonSymbolizer>
9 <sld:Fill>
10 <sld:CssParameter name="fill">#E6E6E6</sld:CssParameter>
11 </sld:Fill>
12 </sld:PolygonSymbolizer>
13 <sld:LineSymbolizer>
14 <sld:Stroke>
15 <sld:CssParameter name="stroke">#4C4C4C</sld:CssParameter>
16 <sld:CssParameter name="stroke-width">0.5</sld:CssParameter>
17 </sld:Stroke>
18 </sld:LineSymbolizer>
19 </sld:Rule>
20 </sld:FeatureTypeStyle>
21 </sld:UserStyle>
1 def style = new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)
SLD
vs
Friday, September 21, 2012
CSS
• CSS for maps!
• Read only
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import geoscript.style.io.*
4 import static geoscript.render.Draw.*
5
6 shp = new Shapefile("states.shp")
7 shp.style = new CSSReader().read("""
8 states {
9 fill: "#FFEBC3";
10 stroke: "#342D36";
11 }
12 """)
13 draw(shp, out: "css.png")
Friday, September 21, 2012
Map
• geoscript.render.Map
• Good for complicated maps with many
layers
Friday, September 21, 2012
Map
1 import geoscript.layer.Shapefile
2 import geoscript.layer.io.CsvReader
3 import geoscript.style.*
4 import geoscript.render.Map
5
6 def dir = "/Users/jericks/Projects/NaturalEarth/SmallScale"
7
8 def ocean = new Shapefile("${dir}/110m_Physical/110m_ocean.shp")
9 ocean.style = new Fill("#66CCFF")
10
11 def countries = new Shapefile("${dir}/110m_Cultural/110m_admin_0_countries.shp")
12 countries.style = new Stroke("#666666",0.5) + new Fill("#E6E6E6")
13
14 def graticlues = new Shapefile("${dir}/110m_physical/110m_graticules_all/
110m_graticules_30.shp")
15 graticlues.style = new Stroke("#CCCCCC",0.1)
16
17 def bbox = new Shapefile("${dir}/110m_physical/110m_graticules_all/
110m_wgs84_bounding_box.shp")
18 bbox.style = new Stroke("#4C4C4C",0.8)
19
20 def pplaces = new Shapefile("${dir}/110m_cultural/110m_populated_places.shp")
21 pplaces.style = new Shape("#CCCCCC",3,"circle",0.55).stroke("#B3B3B3")
22
Friday, September 21, 2012
23 def earthquakes = new CsvReader("Lon","Lat").read(
24 new URL("http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-
M2.5.txt").text
25 )
26 earthquakes.style = (new Shape("#FF6666", 4, "circle").stroke("#8000000",
0.1)).where("Magnitude < 3")
27 earthquakes.style += (new Shape("#FF6666", 6, "circle").stroke("#8000000",
0.1)).where("Magnitude BETWEEN 3 AND 6")
28 earthquakes.style += (new Shape("#FF6666", 10, "circle").stroke("#8000000",
0.1)).where("Magnitude > 6")
29
30 def map = new Map(layers: [ocean,countries,graticlues,bbox,pplaces,earthquakes])
31 map.render(new File("map.png"))
Map...
Friday, September 21, 2012
PDF
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import geoscript.render.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Fill("wheat",0.5) + new Stroke("black",0.2)
7 Map map = new Map(layers:[shp])
8 Pdf pdf = new Pdf()
9 pdf.render(map, new FileOutputStream(new File("map.pdf")))
Friday, September 21, 2012
SVG
1 import geoscript.layer.Shapefile
2 import geoscript.style.*
3 import static geoscript.render.Draw.*
4
5 shp = new Shapefile("states.shp")
6 shp.style = new Fill("wheat",0.5) + new Stroke("black",
0.2)
7 draw(shp, out: "map.svg", format: "svg")
Friday, September 21, 2012
Uses
• Quickly view results of analysis
• Preview & Create SLD
• Creating map series
• Simple WMS/TMS/WMST services
• UTF-8, MBTiless
Friday, September 21, 2012
Thank you!
Friday, September 21, 2012

Más contenido relacionado

La actualidad más candente

Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Provectus
 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript名辰 洪
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017名辰 洪
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! GrailsプラグインTsuyoshi Yamamoto
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)Felix Geisendörfer
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerOrtus Solutions, Corp
 
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisGroovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisJenn Strater
 
Dirty - How simple is your database?
Dirty - How simple is your database?Dirty - How simple is your database?
Dirty - How simple is your database?Felix Geisendörfer
 
Building High Performance Web Applications and Sites
Building High Performance Web Applications and SitesBuilding High Performance Web Applications and Sites
Building High Performance Web Applications and Sitesgoodfriday
 
Scripting GeoServer with GeoScript
Scripting GeoServer with GeoScriptScripting GeoServer with GeoScript
Scripting GeoServer with GeoScriptJustin Deoliveira
 
Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Tsuyoshi Yamamoto
 

La actualidad más candente (18)

Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
Rest, sockets em golang
Rest, sockets em golangRest, sockets em golang
Rest, sockets em golang
 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
Grails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLTGrails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLT
 
Tp web
Tp webTp web
Tp web
 
Web2.0 with jQuery in English
Web2.0 with jQuery in EnglishWeb2.0 with jQuery in English
Web2.0 with jQuery in English
 
Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)
 
Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)
 
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
 
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisGroovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
 
Dirty - How simple is your database?
Dirty - How simple is your database?Dirty - How simple is your database?
Dirty - How simple is your database?
 
Building High Performance Web Applications and Sites
Building High Performance Web Applications and SitesBuilding High Performance Web Applications and Sites
Building High Performance Web Applications and Sites
 
Scripting GeoServer with GeoScript
Scripting GeoServer with GeoScriptScripting GeoServer with GeoScript
Scripting GeoServer with GeoScript
 
Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。
 

Similar a Rendering Maps in GeoScript

Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Kevin Lee
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping VisualizationSudhir Chowbina
 
From Shabby to Chic
From Shabby to ChicFrom Shabby to Chic
From Shabby to ChicRichard Bair
 
A la découverte de TypeScript
A la découverte de TypeScriptA la découverte de TypeScript
A la découverte de TypeScriptDenis Voituron
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
The Web map stack on Django
The Web map stack on DjangoThe Web map stack on Django
The Web map stack on DjangoPaul Smith
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterJorge Arevalo
 
Stegosploit - NCSC ONE 2016
Stegosploit - NCSC ONE 2016Stegosploit - NCSC ONE 2016
Stegosploit - NCSC ONE 2016Saumil Shah
 
Barcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kóduBarcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kóduMilos Lenoch
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceOSCON Byrum
 
Drawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the WebDrawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the WebCloudinary
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece CoLab Athens
 
Opensource gis development - part 3
Opensource gis development - part 3Opensource gis development - part 3
Opensource gis development - part 3Andrea Antonello
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Helder da Rocha
 
Understanding Connected Data through Visualization
Understanding Connected Data through VisualizationUnderstanding Connected Data through Visualization
Understanding Connected Data through VisualizationSebastian Müller
 

Similar a Rendering Maps in GeoScript (20)

Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping Visualization
 
From Shabby to Chic
From Shabby to ChicFrom Shabby to Chic
From Shabby to Chic
 
A la découverte de TypeScript
A la découverte de TypeScriptA la découverte de TypeScript
A la découverte de TypeScript
 
Pycon2011
Pycon2011Pycon2011
Pycon2011
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
The Web map stack on Django
The Web map stack on DjangoThe Web map stack on Django
The Web map stack on Django
 
OWC 2012 (Open Web Camp)
OWC 2012 (Open Web Camp)OWC 2012 (Open Web Camp)
OWC 2012 (Open Web Camp)
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
 
Stegosploit - NCSC ONE 2016
Stegosploit - NCSC ONE 2016Stegosploit - NCSC ONE 2016
Stegosploit - NCSC ONE 2016
 
Barcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kóduBarcamp GoogleMaps - praktické ukázky kódu
Barcamp GoogleMaps - praktické ukázky kódu
 
Google Maps API 101
Google Maps API 101Google Maps API 101
Google Maps API 101
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
 
Drawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the WebDrawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the Web
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
Opensource gis development - part 3
Opensource gis development - part 3Opensource gis development - part 3
Opensource gis development - part 3
 
ECMA5 and ES6 Promises
ECMA5 and ES6 PromisesECMA5 and ES6 Promises
ECMA5 and ES6 Promises
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)
 
Understanding Connected Data through Visualization
Understanding Connected Data through VisualizationUnderstanding Connected Data through Visualization
Understanding Connected Data through Visualization
 

Último

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Rendering Maps in GeoScript

  • 1. Rendering Maps in GeoScript Jared Erickson CUGOS September 2012 Friday, September 21, 2012
  • 2. What is GeoScript? • Geospatial Scripting on the JVM • One API Four Languages • Python • JavaScript • Scala • Groovy • Built on the shoulders of giants (GeoTools, JTS) Friday, September 21, 2012
  • 5. Styling • geoscript.style module • Symbolizer and Composite • Symbolizer • where: Filter • range: min and max scale • zindex: drawing order • Composite:Two or more Symbolizers Friday, September 21, 2012
  • 6. Rendering • geoscript.render module • Draw and Plot shortcuts • draw/plot to image, gui, or file • Map for complicate rendering • Image, PDF, SVG, GUI outputs Friday, September 21, 2012
  • 7. Stroke • Symbolizer for Linear geometries • color, width, opacity, dash, cap, join, hatch, shape 1 import geoscript.layer.Shapefile 2 import geoscript.style.Stroke 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Stroke("#999999",0.1) 7 draw(shp) Friday, September 21, 2012
  • 8. Fill • Symbolizer for Polygon geometries • color, opacity,hatch,icon 1 import geoscript.layer.Shapefile 2 import geoscript.style.Fill 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Fill("wheat",0.5) 7 draw(shp, out: "fill.png") Friday, September 21, 2012
  • 9. Shape • Symbolizer for Point geometries • type, color, size, opacity, rotation, stroke 1 import geoscript.layer.Shapefile 2 import geoscript.style.Shape 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states_centroids.shp") 6 shp.style = new Shape("#008080", 8, "circle", 0.55) 7 draw(shp, out: "shape.png") Friday, September 21, 2012
  • 10. Icon • Symbolizer using external files • url, format (svg, png, gif, jpeg), size 1 import geoscript.layer.Shapefile 2 import geoscript.style.Icon 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states_centroids.shp") 6 shp.style = new Icon("library.svg", "image/svg", 12) 7 draw(shp, out: "icon.png") Friday, September 21, 2012
  • 11. Composite • Two or more Symbolizers • Used to create complicated styles 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Fill("wheat",0.5) + new Stroke("black",0.2) 7 draw(shp, out: "composite.png") Friday, September 21, 2012
  • 12. Where • Apply Symbolizers to some features • Uses CQL or Common Query Language 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Stroke("black",0.1) + new Label(property: "STATE_ABBR", font: new Font(size: 14, family: "Serif")) 7 shp.style += new Fill("#4DFF4D", 0.7).where("PERSONS < 2000000") 8 shp.style += new Fill("#FF4D4D", 0.7).where("PERSONS BETWEEN 2000000 AND 4000000") 9 shp.style += new Fill("#4D4DFF", 0.7).where("PERSONS > 4000000") 10 draw(shp, out: "where.png") Friday, September 21, 2012
  • 13. Z-index • Order Symbolizers 1 import geoscript.layer.Shapefile 2 import geoscript.style.Stroke 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Stroke("black",2.0).zindex(0) + new Stroke("white", 0.1).zindex(1) 7 draw(shp, out: "zindex.png") Friday, September 21, 2012
  • 14. Scale • Scale dependent styles 1 import geoscript.geom.Bounds 2 import geoscript.layer.Shapefile 3 import geoscript.style.* 4 import static geoscript.render.Draw.* 5 6 shp = new Shapefile("states.shp") 7 shp.style = (new Fill("wheat",0.5) + new Stroke("black",0.2)) + new Label("STATE_ABBR").font(size:24).range(max: 16000000) 8 draw(shp, out: "scale1.png") 9 draw(shp, out: "scale2.png", bounds: new Bounds(-105, 35, -95, 45)) Friday, September 21, 2012
  • 15. Transform • Dynamically transform values • String/Date formatting 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = (new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)) + 7 (new Shape("#66CCff", 6, "circle").stroke("#004080") + new Transform("centroid(the_geom)")).zindex(1) + 8 (new Label("STATE_ABBR").font(new Font("normal", "bold", 10, "serif")).fill(new Fill("#004080"))) 9 10 draw(shp, out: "function.png") Friday, September 21, 2012
  • 16. Expressions • geoscript.filter module • Most style properties are Expressions • Expression, Property, Function, Color 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import geoscript.filter.Function 4 import static geoscript.render.Draw.* 5 6 shp = new Shapefile("states.shp") 7 shp.style = (new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)) + 8 (new Label(new Function("strToLowerCase(STATE_ABBR)")).font (new Font("normal", "bold", 20, "serif")).fill(new Fill("#004080"))) 9 10 draw(shp, out: "expression.png") Friday, September 21, 2012
  • 17. Gradient 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import geoscript.filter.Expression 4 import static geoscript.render.Draw.* 5 6 shp = new Shapefile("states.shp") 7 shp.style = new Gradient( 8 new Expression("PERSONS / LAND_KM"), 9 [0,200], 10 [new Fill("#000066") + new Stroke("black",0.1), 11 new Fill("red") + new Stroke("black", 0.1)], 12 10, 13 "exponential") 14 15 draw(shp, out: "gradient.png") Friday, September 21, 2012
  • 18. Another Gradient 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Gradient(shp, "WORKERS", "Quantile", 5, "Greens") 7 draw(shp, out: "gradient2.png") • Color brewer: geoscript.filter.Color • getPaletteNames(String type = “all”) • getPaletteColors(String name, int count = -1) Friday, September 21, 2012
  • 19. UniqueValues • Symbolizer for unique values • colors can be palette name, closure, or list 1 import geoscript.layer.Shapefile 2 import geoscript.style.UniqueValues 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new UniqueValues(shp, "STATE_ABBR", "Greens") 7 draw(shp, out: "uniquevalues.png") Friday, September 21, 2012
  • 20. SLD • The standard way of styling GIS data • Kind of verbose • geoscript.style.io module can read and write SLD 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import geoscript.style.io.* 4 import static geoscript.render.Draw.* 5 6 def style = new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5) 7 new SLDWriter().write(style, new File("states.sld")) 8 9 shp = new Shapefile("states.shp") 10 shp.style = new SLDReader().read(new File("states.sld")) 11 draw(shp, out: "sld.png") Friday, September 21, 2012
  • 21. 1 <?xml version="1.0" encoding="UTF-8"?> 2 <sld:UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"> 3 <sld:Name>Default Styler</sld:Name> 4 <sld:Title/> 5 <sld:FeatureTypeStyle> 6 <sld:Name>name</sld:Name> 7 <sld:Rule> 8 <sld:PolygonSymbolizer> 9 <sld:Fill> 10 <sld:CssParameter name="fill">#E6E6E6</sld:CssParameter> 11 </sld:Fill> 12 </sld:PolygonSymbolizer> 13 <sld:LineSymbolizer> 14 <sld:Stroke> 15 <sld:CssParameter name="stroke">#4C4C4C</sld:CssParameter> 16 <sld:CssParameter name="stroke-width">0.5</sld:CssParameter> 17 </sld:Stroke> 18 </sld:LineSymbolizer> 19 </sld:Rule> 20 </sld:FeatureTypeStyle> 21 </sld:UserStyle> 1 def style = new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5) SLD vs Friday, September 21, 2012
  • 22. CSS • CSS for maps! • Read only 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import geoscript.style.io.* 4 import static geoscript.render.Draw.* 5 6 shp = new Shapefile("states.shp") 7 shp.style = new CSSReader().read(""" 8 states { 9 fill: "#FFEBC3"; 10 stroke: "#342D36"; 11 } 12 """) 13 draw(shp, out: "css.png") Friday, September 21, 2012
  • 23. Map • geoscript.render.Map • Good for complicated maps with many layers Friday, September 21, 2012
  • 24. Map 1 import geoscript.layer.Shapefile 2 import geoscript.layer.io.CsvReader 3 import geoscript.style.* 4 import geoscript.render.Map 5 6 def dir = "/Users/jericks/Projects/NaturalEarth/SmallScale" 7 8 def ocean = new Shapefile("${dir}/110m_Physical/110m_ocean.shp") 9 ocean.style = new Fill("#66CCFF") 10 11 def countries = new Shapefile("${dir}/110m_Cultural/110m_admin_0_countries.shp") 12 countries.style = new Stroke("#666666",0.5) + new Fill("#E6E6E6") 13 14 def graticlues = new Shapefile("${dir}/110m_physical/110m_graticules_all/ 110m_graticules_30.shp") 15 graticlues.style = new Stroke("#CCCCCC",0.1) 16 17 def bbox = new Shapefile("${dir}/110m_physical/110m_graticules_all/ 110m_wgs84_bounding_box.shp") 18 bbox.style = new Stroke("#4C4C4C",0.8) 19 20 def pplaces = new Shapefile("${dir}/110m_cultural/110m_populated_places.shp") 21 pplaces.style = new Shape("#CCCCCC",3,"circle",0.55).stroke("#B3B3B3") 22 Friday, September 21, 2012
  • 25. 23 def earthquakes = new CsvReader("Lon","Lat").read( 24 new URL("http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day- M2.5.txt").text 25 ) 26 earthquakes.style = (new Shape("#FF6666", 4, "circle").stroke("#8000000", 0.1)).where("Magnitude < 3") 27 earthquakes.style += (new Shape("#FF6666", 6, "circle").stroke("#8000000", 0.1)).where("Magnitude BETWEEN 3 AND 6") 28 earthquakes.style += (new Shape("#FF6666", 10, "circle").stroke("#8000000", 0.1)).where("Magnitude > 6") 29 30 def map = new Map(layers: [ocean,countries,graticlues,bbox,pplaces,earthquakes]) 31 map.render(new File("map.png")) Map... Friday, September 21, 2012
  • 26. PDF 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import geoscript.render.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Fill("wheat",0.5) + new Stroke("black",0.2) 7 Map map = new Map(layers:[shp]) 8 Pdf pdf = new Pdf() 9 pdf.render(map, new FileOutputStream(new File("map.pdf"))) Friday, September 21, 2012
  • 27. SVG 1 import geoscript.layer.Shapefile 2 import geoscript.style.* 3 import static geoscript.render.Draw.* 4 5 shp = new Shapefile("states.shp") 6 shp.style = new Fill("wheat",0.5) + new Stroke("black", 0.2) 7 draw(shp, out: "map.svg", format: "svg") Friday, September 21, 2012
  • 28. Uses • Quickly view results of analysis • Preview & Create SLD • Creating map series • Simple WMS/TMS/WMST services • UTF-8, MBTiless Friday, September 21, 2012