TransWikia.com

Loading a GeoJSON in QGIS using Python but the layer can't be edited

Geographic Information Systems Asked by GISSIAH on December 21, 2020

def loadLayer(self):
    layer = self.dlg.listWidget.currentItem().text()
    url = self.getRoute(layer)
    data_req = requests.get(url)
    data_layer = data_req.json()
    with open('xx.geojson','w+') as f:
        json.dump(data_layer,f)
    layer = QgsVectorLayer('xx.geojson',layer,' ogr')
    QgsProject.instance().addMapLayers([layer])

I’m getting data from a server in the form of a feature collection. I write it into a GeoJSON file then load it in QGIS. The layer loads properly but if I try to edit some features it is not possible.

One Answer

Different possibilities:

Did you also try something like iface.activeLayer().isEditable()? Sometimes not editable due to file permissions.

Answered by ThomasG77 on December 21, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP