The density and peculiar velocity fields of nearby galaxies