Skip to content

Instantly share code, notes, and snippets.

@jericks
Created March 11, 2012 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jericks/2017856 to your computer and use it in GitHub Desktop.
Save jericks/2017856 to your computer and use it in GitHub Desktop.
layer transformation and cleaning
import geoscript.layer.Shapefile
import geoscript.proj.Projection
import geoscript.feature.Field
def shp = new Shapefile("test_uk.shp")
def out = shp.workspace.create(shp.schema.reproject("EPSG:27700", "test_uk_valid"))
out.add(shp.cursor.collect{f ->
f.geom = Projection.transform(f.geom, "EPSG:4326", "EPSG:27700")
if (!f.geom.isValid()) {
f.geom = f.geom.buffer(0)
}
f
})
geoscript.render.Draw.draw(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment