This is a messy one

I want to eventually get back to cleaning this up because I ended up just copying a large chunk from sediment mapper.