# Would you stay here?

Airbnb & Rodent Witness Calls in Manhattan

New York City, especially Manhattan is full of tourist and visitors from all over the world. With so many people spending their nights in the city, Airbnb has become a popular host for the people that are staying either short term or long term. In the other hand, New York City is also known as the city with RATS….So, we decided to create a map to see how many rats there are in the area, one wants to stay! And of course, there are SO MANY RAT WITNESSES throughout the city! The number of rats surpassed the number of Airbnb in New York City so we decided to focus only on Manhattan.

Writing the code took a bit of trial but we are happy with the result. We started by utilizing SlippyMapper with Processing & Python. We gathered all the longitude and latitude data for Airbnb and Rodent Report Call data in Manhattan. And created an interactive code that is click-able, zoom-able, and move-able (thanks to Allan William Martin!). Now we can click the location of an Airbnb and see the number of rats within the radius of 60ft. The whole process was complicated but super exciting to see the result of the interactive map through a set of data + Python!

`import spatialpixel.mapping.slippymapper as slippymapperimport csvdef setup():    size(1000, 800, P2D)    global zoom    zoom = 14        #airbnb image file    pin = loadImage("https://s3.amazonaws.com/spatialpixel/maps/map-pin-10px.png")        global nyc    nyc = slippymapper.SlippyMapper(40.715, -73.999, zoom, 'carto-dark', width, height)    global ratLocations    ratLocations = []        with open('airbnb.csv') as f:        reader = csv.reader(f)        header = reader.next()                for row in reader:            latitude = float(row[1])            longitude = float(row[2])                        nyc.addMarker(latitude, longitude, pin)        nyc.render()                    with open('rat.csv') as f:        reader = csv.reader(f)        header = reader.next()                for row in reader:            try:                latitude = float(row[1])                longitude = float(row[2])                ratLocations.append((latitude, longitude))            except:                pass    nyc.render()    def isClose(mouseLocation, ratLocation):    threshold = 0.002    distanceToRat = dist(mouseLocation[0], mouseLocation[1], ratLocation[0], ratLocation[1])    if distanceToRat <= threshold:        return True    else:        return False def mouseClicked():    # Get where I clicked in latitude x longitude    global nyc    clickLongitude = nyc.xToLon(mouseX)    clickLatitude = nyc.yToLat(mouseY)    ratImage = loadImage('hirat.png')    ratImage.resize(0,100)                            closeRats = []            def rat_marker(x, y, marker):        marker.stroke(255, 255, 255)        marker.fill(255, 255, 255)        marker.ellipse(x, y, 5, 5)            # Loop over all the rats    global ratLocations    for rat in ratLocations:        # If the click is close to a rat, remember the rat.        if isClose((clickLatitude, clickLongitude), rat):            closeRats.append(rat)                    # drawing and stuff here for when you click.    print(len(closeRats))    fill(102, 102, 102)    textSize(20)    nyc.addMarker(clickLatitude, clickLongitude, str(len(closeRats)))        for rat in closeRats:        nyc.addMarker(rat[0], rat[1], ratImage)        nyc.addMarker(rat[0], rat[1], rat_marker)def draw():    background(0)    nyc.draw()            def keyPressed():    global zoom, nyc        step = 0.005    lat = nyc.lat    lon = nyc.lon        if key in ('-', '_'):        zoom -= 1    elif key in ('+', '='):        zoom += 1    elif keyCode == UP:        nyc.setCenter(lat + step, lon)    elif keyCode == DOWN:        nyc.setCenter(lat - step, lon)    elif keyCode == LEFT:        nyc.setCenter(lat, lon - step)    elif keyCode == RIGHT:        nyc.setCenter(lat, lon + step)        if zoom < 1:        zoom = 1    if zoom > 18:        zoom = 18    nyc.setZoom(zoom)    nyc.render()`

P.S. Did you know you could get a refund and get relocated if you witness rodents?

Author: