Hi Mike,

there are probably several solutions for your problem. Below a script, which uses the imported csv-layer and creates a memory layer for each feature.

# active-layer = csv-import-layer
vl = iface.activeLayer()

# the group for the single-point layers in Layer-Panel
target_group = QgsProject.instance().layerTreeRoot().addGroup('group_1')

# iterate through the csv-import-layer
for f in vl.getFeatures():
    # create a clone of this layer with only one feature
    vl_clone = vl.materialize(QgsFeatureRequest().setFilterFids([f.id()]))
    # set the name for the new layer, here using the attribute 'name' of the csv-import-layer
    # adapt if necessary or create another name
    vl_clone.setName(f['name'])
    # parameter 2 False => dont't add to layerTreeRoot...
    QgsProject.instance().addMapLayer(vl_clone,False)
    # ...but to the above created group
    target_group.insertLayer(-1, vl_clone)


Note: the script creates temporary memory-layers, which you must convert to permanent layers (context-menu > Make Permament)


hth

Ludwig

Am 09.02.26 um 21:37 schrieb ERT - Mike Breiding via QGIS-User:
Greetings,
I was successful in adding lat/long points to my project from a .cvs file:
Lat,Long,Mile
-79.924454,39.709589,M 1
-79.936296,39.698546,M 2
-79.939802,39.68499,M 3
etc.

When the points are added to my project all the of them are in one layer that contains all the points.
I wish to have all the points as separate layers contained in a Group.
How can I accomplish this?

Thanks,
WV-Mike
_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to