# ProportionWtAvg

## Description

Computes the weighted average of an aggregation of values which are adjusted based on the proportion of two geometry objects.

## Syntax

ProportionWtAvg ( n, w, value_geometry, reference_geometry )

## Arguments

n is a numeric expression,

w is a numeric expression indicating the weight,

value_geometry is a geometry expression, and

reference_geometry is a geometry expression.

## Example

Returns the proportional weighted average of values between two geometry objects (one an envelope using MI_Box, the other passing in a geometry object) based on female population.

``select ProportionWtAvg(Pop_1990, Pop_Female, obj, MI_Box(-104.493426, 39.399710, -101.282362, 41.474182, 'epsg:4269')) as ProportionWtAvg from states``

## Remarks

ProportionWtAvg is an aggregation function which can only be used in an aggregating Select statement. Null values for n, value_geometry, and/or reference_geometry are ignored. If there are only null values supplied in the aggregation, then a null value is returned. If the denominator results in a value of zero (which would occur if the weight or the area of the overlap are zero for each record accumulated), then a value of null will be returned.

The ProportionWtAvg aggregation function can be replaced with the following formula:

``ProportionWtAvg = Sum(n * w * Area(Intersection(value_geometry, reference_geometry), 'sq mi', 'Spherical') / Area(value_geometry, 'sq mi', 'Spherical')) / Sum(w * Area(Intersection(value_geometry, reference_geometry), 'sq mi', 'Spherical') / Area(value_geometry, 'sq mi', 'Spherical'))``

If the coordinate system of the value_geometry is Non-Earth, a Cartesian area calculation will be performed.