import Table
dataMin = 0
dataMax = 0
def setup():
global locationTable
global mapImage
global rowCount
global dataTable
global dataMin
global dataMax
size(640, 400)
mapImage = loadImage("map.png")
locationTable = Table.Table("locations.tsv")
rowCount = locationTable.getRowCount()
#print rowCount
dataTable = Table.Table("random.tsv")
# Find the minimum and maximum values
for row in range(rowCount):
value = dataTable.getFloat(row, 1)
if value > dataMax:
dataMax = value
if value < dataMin:
dataMin = value
def draw():
global locationTable
global mapImage
global rowCount
global dataTable
global dataMin
global dataMax
background(255)
#print(rowCount)
image(mapImage, 0, 0)
fill(192, 0, 0)
noStroke()
for row in range(0,rowCount):
abbrev = dataTable.getRowName(row)
x = locationTable.getFloat2(abbrev, 1)
y = locationTable.getFloat2(abbrev, 2)
drawData(x, y, abbrev)
# Map the size of the ellipse to the data value
def drawData(x, y, abbrev):
global dataTable
global dataMin
global dataMax
#Get data value for state
value = dataTable.getFloat2(abbrev, 1)
percent = norm(value, dataMin, dataMax)
#Re-map the value to a number between 2 and 40
between = lerpColor('#FF4422', '#4422CC', percent) #red to blue
fill(between)
ellipse(x, y, 15, 15)