Change the name ID of each node

Hi everyone
I have a network, I do not like naming nodes, and it’s not easy for me to work with them.

Is there any command in (epanet-matlab toolkit ) that I can automatically change the name ID of each node?
for example in my network, i have some node with node ID , j1,j2…,j1325,n1,n2,n3,t1,t2,r1,r2.
(I uploaded a part of the network)

i want to change all the name ID to 1,2,3,4,5,… respectively. I wanted to do this manually, but the number of nodes is very high and I want to do this automatically. How can i do this?

I have other question too

does anybody know wich command in toolkit, is useful for water age analysis?

Thank you so much


If it is one-off process, I suggest you do this by editing the INP file through an editor tool (e.g. Excel) which is very quick and you are able to name them with more flexibility in Excel spreadsheet

1 Like

Unfortunately I did not see a function for this job,
epanet api dont have EN_setlinkid and EN_setNodeid
im report t to epanet team


Thanks for your answer, can you explain more about editing the INP file through Excel . could you recommend a good source to me?

Thanks again!

you must edit in epanet GUI
because if you set rule for nodes you must change all it
its better to change in epanet GUI

You can just simply drag and drop the INP file in spreadsheet. With whatever technique (e.g. drag/drop), once opening the inp file in Excel, you should be able to see all entries in a separate cell. If not, you should covert this through DATA menu in Excel through “Text to Columns” button. This video is also als another way of opening INP/text file in Excel ( Finally, locate the node section in the spreadsheet and select those node IDs and change/convert to what you want and finally close the file and if it asks for saving the INP file, press Yes (You don’t need to change/save it with another extension or xls file).
Hope this helps,


Another option is to use the epanetReader package for R.

This would allow you to:

net <- read.inp("my_network_file.inp") 
net$Junctions$ID <-   vector_of_new_names
write.inp(net, "my_updated_network_file.inp")

Care is needed after updating the Junction IDs because the above will not change the IDs in the other places where they appear in the inp file such as the [Pipes] table. You can use the merge() function to create a lookup from old to new IDs.


Hello @linkhochon

You can download my tool ENRenameIDs
If it shows you an error, write me
It’s in Spanish, but it’s very intuitive



Hi @Ovegas , Thanks a lot .

I downloaded it and had no errors,But I do not know how to use it.Unfortunately, I do not know Spanish.
Can you explain a little how can I use it ?


Thanks & Best

Click on the button of the three points and look for the inp file of Epanet. Then the number of elements will be displayed. In tab 2 you can remove all the elements or groups. Finally click on the accept button. The resulting file is saved in the same directory as the original file

Thanks again @Ovegas
I did what you said, But there is a problem. In my network, nodes are represented by j1, …, j334. And tanks with t1, …, t5, and reservior with r1, …, r3. when I removed the elements , the name ID of reservoirs, tanks are the same.
I mean, I have three 1. One represents a reservoir ,another represents a tank ,And the other is a node.
I want to have different name ID.
Is there any way that I can do this with your tool ?
d-town.inp (124.9 KB)
d-town_RenameID.inp (146.7 KB)



Epanet does not allow repeating an identifier by category (node and link)
Do not use prefix for the nodes and add a prefix “T” for the tanks (Depositos), and a prefix “R” for the reservoirs (Embalses)d-town_RenameID_Ovegas.inp (146,7 KB)

1 Like

I did what you said above, about renaming reservoirs with a prefix R and Tanks with R, and nothing in nodes, but I always get an error, when renaming ID. I tried setting an increment of 10, but no success.
Can someone please tell me how to rename IDs of nodes successfully, as well as Tanks and reservoirs?

Hi @nando1988
You can repeat the same prefix for reservoirs and reservoirs, but you will have different paths. It is recommended that the prefixes are all different. You can configure it as follows (see images)

F1 F2


You can use this version new RenameIDs
I use ENsetnodeid and ENsetlinkid functions.


Hi @nando1988,

Also, you can use EMT like the following video:

% Clear
clear; close('all'); clc;


% Load network
d = epanet('Net1.inp');

disp('Node name ids:')

% Set your prefix 
junction_prefix = 'J';
reservoir_prefix = 'R';
tank_prefix = 'T';

% Update node names 
for i=d.getNodeJunctionIndex
    d.setNodeNameID(i, [junction_prefix, '-', num2str(i)]);

for i=d.getNodeReservoirIndex
    d.setNodeNameID(i, [reservoir_prefix, '-', num2str(i)]);

for i=d.getNodeTankIndex
    d.setNodeNameID(i, [tank_prefix, '-', num2str(i)]);

disp('Node name ids after:')