Thanks Martin and Stefan,  I am looking into
TopologyPreservingSimplifier and it appears that does exactly what I
need.

I ran a quick test against a map of the US broken out by state and got
the SHP file from 2,100K down to 200K and the level of detail is still
sufficient for my application.  I'd like to get it smaller but if I
set the simplification level higher than 0.01 the state borders don't
line up with each other.  I think this is where your additional steps
come in.  Here's my quick test code...

File source = new File(sourceShpfile);
ShapefileReader sr = new ShapefileReader();
DriverProperties dpSource = new DriverProperties( source.getCanonicalPath());
FeatureCollection features = sr.read(dpSource);

for (Iterator iter = features.iterator(); iter.hasNext();) {
        Feature f = (Feature) iter.next();
        Geometry 
tmp=TopologyPreservingSimplifier.simplify(f.getGeometry(),0.01);
        f.setGeometry(tmp);
}

File dest = new File(destShpfile);
DriverProperties dpDest = new DriverProperties( dest.getCanonicalPath());
ShapefileWriter sw= new ShapefileWriter();
sw.write(features, dpDest);

I'll try to implement your suggestions, but any other tips would be welcome.

Thanks again,
~ Chris

> I assume that your dataset forms a polygonal coverage, right?  If so,
> you can't just simplify each polygon individually - you need to process
> them all together, to ensure that coverage topology is maintained.
>
> In this case, you need to do the following:
> - dissolve the boundaries of the polygons to form unique line segments
> - merge the line segments into linestrings which do not cross
> - simplify the resulting linestrings (using
> TopologyPreservingSimplifier, to avoid introducing intersections'
> - polygonize the resulting line set
> - use point-in-polygon tests to reattach the original polygon attributes
> to the simplified polygons.
>
> You can do all this with the JUMP and JTS APIs - but there will be a bit
> of code required to glue all the pieces together.
_______________________________________________
jump-users mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jump-users

Reply via email to