[Qgis-developer] Points from polygon's geometry vertices

Martin Dobias wonder.sk at gmail.com
Mon Oct 29 09:30:05 PDT 2012


On Mon, Oct 29, 2012 at 3:58 PM, Dominik Fröhlich
<dominik.froehlich at venus.uni-freiburg.de> wrote:
> Hi again!
>
> Maybe you could also help me with an other issue: I need to save the
> coordinates of the polygon vertices to a list for later processing. I tried
> with "thepoints = thepoly.asMultiPoint()" but get an empty list.
> In the API Documentation I found that the function asMultPoint() needs a
> MultiPoint-geometry as input (what makes no sense to me, as I don't need to
> convert it if it is already MultiPoint…?).
>
> Is there an other function that does what I want, or am I calling the
> asMultiPoint function wrong?

Dominik,
if you have a polygon, then you need to use asPolygon() method. It
will give you list of rings (and each ring is a list of vertices). The
list of rings always has at least one ring (the outer one) - if there
are more rings then your polygon has some holes. The function
asMultiPoint() works only for geometry type MultiPoint (which is
something completely different, see [1]).

[1] http://upload.wikimedia.org/wikipedia/commons/4/4e/Geometrietypen.jpg

Martin


More information about the Qgis-developer mailing list