SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Василевский Илья (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
 

Was ist angesagt? (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@ロンドンへ行ってきた報告。
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

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