Hi Dr Haspel,

Thanks for the message. I did place the comma and it did not work out. I got the following message now:




*/ But I'm curious: what did you need that my macro isn't doing?

Your DBox is doing find exactly what you meant with your program. What I need is the individual area and perimeter of each polygon depicted in the geographic file, and I believe Armando's macro will do the trick. I hope it will create a list with a one to one relationship with the geographic file of my polygons. It should consider adjacent polygons topology. That means that if two polygons share a common boundary this line length should be added to to both of the polygon perimeters. Also, if a polygon is composed by several ones, like islands of an archipelago, there should be only one line in the database with the total area and perimeter of this complex polygon. I have seen that Armando's macro does not compute the area as yours does, but if I get the one to one table as result, I believe it can joined later to the layer dataview to get the area as well.

Thanks for your advice. Cheers,

Reinaldo



 
dr_haspel wrote:
 



Hi again Reinaldo,

You're just missing a comma. Instead of:
rh = GetFirstRecord (sLayerName + "|" + sSetName)

use:
rh = GetFirstRecord (sLayerName + "|" + sSetName, )

The second parameter in question is for the sort order. Maptitude will use the "natural order" of the database if you leave that value null, which in your case is fine (since the sort order is irrelevant for your application).

But I'm curious: what did you need that my macro isn't doing? It should compute both the outer perimeter of the selected area (whether the polygons are contiguous or not) and the length of any shared borders. If you need the sum of all perimeters, that is simply [the outer perimeter + (2 * the shared borders)] -- which is actually found in the macro as "perimeter_sum".

--- In [email protected], Reinaldo Paul P�rez Machado <rpmgis@...> wrote:
>
> /*Hi Armando,
>
> I found that there was lacking quotation marks around the name of the
> Layer. But now what follows is this then I do not know how to proceed.
>
> Cheers,
>
> Reinaldo
>
> */
> /*
> P.S. The modified macro, that I am running on Maptitude 4.6:
>
> // Returns an options array where the name of the option is the Name of
> the polygon and the value is its perimeter
> // it also returns the total perimeter of all areas found
> //
>
> Macro "GetPolygons" (sLayerName, sSetName, sNameField)
>
>
> SetLayer("Favelas2010")
> // This problem was solved
> *//**//*
> if sNameField = null then sNameField = "ID"
>
> rh = GetFirstRecord (sLayerName + "|" + sSetName)
> // Now stops here...
>
> arPerimeters = {}
> nTotper = o
> while rh <> null do
> nPer = GetPerimeter(rh2id(rh))
> arPerimeters.(sLayerName.(sNameField)) = nPer
> nTotper = nTotper + nPer
> rh = GetNextRecord (sLayerName + "|" + sSetName ,, )
> end
>
> Return( { arPerimeters, nTotper} )
>
> endMacro
> */
> ----------------------------------------------------------
>
> Armando Scalise wrote:
> >
> >
> > HI Reinaldo
> >
> >
> > Here is some code that might help you do that.
> >
> > I have not tested it, so bear in mind it might require some slight
> > changes to do what you need.
> >
> > Good luck
> >
> >
> > // Returns an options array where the name of the option is the Name
> > of the polygon and the value is its perimeter
> > // it also returns the total perimeter of all areas found
> > //
> >
> > Macro "GetPolygons" ( sLayerName, sSetName, sNameField)
> >
> > SetLayer(sLayerName)
> >
> > if sNameField = null then sNameField = "ID"
> >
> > rh = GetFirstRecord (sLayerName + "|" + sSetName)
> >
> > arPerimeters = {}
> > nTotper = o
> > while rh <> null do
> > nPer = GetPerimeter(rh2id(rh))
> > arPerimeters.(sLayerName.(sNameField)) = nPer
> > nTotper = nTotper + nPer
> > rh = GetNextRecord (sLayerName + "|" + sSetName ,, )
> > end
> >
> >
> > Return( { arPerimeters, nTotper} )
> >
> > endMacro
> >
> > 2011/2/4 Reinaldo Paul P�rez Machado <rpmgis@...
> > <mailto:rpmgis@...>>
> >
> >
> >
> > /*Hello,
> >
> > Please, I would like to know how is it possible to get the
> > corresponding perimeter of a bunch of polygons in a geographic files?
> >
> > Thanks in advance. Any aid would be very much appreciated. Cheers,
> >
> > Reinaldo*/
> >
> >
> >
> >
> > --
> > Armando Scalise
> >
>

Reply via email to