Good advice, rich, and that's pretty much how the factory does it, too. 8)
If you look at a factory built boat, you may see plastic plugs on the decks, etc. This is where the factory inserts a plastic bag, where they give it a quick inflation to make it fill the space, then, they pour in the 2-part foam, except, the foam they use is closed-cell, it's not like the 'great stuff'
I know about using that spray foam in a boat, when I re-did my jetboat, I had the pleasure of digging out water-logged foam from around the fuel tanks. The waterlogged foam also caused corrosion issues with the aluminum tanks, heavy pitting, which, I took care of the worst of it by the tedious job of TIG welding anywhere the pitting looked deeper than about .025"
Fortunately, it did not damage the boat's hull, because it was painted with truck bed liner, and there was a sheet of 1/2" dow foam board placed under the fuel tanks before the spray foam was blown in. But, the foam board being in contact with the bottom of the fuel tank also caused corrosion, so, this time, I didn't put any foam under it, for good ventilation and drainage, and the tanks are elevated about 1 inch off the bottom of the boat with ribs, and those ribs are topped with a strip of industrial-type rubber, with the tank's brackets bolted down to that.