[Qgis-user] Adding coordinates to layer
Ludwig Kniprath
ludwig at kni-online.de
Mon Dec 2 15:36:20 PST 2024
Hi Pat,
Step 1 (already done): import csv as "Delimited Text Layer". Since there
are no coordinates this results in a geometry-less layer.
Step 2: export and load the just imported csv as vector-layer
(GeoPackage, Shape), geometry-type "Point", desired projection. This
results in a Point-Layer with the same features and attributes as the
csv but still without valid geometries.
Step 3: Update the empty geometries with valid points. Sadly there is a
lack in QGis, edit existing geometries => OK, creating new features with
geometries => OK, update geometries in geometry-less features => not
supported out-of-the-box.
So I (not Anthropic Claude 😉) wrote a script, attached as python file.
Operating instructions:
1: Load script into python console
2: activate the exported vector-layer from step 2
3. run the script
4. open attribute-table
5. select the desired feature in table
6. digitize the point-geometry for the selected feature by click on map
7. repeat steps 5 and 6 as often as you like
8. stop and save edits
Afterwards the features have valid geometries and can be edited with
QGis on-board tools
Note:
The script does not write coordinates to the attribute-table but creates
point-geometries. You can afterwards extract x- and y-coordinates into
according fields by QGis-Field-Calculator.
hth
Ludwig
Am 02.12.24 um 14:08 schrieb Pat Brown via QGIS-User:
> Hi
> I have a csv file with data about various mines. It includes
> descriptions of locality but no coordinates. I have added this file
> to qgis and created a shapefile. I now want to add the coordinates of
> each mine by searching for its locality on a basemap in qgis then
> clicking on the map to add the coordinates to the shapefile attribute
> table. Is this possible or do I have to search for each location on
> Google Earth, for example, then write out the coordinates and add them
> to the attribute table manually?
>
> Thanks
>
> Paddy
>
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2024-12-02 MapToolUpdateNullGeometry.py
Type: text/x-python
Size: 2604 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20241203/b896d1af/attachment.py>
More information about the QGIS-User
mailing list