def area_of_polygon(XYs):
  """ Calculates the area of an arbitrary polygon given its verticies """
  n = len(XYs)  # of corners
  area = 0.0
  for i in range(n):
    j = (i + 1) % n
    area += XYs[i][0] * XYs[j][1]
    area -= XYs[j][0] * XYs[i][1]
  area = abs(area) / 2.0
  # print ("XYs {0} area {1}".format(XYs, area))
  return area