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.
WITH
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 ;
I think the problem is in Dumped_ways query. This is the result


crs.createFromSrid. I assign 3003 (Gauss Boaga Ovest) but every time It asks me to assign manually the CRS. – Daniele Piccolo Jan 23 '17 at 11:4127700with3003, the raster layers are set to(EPSG:3003, Monte Mario / Italy zone 1)without me having to manually assign a crs. Which QGIS version are you using? I tested this on QGIS 2.18.2 for Win7 64-bit. – Joseph Jan 23 '17 at 11:47fileName). Perhaps that was the culprit? I've edited my post =) – Joseph Jan 23 '17 at 11:55