Exporting SHP Assets to CSV with LatLong
NOTE: This has only been tested with point data, however complex geometries could probably also be used. It would just be a bit more work to rework geometry to single point data. Some of this might have already been done in the CDMSmith - CSDP project.
A. Reproject the layer to EPSG:4326 - WGS 84
- In the Layers pane, left click to select the layer to be exported.
- In the menu bar, select Vector > Data Management Tools > Reproject Layer...
- All defaults should be fine, but make sure the Target CRS is "EPSG:4326 - WGS 84"
- Click Run and note the new resulting layer.
B. Add attributes for latitude and longitude
NOTE: Longitude is X and Latitude is Y
- Right click the layer (make sure it's the correct layer if you have multiples) and select Open Attribute Table. If you had to reproject the original layer, make sure you select the Reprojected layer.
- Select "Open field calculator". This icon should be the fourth from the right and can also be opened with "Ctrl+I"
- In the resulting menu, set the "Output field name" to longitude"
- Change the "Output field type" to "Decimal Number (real)".
- Change Output field length to 16 and Precision to 8.
- Inside the "Expression" text box, type "$x"
- Click OK.
- Repeat steps 2 through 7 but name the field "latitude" and use the Expression "$y" instead of x.
- Close the attribute table.
C. Export to CSV
- Right click on the layer.
- Select Export > Save Features As.
- Change the Format dropdown to CSV.
- Give the file a path and a name to write to.
- Next to the "OK" button, uncheck the box "Add saved file to map" (we don't need to view it in QGIS).
- Click OK.