[udig-devel] How can we find intersection of two geometries?
Jesse Eichar
jeichar at refractions.net
Wed Apr 4 12:58:37 PDT 2007
Look at the JTS API. All the geometries are JTS geometries. If I
remember correctly there is an intersection method or something like
that that will create the intersected geometry. Then you have to
create a new feature with that geometry. Here's some pseudo code:
Geometry geom1 = feature1.getDefaultGeometry();
Geometry geom2 = feature2.getDefaultGeometry();
Geometry finalGeom = geom1.intersection(geom2);
FeatureTYpe type = feature1.getFeatureType();
Feature newFeature = type.createFeature( feature1.getAttributes() );
newFeatures.setDefaultGeometry( newFeature );
This uses the attributes from feature1 as the attributes for the new
feature.
Jesse
On Apr 4, 2007, at 10:02 AM, Sergiy Doroshenko wrote:
> Hi all!
>
> How can we create new feature from given one by intersecting its
> geometry by another geometry? For example, split given feature by
> rectangular grid and create new feature for every peace - in this case
> we need to find intersection of multipolygon and rectangles.
>
> Is there some udig's or geotools' instrument, or this geometrical
> operation can be done only with some 3d party libraries?
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
More information about the udig-devel
mailing list