Physico-chemical spectroscopic mapping of the planetary nebula NGC 40 and the 2d_neb, a new 2D algorithm to study ionized nebulae