[gdal-dev] Building a resizable polygon

Chaitanya kumar CH chaitanya.ch at gmail.com
Tue Apr 5 09:54:34 EDT 2011


Bill,

OGR's UnionCascaded() method is built on the GEOS library. There may be an
example in the autotest suite but it may not be as useful or necessary. I am
not sure which geometry type it accepts and returns, so you may have to
fiddle a bit.

Loop through all your polygons to fill them into an
OGRMultiPolygon object using addGeometryDirectly().
Note that the union result may be a MultiPolygon.

On Tue, Apr 5, 2011 at 6:41 PM, Cassanova, Bill <BCassanova at weather.com>wrote:

>  Thanks Chaitanya.  I will take a look.
>
>
>
> Do you know if GDAL has any example code buried somewhere within the source
> tree?  I am sure I will need to use UnionCascaded because there will be many
> polygons added and at first glance the
>
> Doxygen documentation doesn’t really provide a good starting place.
>
>
>
> So in my original example do I first need to create a OGRPolygon A, and
> OGRPolygon B, and then an OGRMultiPolygon C and then call
> C.addGeometryDirectly passing in a pointer to A and B
>
> And then call C.UnionCascaded?  The result of UnionCascased is a
> OGRGeometry object which I assume you would cast to OGRPolygon and then make
> calls into getX and getY to extract the new points?
>
>
>
>
>
> *From:* Chaitanya kumar CH [mailto:chaitanya.ch at gmail.com]
> *Sent:* Monday, April 04, 2011 5:44 PM
> *To:* Cassanova, Bill
> *Cc:* gdal-dev at lists.osgeo.org
> *Subject:* Re: [gdal-dev] Building a resizable polygon
>
>
>
> Bill,
>
> Either of OGRGeometry::Union() and OGRGeometry::UnionCascaded() should help
> you.
>
> I would choose the latter if there are more than two polygons. It operates
> on an OGRMultiPolygon object.
>
> On Tue, Apr 5, 2011 at 2:35 AM, Cassanova, Bill <BCassanova at weather.com>
> wrote:
>
> Hi All,
>
>
>
> I am looking for some direction on if GDAL has the capability has the
> ability to build a super-polygon from a series of small polygons…I have
> played a bit with the OGR Geometry classes but I can’t
>
> seem to quite get what I need.
>
>
>
> Let’s start with a simply example.
>
>
>
> Polygon A has vertices in (X,Y) format of <0, 0>, < 0,1>, <1,0>, <1,1>
>
> Polygon B has vertices in (x,y) format of < 1,0 >, <1,1>, <2,0>, <2,1>
>
>
>
> Since Polygon A and B share a common side with vertices < <1,0> and <1,1> I
> want to build super polygon that contains the coordinates of the outer
> perimeter of the points.
>
> When complete the new polygon C will thus have points <0,0>,<0,1>,<2,0>,
> <2,1>
>
>
>
> I had first looked at OGRPolygon.AddRing wherein A and B above would be
> OGRLinearRings and then by making a call to C.getExteriorRing() but this
> seem to report the first ring added.
>
>
>
> Am I heading in the correct direction or is this something that I will
> essentially have to do manually by first creating a OGRLinearRing from the
> vertices of polygon A, then creating a OGRPolygon to which I execute
> addRing.
>
> Then interrogating that ring to see which line segments are common between
> A and B and removing the ones that are common and adding the line segments
> that aren’t common.
>
>
>
> Thanks,
>
> Bill
>
> ++++
>
>
>
> William Cassanova | Senior GFS Developer | The Weather Channel |
> 770.226.2368 | bcassanova at weather.com
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>
> --
> Best regards,
> Chaitanya kumar CH.
> /tʃaɪθənjə/ /kʊmɑr/
> +91-9494447584
> 17.2416N 80.1426E
>



-- 
Best regards,
Chaitanya kumar CH.
/tʃaɪθənjə/ /kʊmɑr/
+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110405/ca1d169e/attachment.html


More information about the gdal-dev mailing list