[gdal-dev] Ogr remove multiples Polygones of a Multipolygone
Benjamin
benjamin.lux at maxsea.fr
Fri Aug 3 06:46:00 PDT 2012
Hi,
I want to remove polygones who have a "little" area from a Mulipolygone.
My multipolygone may be verry complex.
I have write :
[code]
// geom OGRGEOMETRY of type wkbGeometryType.wkbMultiPolygone
// surfaceMin is an int
for (int i = 0; i < geom.GetGeometryCount(); i++)
{
// If we have remove all polygone geometries of geom unless one
if (geom.GetGeometryType() != wkbGeometryType.wkbPolygon)
return geom.Area() >= surfaceMin;
// else if the polygone n°i is too little ...
if (geom.GetGeometryRef(i).Area() < surfaceMin)
{
// ... we remove it.
geom = geom.Difference(geom.GetGeometryRef(i));
i = 0;
}
}
[/code]
Note : I can use Geometry::Difference because my polygones aren't stack
(poly1.Intersection(poly2) is all the time false).
There is a neater solution ?
1/
When you use Difference(Pi), the last polygon of the multipolygone go at the
indice i ?
ex :
MP as a geometry with a multipolygone type
MP : P1, P2, P3, P4
MP.Difference(P2) : P1.Difference(P2), P3.Difference(P2), P4.Difference(P4)
?
if yes, i can write :
"i--" and not "i=0", and not test every time sames first polygones ...
2/
Maybe there is an other way, and not use Difference(Pi) but a hidden methode
near "Remove(Pi)" ?
3/
Do you think that create a new multipolygon is a better solution ?
And add just "big" Polygons with Geometry.AddGeometry(Geometry).
Then, AddGeometry() or AddGeometryDirectly() ?
This 2 methods aren't in the OGR API
(http://www.gdal.org/ogr/classOGRGeometry.html) but in my C# wrapper.
Best regards,
Benjamin
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/gdal-dev-Ogr-remove-multiples-Polygones-of-a-Multipolygone-tp4992980.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list