Optimal spatial resource allocation in networks: Application to district heating and cooling. (September 2022)