def wps_execute_layer_attribute_statistics(layer_name, field):
 url = ('%s/ows' % ogc_server_settings.LOCATION)
 request = render_to_string('layers/wps_execute_gs_aggregate.xml', {'layer_name': ('geonode:%s' % layer_name), 'field': field})
 response = http_post(url, request, timeout=ogc_server_settings.TIMEOUT, username=ogc_server_settings.credentials.username, password=ogc_server_settings.credentials.password)
 exml = etree.fromstring(response)
 result = {}
 for f in ['Min', 'Max', 'Average', 'Median', 'StandardDeviation', 'Sum']:
  fr = exml.find(f)
  if (fr is not None):
   result[f] = fr.text
  else:
   result[f] = 'NA'
 count = exml.find('Count')
 if (count is not None):
  result['Count'] = int(count.text)
 else:
  result['Count'] = 0
 result['unique_values'] = 'NA'
 return result

def wps_execute_layer_attribute_statistics ( layer_name , field ) : url = ( '%s/ows' % ogc_server_settings . LOCATION ) request = render_to_string ( 'layers/wps_execute_gs_aggregate.xml' , { 'layer_name' : ( 'geonode:%s' % layer_name ) , 'field' : field } ) response = http_post ( url , request , timeout = ogc_server_settings . TIMEOUT , username = ogc_server_settings . credentials . username , password = ogc_server_settings . credentials . password ) exml = etree . fromstring ( response ) result = { } for f in [ 'Min' , 'Max' , 'Average' , 'Median' , 'StandardDeviation' , 'Sum' ] : fr = exml . find ( f ) if ( fr is not None ) : result [ f ] = fr . text else : result [ f ] = 'NA' count = exml . find ( 'Count' ) if ( count is not None ) : result [ 'Count' ] = int ( count . text ) else : result [ 'Count' ] = 0 result [ 'unique_values' ] = 'NA' return result
derive aggregate statistics from wps endpoint .