At 08:45 AM 3/26/2011 +0100, Andrea Aime wrote:
Andrea, thank you for the suggestions.
I have a clarification, a comment, and a question on your procedures.
The clarificationis: For my application, the resulting geometries, for my
application need not be polygons, although polygons are accepetable. In
fact, I will ultimately render them (after much more conversion outside the
shapefile/GIS realm) using line strings. The reason is that if I simply
eliminate the duplicate line segments in the intersections, I can still
completely bound all of the space by drawing line segments.
The comment is : If I simplify each line, the endpoints must not change or
here will be gaps or overlaps. I think the TopologyPreservingSimplifier
does this but I'm not sure. Also, would it be better to node and union all
the resulting line strings to the simplifier will work on one big geometry?
Is there a way to do this without creating lines I don't need?
The question is due to my weak understanding of the API: Given a collection
of LineString geometries (say, Array or LinkedList) of line strings, how
can I turn that back into a shapefile?
My problem is I don't know the correct Java code to create the
SimpleFeatureType for a collection of LineString geometries when all I had
originally was a shapefile full of multi-polygons. Once I have the type, I
know how to create the SimpleFeatureCollection and ultimately the shape file.
Thanks
John
On Wed, Mar 23, 2011 at 4:58 AM, John Moore <[email protected]> wrote:
> I have a set of polygons representing the boundaries of United States
> Counties. Each county adjoins one or more other counties, so they share
> common boundaries. This means that there are cases where a line segment in
> county A's polygon is within a line segment of County B's polygon.
There are
> other similar cases, all in which part of the line of one county is the
same
> as part or all of the line of another county.
>
> I need to apply a simplifying algorithm to the county lines to reduce the
> number of points in them (for example, using
TopologyPreservingSimplifier ).
>
> However, since these lines are not identical, if I simply apply the
> simplification to each county independently, the result is that the
> boundaries which were identical are no longer so.
Solving this problem is not trivial I believe.
As far as I know this process would work:
- dismantle the set of polygons into a set of plain lines
- node the lines by intersection so each arc has only
two polygons touching it, a left and a right one (and
somehow remember these two labels, they will be needed
afterwards)
- remove the duplicate lines resulting out of the intersection,
for each two touching polygons you should get a couple
of (mostly) identical segments
- simplify each line
- rebuild the polygons by using the label you attached before
The hard part is in the first two steps... here is something that
_might_ work. For each polygon, find all adjacents ones, compute
the intersection, if they touch perfectly you'll get the shared segment
that you can label.
Once you've done with all the neighbours you still have to find out
the segments that were not shared with any other polygon, I _think_
you can collect all the rings of the polygon in a multi line string
and do a difference (subtract), which should leave you with the
parts that did not overlap with anything else.
You'll label each segment with the neighbouring polygons ids during
the process, you can store that in the user data or create a map
from polygon id to the list of its segments.
Then you do the simplification segment by segment, and rebuild
the polygons using the JTS polygonizer.
There are still quite a bit of gotchas in this approach:
- it assumes everything is perfectly lining up (I guess you can have
a look ath JTS precision models to handle part of this)
- by simplifying lines alone you can occasionally get holes in polygons
that after the simplification end up touching or intersecting the
outer shell (they have to be very close to it to start with, but still)
I do hope this does not send you down the wrong path, did not do it
before so take the above with a (maybe many?) pinch of salt.
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users