Convex Hull
// Import GeoScript modules
import geoscript.layer.*
import geoscript.feature.*
import geoscript.geom.*
// Get the shapefile
Shapefile shp = new Shapefile('states_centroids.shp');
// Create a new Schema
Schema schema = new Schema('states_convex_hull', [['the_geom','Polygon','EPSG:4326']])
// Create our new Layer
Layer layer = shp.workspace.create(schema)
// Collect the Geometries
List geoms = shp.features.collect{f->f.geom}
// Create a GeometryCollection from the List of Geometries
GeometryCollection geomCol = new GeometryCollection(geoms)
// Get the Convex Hull from the GeometryCollection
Geometry convexHullGeom = geomCol.convexHull
// Add the Convex Hull Geometry as a Feature
layer.add(schema.feature([convexHullGeom]))
Minimum Bounding Circle
// Import GeoScript modules
import geoscript.layer.*
import geoscript.feature.*
import geoscript.geom.*
// Get the Shapefile
Shapefile shp = new Shapefile('states_centroids.shp')
// Create a new Schema
Schema schema = new Schema('states_minimum_bounding_circle', [['the_geom','Polygon','EPSG:4326']])
// Create the new Layer
Layer layer = shp.workspace.create(schema)
// Collect Geometries from the Shapefile
List geoms = shp.features.collect{f->f.geom}
// Create a GeometryCollection from the List of Geometries
GeometryCollection geomCol = new GeometryCollection(geoms)
// Get the Minimum Bounding Circle from the GeometryCollection
Geometry circleGeom = geomCol.minimumBoundingCircle
// Add the Minimum Bounding Circle Geometry as a Feature
layer.add(schema.feature([circleGeom]))
Jared (or anyone for that matter),
ReplyDeleteAre you aware of any implementations of the Douglas-Peucker or Lang Simplification algorithms in Groovy? Alternatively what about Java? I can port one over from C++ or other language but I'd hate to reinvent the wheel! TIA for any help.
Succeed! It could be one of the most useful blogs we have ever come across on the subject. Excellent info! I’m also an expert in this topic so I can understand your effort very well. Thanks for the huge help. バウンディング
ReplyDelete