I'm using the action code of this question: "How to create a QGIS Action which loads a raster?"
qgis.utils.iface.addRasterLayer('E:\\Plot Sheet Devt\\1974-1984\\1250k\\[% Grid_Ref %].TIF', '[% Grid_Ref %]')
It is very useful for my work and I would need some more functions. The first one is that the action layer remains selected after the action. Now after loading raster It doesn't remain selected. I tried to add this code:
vl = QgsMapLayerRegistry.instance().mapLayersByName('catalogo_CTR') iface.setActiveLayer(vl)
but It doesn't work.
Other functions could be:
- to automatically assign SRC to loaded rasters
- to create a group of layer where to load the raster.
UPDATE Now, way is a linestring. I tried your code and at the beginning it gave a few hours on the name of the columns that I changed. Then I inserted the centroid of station in the variables of the ST_LineLocatePoint, because it asked me for a point as a second argument. I entered the new code in the application update. everything works but the order is null.
dumped_ways AS ( SELECT name, dmp.path1 AS way_part, dmp.geom FROM s_602_ptrc.way, LATERAL ST_Dump(geom) AS dmp )
SELECT ROW_NUMBER() OVER(PARTITION BY nway.name, nway.way_part ORDER BY nway._frac) AS id, station.nome AS station, nway.name, nway.way_part, station.geom FROM s_602_ptrc.station CROSS JOIN LATERAL ( SELECT dumped_ways.name, dumped_ways.way_part, ST_LineLocatePoint(dumped_ways.geom, ST_Centroid(station.geom)) AS _frac FROM dumped_ways ORDER BY dumped_ways.geom <-> ST_Centroid(station.geom) LIMIT 1 ) AS nway ORDER BY nway.name, nway.way_part, nway._frac ;