I thought about this some more, and I have another answer. The problem with
adding and updating a new column as I suggested is that the data type needs
to be character to hold the percent symbol, and it just takes up unneeded
space in your data set. Another approach is to not store the percentage in
the table, but use either a label function to display/print , or a
calculated query to have the data in a browser.
1. Display / print with labels; expression to label with such as
Round(Area(Object, "sq m")/[a constant equal to the total area ]*100,
0.01)+" %"
If you use this approach , you don't need an extra column to hold the
percentages, they are calculated as labels.
2. Calculated query; If you need the data formatted in a column you can use
a calculated query to generate a temp column-
in SQL builder, select your table, in column section, select the
individual columns to display (the * does not work for this) and after the
columns you want to display, use the percentage formula again. after the
formula, and without a comma you can give the calculated field an alias in
quotes. It looks like this in the MapBasic window:
Select Field1, Field2, Field3, Round(Area(Object, "sq m")/22956*100, 0.01)+"
%" "Percent_of_total" from Mytable into Selection.
Also of note is that either of these approaches can use the decimal data
type and still utilize a percent character.
William "Woody" Woodruff
Zoning Administrator
Charter Township of Union, Isabella County, Michigan
-84.80947000 43.61095100
2010 S Lincoln Rd, Mt. Pleasant, MI 48858
(989) 772 4600 EXT 41
Visit our web site at http://www.geocities.com/ctuzoning/index.htm
-----Original Message-----
From: Woody Woodruff [mailto:[EMAIL PROTECTED]
Sent: September 27, 2004 21:57
To: Peter Hatton; [EMAIL PROTECTED]
Subject: RE: MI-L PERCENTAGE QUERY
If its not there, add a column to hold the percentage via table
>maintenance>structure. For this discussion it will be called
Percentage_Of_Total
Then a 2 part SQL.
step one determine total area (I used square meters here, Mate)
In SQL builder:
Choose your polygon table in the table section
replace the * in the first section with Sum(Area(obj, "sq m")) sq m can be
replaced with other units
MapBasic window shows:
Select Sum(Area(obj, "sq m")) from MyTable into Selection
Browse * From Selection
the result will be one record giving the sum of the areas of all polys from
your table. It is not necessary to Group By Objects. Note that the units
of your existing individual area column and units of the query for total
area must match.
copy the figure returned above.
I used an existing table of polygons I have and it returned 22956 for the
sum of area(obj, "sq m"), we'll use that number in our next formula.
then run an column update wizard (Table>Update Column):
column to update is Percentage_Of_Total column you added above
hit the assist button and build a formula to divide the individual object's
area by the total area figure obtained in step one. The basic formula would
then be Area (obj, "sq m") / total area. Notice that although you have a
column for the individual objects' area, it is not necessary, the function
Area() will return these figures without an actual column.
So far, this procedure gives you decimals with no formatting for
percentages, and MI has no Percent data type or functions.
to get to a column of percentage, try this:
Update MyTable Set Percentage_of_Total = Round((Area(obj, "sq m") /
22956)*100, .001) +" %"
*100 converts the decimal to a percentage, it needs to be rounded to the
nearest 1/1000th to be workable, and the + " %" concatenates the percent
symbol into the figure, notice it is quote space % end quote to give a space
between the numbers and the % sign.
William "Woody" Woodruff
Zoning Administrator
Charter Township of Union, Isabella County, Michigan
-84.80947000 43.61095100
2010 S Lincoln Rd, Mt. Pleasant, MI 48858
(989) 772 4600 EXT 41
Visit our web site at http://www.geocities.com/ctuzoning/index.htm
-----Original Message-----
From: Peter Hatton [mailto:[EMAIL PROTECTED]
Sent: September 27, 2004 02:13
To: '[EMAIL PROTECTED]'
Subject: MI-L PERCENTAGE QUERY
Hi all,
Can someone help me to do the following -
I have a table of polygons with
individual area totals for each polygon. Can someone tell me how I can
determine the area percentage of each polygon for the combined total area ?
Many thanks
Peter
Peter HATTON
GIS Officer
Greater Taree City Council
PO Box 482 TAREE 2430
Ph 02 6592 5227
Fax 02 6592 5380
E-mail [EMAIL PROTECTED]
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 13513
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 13529
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 13552