At 09:37 PM 3/24/2011 +1100, Michael Bedward wrote:
Hi John,

Thanks for the quick and detailed response. I will be responding twice to this, on two different issues.

The first issue, which you addressed, is my problem with polygon boundaries with shared lines (or a line of one a shorter length part of a line of another).

I tried the code you supplied below, and it indeed did not generate the perverse effects I had seen before. Unfortunately, it did something else - probably intended, but not what I am seeking.

I'll restate this in ordinary language since, not being a GIS person, I may mislead if I use GIS specific terminology. I apologize for not making the problem clear.

...

There are two political boundaries, each a polygon, which bound adjacent territories and share part of a border.

I want to simplify the two polygons, but on the shared part of the border, have a consistent border. If I simplify them separately, the borders may simplify slightly differently due to different bounds on the shared lines, which results in a disappointing map when both are displayed at once.

The algorithm you supplied unfortunately *removes* the shared borders.

Here it is diagrammatically. The > and ^ shapes represent wiggles to be simplified out.

Original:

+---------------+
|               |
|               +---------+
|      A        |         |
|               \   B     |
|               /         |
|              /          +---------+
+-----v---------\                   |
                |                   |
                +-------------------+

Becomes with the method you sent:
+---------------+
|               |
|               +---------+
|                         |
|                         |
|                         |
|                         +---------+
+---------------+                   |
                |                   |
                +-------------------+

Instead of desired:
+---------------+
|               |
|               +---------+
|       A       |         |
|               |   B     |
|               |         |
|               |         +---------+
+---------------+                   |
                |                   |
                +-------------------+

If simplified separately, the result can be something like below (note the extra slanted line indicating the difference between the simplified boundary of A and the boundary of B:

+---------------+
|               |
|               +---------+
|      A        |         |
|               |    B    |
|               |         |
|              /|         +---------+
+-----v---------\                   |
                |                   |
                +-------------------+


At this stage, the "simplified" object will probably be a single
MultiPolygon (it's possible for it to be a single Polygon with holes
for some input data).  Now the tricky bit is associating the
components of your simplified Geometry with the original polygons so
that you can create a new SimpleFeatureCollection, copying across all
attributes from the original collection except for the geometries,
which you want to replace with your new polygons.

It is acceptable to have a single geometry for the whole thing.


Um... I'm tempted to see I leave that as an exercise for the reader
:-)  Instead I'll call out for help from other list members at this
point...

I *think* the best approach, for all but a tiny dataset, is to use a
spatial index (Quadtree of STRtree in JTS). Insert each of the
component polygons that make up the MultiPolygon object "simplified"
into the index. The you can iterate through your original feature
collection once more and use the bounds of each features geometry to
query the index and find the best matching polygon.

This also applies to my next response (next message)


If I think of a less involved way I'll let you know. Meanwhile, we can
also help others will chime in with better suggestions.

> Another question: I notice that all of the classes you use are in
> com.vividsolutions.jts packages. I am unclear as to when I should use those
> (in general) and when to use those in org.opengis or org.geotools.
>

The simple rule of thumb when working with shapefiles (and many other
data sources) is stick to JTS.

Thanks

This is example app is a good place to start:
http://docs.geotools.org/stable/userguide/examples/csv2shp.html


Thanks! That's a great example.

John

Hope that helps,

Michael
------------------------------------------------------------------------------
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

Reply via email to