Skip to content

Instantly share code, notes, and snippets.

@jericks
Created November 18, 2014 03:31
Show Gist options
  • Save jericks/6a88422bcea5129f927e to your computer and use it in GitHub Desktop.
Save jericks/6a88422bcea5129f927e to your computer and use it in GitHub Desktop.
import geoscript.layer.Shapefile
import geoscript.layer.io.CsvReader
import geoscript.style.*
import geoscript.render.Map
import geoscript.geom.Bounds
def dir = "/Users/jericks/Projects/NaturalEarth/SmallScale"
def ocean = new Shapefile("${dir}/110m_Physical/110m_ocean.shp")
ocean.style = new Fill("#66CCFF")
def countries = new Shapefile("${dir}/110m_Cultural/110m_admin_0_countries.shp")
countries.style = new Stroke("#666666",0.5) + new Fill("#E6E6E6")
def graticlues = new Shapefile("${dir}/110m_physical/110m_graticules_all/110m_graticules_30.shp")
graticlues.style = new Stroke("#CCCCCC",0.1)
def bbox = new Shapefile("${dir}/110m_physical/110m_graticules_all/110m_wgs84_bounding_box.shp")
bbox.style = new Stroke("#4C4C4C",0.8)
def pplaces = new Shapefile("${dir}/110m_cultural/110m_populated_places.shp")
pplaces.style = new Shape("#CCCCCC",3,"circle",0.55).stroke("#B3B3B3")
def earthquakes = new CsvReader("Lon","Lat").read(
new URL("http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt").text
)
earthquakes.style = (new Shape("#FF6666", 8, "circle").stroke("#8000000",0.1)).where("Magnitude < 3")
earthquakes.style += (new Shape("#FF6666", 12, "circle").stroke("#8000000",0.1)).where("Magnitude BETWEEN 3 AND 6")
earthquakes.style += (new Shape("#FF6666", 16, "circle").stroke("#8000000",0.1)).where("Magnitude > 6")
def map = new Map(
layers: [ocean,countries,graticlues,bbox,pplaces,earthquakes],
bounds: new Bounds(-180,-90,180,90,"EPSG:4326"),
width: 1600,
height: 800,
proj: "EPSG:4326"
)
map.render(new File("earthquakes.png"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment