How to find coordinates of nodes

Hi,

I am working on finding coordinates of nodes in WDN using epanettools, but I failed to do that. My code is shown below:

import os, pprint
from epanettools.epanettools import Node
file=os.path.join(os.path.dirname(‘C:/Users/Ziyuan/desktop/Battledim/L-Town.inp’),‘L-Town.inp’)
x=Node.value_type[‘EN_COORDINATEX’]
print(es.ENgetnodevalue(1,x))

Finally, I recevied an error showing ImportError: cannot import name 'adf’ from ‘epanettools’ (C:\Users\Ziyuan\AppData\Local\Programs\Python\Python37\lib\site-packages\epanettools_init.py).

Could you please tell me what does this ImportError mean? I am really confused about this error, because I did not import “_adf”. And could you please share your idea about how to retrieve coordinates of nodes with me?

Appreicate a lot if any advices.

Hi ZiyuanCai,

adf is an epanettools library (https://github.com/asselapathirana/epanettools/tree/master/src/epanettools/adf), maybe you should reinstall.

Regarding to coordinates, the Node class does not have the value type: EN_COORDINATEX.

To get the coordinates you should use: ENgetcoord. Unfortunately this function is not implemented in epanettools, but you could edit it. Let me know if you need help with this.

Regards.
Sergio

Hello Sergio,

Thanks for your help!
And I am new to this area, could you please tell me how to add the value type ENgetcoord to epanettools source code?
Thank you very much.

Sincerely,
Ziyuan Cai

I’ve been checking the epanettools library and its epanet version doesn’t bring the ENgetcoord function. I’m sorry.

So I think the best and fastest solution to implement it is the one indicated by @samhatchett

Hi @ZiyuanCai,

Using the EMT you can try the following example:

start_toolkit;
d = epanet(‘Net1.inp’);
x = d.getNodeCoordinates{1}
y = d.getNodeCoordinates{1}
d.getNodeCoordinates
d.plot

Regards,
Marios

image