[QGIS-Developer] wrong VRT layer extent

PIERRE Sylvain sylvain.pierre at alsace.eu
Thu Nov 23 08:21:33 PST 2023


Hi,

Trying to simply export VRT layer , getting a wrong extent and exporting only extent of first raster part of VRT with this code :

      list_dalles = []

        features = layer.selectedFeatures()
        for f in features:
            file_name = f['NOM_DALLE']+'.tif'
            dir_name = f['repertoire']
            full_file_name = os.path.join( dir_name, file_name)

            if os.path.isfile(full_file_name):
                list_dalles.append(full_file_name)

        parameters = { 'ADD_ALPHA' : False,
                    'ASSIGN_CRS' : None,
                    'EXTRA' : '',
                    'INPUT' : list_dalles,
                    'OUTPUT' : outVRTfile,
                    'PROJ_DIFFERENCE' : False,
                    'RESAMPLING' : 0,
                    'RESOLUTION' : 0,
                    'SEPARATE' : False,
                    'SRC_NODATA' : '' }

        #processing.runAndLoadResults("gdal:buildvirtualraster", parameters)
        processing.run("gdal:buildvirtualraster", parameters)

        vrtLayer = QgsRasterLayer(full_file_name, "bidon")

        QgsProject.instance().addMapLayer(vrtLayer, True)

        file_writer = QgsRasterFileWriter(outfile)
        provider = vrtLayer.dataProvider()
        pipe = QgsRasterPipe()

        if not pipe.set(provider.clone()):
            print ("Cannot set pipe provider")

        print(str(provider.extent()))
        file_writer.writeRaster(
            pipe,
            provider.xSize(),
            provider.ySize(),
            provider.extent(),
            provider.crs())

I don't find anything about that, any idea ?

Thanks

[cid:image001.jpg at 01DA1E31.806E1620]
Sylvain PIERRE
Chef de projet système d'information
Direction des Systèmes d'Information et du Développement Numérique
Service Projets et Ingénierie Numérique
Collectivité européenne d'Alsace
Tél : 03 88 76 68 88
sylvain.pierre at alsace.eu<mailto:sylvain.pierre at alsace.eu>
www.alsace.eu<http://www.alsace.eu>
[facebook]<http://www.facebook.com/toutelalsace> [twitter] <http://www.twitter.com/toutelalsace>  [insta] <http://www.instagram.com/toutelalsace>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231123/d69e251b/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 8094 bytes
Desc: image001.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231123/d69e251b/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 827 bytes
Desc: image002.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231123/d69e251b/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 852 bytes
Desc: image003.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231123/d69e251b/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 1028 bytes
Desc: image004.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231123/d69e251b/attachment-0005.png>


More information about the QGIS-Developer mailing list