Elevation profile #trackprofile2web #QGIS #test

Data project

<?xml version="1.0"?>
<gpx version="1.1" >

"<wpt> GPX DATA HERE"

<trk>
<trkseg>

"<trkpt> GPX DATA AND HERE"

</trkseg>
</trk>
</gpx>

Fix EPANET pipe lengths

Using EPANET-Matlab-Toolkit

clear all; close all;

% Load paths
start_toolkit;

% Load file
d = epanet('test.inp');

% Get link node indices # from node to node
indices = d.getLinkNodesIndex;

% Return initial length of pipes
d.getLinkLength

% Fixed length of pipes
for link_ind = 1:d.LinkCount
    ind_Node1 = indices(link_ind, 1);
    ind_Node2 = indices(link_ind, 2);
    
    [latlons] = d.getNodeCoordinates([ind_Node1, ind_Node2]);
    
    X = [latlons(1, :);latlons(2, :)];
    fixLength = pdist(X, 'euclidean');
    
    d.setLinkLength(link_ind, fixLength);
end

% Rerurn link lengths
d.getLinkLength

d.saveInputFile('fixLengths.inp');

% Unload dll
d.unload;

Or via executable:

https://www.dropbox.com/s/xyulvoywdb68ffq/FixLengths.zip?dl=0

Question thread at community.wateranalytics.org

http://community.wateranalytics.org/t/finding-pipe-lengths/899

Example code: layer.setSubsetString(“‘4′ LIKE “dist_code””’)

# Show every province features (postcodes) one by one

from time import sleep

def stopped(task):
    pass
def completed(exception, result=None):
    pass
def run(task, wait_time):

    # main code
    postcodes = QgsProject.instance().mapLayersByName('postcodes')[0]
    wait_time = wait_time / 100
    prov = [1, 3, 4, 5, 6]
    for i, m in enumerate(prov):
        task.setProgress(i)
        sleep(wait_time)
        postcodes.setSubsetString("'" + str(m) + "'" + ''' LIKE "dist_code"''')

        if task.isCanceled():
            stopped(task)
            return None
    postcodes.setSubsetString("")

task = QgsTask.fromFunction(u'Task', run,
                            on_finished=completed, wait_time=150)
QgsApplication.taskManager().addTask(task)

Or by right click on layer and go to Source and Query Builder:

Filter features on a layer #QGIS #PyQGIS

About

Hello all,

My name is Marios. Welcome to my page!

Marios S. Kyriakou received his B.Sc (2012) and his M.Sc. (2014) in Electrical Engineering from the Department of Electrical and Computer Engineering of the University of Cyprus. His Master Thesis with the title “Risk Evaluation and Sensor Placement for Disinfection By-Products in Water Distribution Systems” was carried out in KIOS under the supervision of Dr. Marios M. Polycarpou and Dr. Demetrios G. Eliades. He is currently working as a Software Developer at KIOS Research and Innovation Center of Excellence since 2012.  His research interests focus on water distribution systems.

Publications
Google Scholar

Active member
http://community.wateranalytics.org/

Enjoy to follow and subscribe to me, thanks!
https://www.youtube.com/user/Mariosmsk/
https://github.com/Mariosmsk

CONTACT DETAILS
E-mail: mariosmsk@gmail.com

Year, Winner
1956, Switzerland
1957, Netherlands
1958, France
1959, Netherlands
1960, France
1961, Luxembourg
1962, France
1963, Denmark
1964, Italy
1965, Luxembourg
1966, Austria
1967, United Kingdom
1968, Spain
1969, Spain
1970, Ireland
1971, Monaco
1972, Luxembourg
1973, Luxembourg
1974, Sweden
1975, Netherlands
1976, United Kingdom
1977, France
1978, Israel
1979, Israel
1980, Ireland
1981, United Kingdom
1982, Germany
1983, Luxembourg
1984, Sweden
1985, Norway
1986, Belgium
1987, Ireland
1988, Switzerland
1989, Yugoslavia
1990, Italy
1991, Sweden
1992, Ireland
1993, Ireland
1994, Ireland
1995, Norway
1996, Ireland
1997, United Kingdom
1998, Israel
1999, Sweden
2000, Denmark
2001, Estonia
2002, Latvia
2003, Turkey
2004, Ukraine
2005, Greece
2006, Finland
2007, Serbia
2008, Russia
2009, Norway
2010, Germany
2011, Azerbaijan
2012, Sweden
2013, Denmark
2014, Austria
2015, Sweden
2016, Ukraine
2017, Portugal
2018, Israel
2019, Netherlands

Example: HERE

Eurovision Winners 1956 – 2019 #QGIS #Maps #Eurovision

Biggest Dams based on data

DamCountry YearCapacity MCMQuality
1.Lake VictoriaUganda 1954 204800 Verified
2.KaribaZimbabwe 1959 185000 Good
3.Bratskoye Russia 1964 169000 Fair
4.Lake NasserEgypt 1970 162000 Verified
5.VoltaGhana 1965 148000 Verified
6.ManicouaganCanada 1968 141850 Good
7.CaroniVenezuela 1986 135000 Fair
8.WillistonCanada 1967 74300 Fair
9.Krasnoyarskoye Russia 197273300 Verified
10. Zeyskoye Russia197868400Fair
3042.KourrisCyprus1988115Good

Total dams in this dataset: 7320

Source and more info:

For more videos subscribe:
https://www.youtube.com/user/Mariosmsk/

Global Dam Map #QGIS

Sample code:

from time import sleep
def stopped(task):
	QgsMessageLog.logMessage(
		'Task "{name}" was canceled'.format(
			name=task.description()),
		'task', Qgis.Info)

def completed(exception, result=None):

    buildings=result['buildings']
    finalFeature=result['finalFeature']
    buildings.startEditing()

    for i, featBuilds in enumerate(finalFeature):
        buildings.updateFeature(featBuilds) 
    buildings.commitChanges()
    
def run(task, wait_time):
    QgsMessageLog.logMessage('Started task {}'.format(task.description()),
                                 'Add post code on buildings', Qgis.Info)

    postcodes = QgsProject.instance().mapLayersByName('ex_postCodes')[0]
    buildings = QgsProject.instance().mapLayersByName('ex_buildings')[0]

    fields = []
    [fields.append(f.name()) for f in buildings.fields()]
    newfield = 'post_code'
    if newfield not in fields:
        postcode_field = QgsField(newfield, QVariant.Int)
        prov = buildings.dataProvider()
        prov.addAttributes([postcode_field])
        buildings.updateFields()

    wait_time = wait_time / 100

    # Create a column for post codes in buildings
    total_features = buildings.featureCount() + postcodes.featureCount()
    prc = 0

    new_postcode_index = buildings.fields().indexFromName(newfield)
    finalFeature = []
    for i, featBuilds in enumerate(buildings.selectedFeatures()):
        task.setProgress((prc/total_features)*100)
        #sleep(wait_time)
        overlapping = []
        check_IF_write_value = False
        for featPostc in postcodes.getFeatures():
            prc += 1
            num_post_code = featPostc.attribute(featPostc.fieldNameIndex(newfield))
            if featBuilds.geometry().within(featPostc.geometry()):
                featBuilds['post_code'] = num_post_code
                finalFeature.append(featBuilds)
                check_IF_write_value = True
            else:
                areaA = featBuilds.geometry().intersection(featPostc.geometry()).area()
                areaB = featBuilds.geometry().area()
                overlapping.append([(areaA/areaB)*100, num_post_code])
            if not check_IF_write_value:
                featBuilds.setAttribute(new_postcode_index, max(overlapping)[1])
                featBuilds['post_code'] = max(overlapping)[1]
                finalFeature.append(featBuilds)
        if task.isCanceled():
            stopped(task)
            return None
    return {'finalFeature': finalFeature, 'buildings': buildings,
            'task': task}

task = QgsTask.fromFunction(u'Task', run,
					on_finished=completed, wait_time=4)
QgsApplication.taskManager().addTask(task)

How to add postcode layer to selected buildings layer #QGIS