qgisred / QGISRed

GNU General Public License v2.0
23 stars 8 forks source link

Automatic addition of nodes along pipe's lengths #51

Closed IDoytchinov closed 3 years ago

IDoytchinov commented 3 years ago

Hey all. We are new to QGISred and have a bit specific question. We wish to find a way to add multiple new nodes automatically along a pipe length at even distances. Imagine we want to cut a pipe along the length over every 1 meter. Below I have a simple visual example of a basic network that we did manually in EPANET.

The question is if we have a massive city network and want to do this for it automatically, can we script it somehow within QGISReed? Thanks a lot for your ideas and suggestions!

image

image

Iordan Doytchinov, Ph.D.

Postdoctoral researcher and scientific collaborator

Ecole Polytechnique Fédérale de Lausanne (EPFL) EPFL – TOPO Station 18 – Bâtiment GC C2 398

CH–1015 Lausanne

Office telephone: +41216939832 Personal mobile: +33699850592

iordan.doytchinov@epfl.ch http://topo.epfl.ch/

neslerel commented 3 years ago

Hi @IDoytchinov,

There is not a specific feature in QGISRed to split pipes every certain length. However, you can take pipes layer and use a QGis Tool (Proccessing-->Toolbox): "Split lines by maximum length". It will create a new layer with the splitted pipes. In this case, you should review the pipe's Ids to avoid duplicate values. Moreover, you can compute again the field Length with Field Calculartor (QGis tool). With the new pipe layer prepared you need to create a new QGISRed project and import (or add) data from SHPs. You can select the new layer for pipes element and also import the other elements (reservoirs, previous nodes, etc.).

I hope it could help you. Nevertheless, we take note of this possible feature to include in the future.

Thanks for your message.

neslerel commented 3 years ago

Hi @IDoytchinov,

I received an email from you, but I don't see the message here. I know that in QGis you can create python script, for example to run a specific QGis tool (from the toolbox) and update some fields of a layer. However, the proccess of importing the new layers in QGISRed I think is not possible to script in QGis. How many networks you have to edit?

IDoytchinov commented 3 years ago

Dear @neslerel https://drive.google.com/file/d/1mexveogfdM046p9SuHJJ_eQyXVHsB-V2/view?usp=sharing here is my QGIS example. I tried but there seems to be a problem. I used the original .imp file of the water network and created a shape file which i split evenly in 1 meter sections. I used this and the terrain to generate nodes every one meter saved in another shape file. I created lines as well as a separate shape file every one meter. Then i tried inserting a new .inp file from those 2x shape file however it fails.. It works only for a few nodes connections. As well there is a challenge with the split of the shapes. There are many/hundreds of duplicate values as well... not sure how we can go through all and automatically remove them!

Will be really grateful if someone can help us with this quest of splitting pipes!

All the best!

Iordan

neslerel commented 3 years ago

Hi @IDoytchinov ,

Sorry, only with ".shp" files is not enought to open them in QGis. I couldn't see your shapefiles... However I started with the INP file and I followed the next steps:

It is not an automatic process, but I hope it can help you.

neslerel commented 3 years ago

One more comment: As I told you in other message, you should calculate the pipe length of new elements or when you select the fields to import, not select the Length property and QGISRed will calculate it for each pipe with its geometry. image

IDoytchinov commented 3 years ago

Dear @neslerel Great effort! :) Finally, we have what we needed and can start running experiments/studies :)!

Thanks a lot for your help!!

IDoytchinov commented 3 years ago

Dear @neslerel Great effort! :))) Finally, we have what we needed and can start running experiments/studies :)!

Thanks a lot for your help and great explanation, we appreciate it! :)

Iordan D. et all

IDoytchinov commented 3 years ago

Dear @neslerel Sorry for re-opening! It seems there is a problem with the .inp export! :((( We managed to have the correct height on all the nodes from the raster. However, as soon as we try to export our project as .inp we have 0 height on all the nodes in EPANET : (((. We presume it is some problem with the .inp export function. Please can you have a look at our project and project files, I tried to add all of them here - https://drive.google.com/file/d/1bqDyqzge9UPQGcSyt2pSdKat5KwG_r7d/view?usp=sharing Thanks a lot for the kind help!

neslerel commented 3 years ago

Dear @IDoytchinov!!

I checked your files. In Network_Junctions layer the Elevation field is filled with ceros. This layer has all the properties of the junctions that will be included in the model (and in the INP file). Then, it is normal that if you export to INP, the elevation will be 0 in all junctions. I saw that you have a layer (Points_with_cords) that contains all the junctions and I suppose that the only field corresponds with the elevation. In this case, when you create a new project importing splitted_pipes, you have to import for junctions the layer Points_with_cords and to select in Elevation field the only field of the layer: image

If it is not clear, tomorrow I can make a gif like previous ones. I hope it fixes the problem.

IDoytchinov commented 3 years ago

Hello, @neslerel Thanks a lot for the swift reply! In fact, I did as you pointed out even before and yet still the problem persists. In QGISred in the network attribute table, I do have the correct height for each junction as shown below. However, as soon as I try to use the 'export-to-inp' feature, the .inp file does not have the heights for the nodes! :(((

image

Do you have any idea what could be going wrong? Does it work correctly for you? For the time being, we need to get it at least 1ce right so we can run our preliminary tests!

Thanks a lot for your kind help!

Iordan et all

neslerel commented 3 years ago

Hi @IDoytchinov, In the layers that you sent me, the elevation is not in Junction layer data: image With this layer of points (junctions) I suppose you interpolated the elevation with raster data obtaining Points_with_cords layer: image However, I noticed that one layer has more points than the other one... image In this case, there are some points in Points_with_cords that there are not used in the importation process and other points that originally were in Network_Juntions there are not in Points_with_cords and the process create them. These points created have elevation 0 and for this reason, some points in the INP have elevation equal to 0.

I recommend you to take Network_Junctions layer and use it to get the elevation from the raster.

For other hand, I noticed that some fields are imported although you don't select them. I'm going to fix it now.

IDoytchinov commented 3 years ago

Hello, @neslerel Thanks a lot for writing back! It is a bit strange.. it seems that you might not have got the right files. Here I apply the latest version - https://drive.google.com/file/d/1P8NOdK2UGy3RA0x-eb0gt-TGsMiXEll9/view?usp=sharing . What I see is that for all junction points do have the correct elevation.

image

Which is strange then why we cannot export it back to .inp with the correct elevation? Any thought's on that? :/ ?

All the best!

Iordan

IDoytchinov commented 3 years ago

HA! Strange enough! This time it worked! I tried to save the file as .inp. Re-load it in QGISRed and then again export it as .inp and now for first time it actually worked and in EPANET 2.2 we have the correct elevations!!

IDoytchinov commented 3 years ago

Please can you confirm this as well!? : ) - https://drive.google.com/file/d/1od93PwuXPuLq7qMEh2zt8lOXulo68kXg/view?usp=sharing yes! image

neslerel commented 3 years ago

Hi @IDoytchinov,

In the last Junctions layer you sent me, there are 156 points with elevation equal to 0. And in your INP there are the same points without elevation: image image For example, Junction with ID: J9909.

IDoytchinov commented 3 years ago

@neslerel Thanks for pointing it out! Do you have any suggestion on how to correct those junctions elevations? Not sure if it is possible to correct the elevation only on those problematic junctions... I was thinking if it is possible to save the junctions as a shapefile and then re-project again the elevation however this seems not possible. The error is somewhere upstream that causes those problematic junctions : /.

neslerel commented 3 years ago

Hi @IDoytchinov,

I'm not an expert using QGis tools, but I got the elevation of all the junctions: IGw7uJ2Q7Y

IDoytchinov commented 3 years ago

Hello @neslerel thanks for the advice, I did this and got the right elevations but once I attempt to use the function and export it to .inp https://drive.google.com/file/d/1JOGP2ikLBKhIETbF3bxXZyXEly5qYiSw/view?usp=sharing it does not work! : ((( Again the .inp is with the same problematic 0 elevations on id bigger than 8000. It is wired it seems there is a bug or something and one cannot export .inp with such a high count id nodes to .inp with correct elevation? I applied the corrected shape files ready for .inp conversion you can see it you like and confirm that the problem is in the .inp export feature? : / Thanks a lot for your help!!

Iordan

neslerel commented 3 years ago

I'm sorry @IDoytchinov but I continue seeing some junctions (156) without elevation... qgis-bin_kMvp3geuIB

I don't know how I can help you more, sorry.

IDoytchinov commented 3 years ago

Dear @neslerel no worries, you helped a lot already! We will correct the .inp with the correct elevations directly in EPANET via its python extension.

Thanks a lot again and all the best!

Iordan