QGIS导出CSV文件时无法将Y、X坐标转换为十进制度数的问题求助
Hey Emil, I totally get the frustration of spending hours on a "simple" QGIS task—been there myself! Let's walk through why your coordinate conversion isn't sticking when exporting to CSV, and how to fix it:
Common Mistake: Using Pre-Calculated X/Y Fields (Wrong CRS)
The Y/X fields you added to your centroid layer are tied to the original CRS of your Denmark admin data (probably something like EPSG:25832 or EPSG:3044, UTM zones for Denmark). Changing the export CRS won't retroactively convert these existing fields—QGIS will just export their original values. Instead, you need to tell QGIS to generate new coordinate fields in EPSG:4326 during export.
Step-by-Step Correct Export Process
- Open your centroid layer and go to
Layer > Export > Save Features As...(or right-click the layer and select this option) - In the export dialog:
- Set Format to
CSV - Under CRS, click the dropdown and select
EPSG:4326 - WGS 84(make sure it's not set to "Layer CRS") - Scroll down to expand the Layer Options section:
- Change the
GEOMETRYdropdown fromAS_WKTtoAS_XY - You can customize the
X field nameandY field nametolonandlatfor clarity, or leave asX/Y
- Change the
- Optional but helpful: Check
Add saved file to mapso you can instantly verify the exported layer's CRS and coordinates
- Set Format to
- Click OK to export—your CSV should now have decimal degree coordinates (longitude between -180/180, latitude between -90/90)
If That Still Doesn't Work: Reproject First, Then Calculate Centroids
Sometimes export-time conversion can glitch if the original layer's CRS is misconfigured. Try this alternative workflow:
- First, reproject your original Denmark admin data to EPSG:4326:
- Right-click the admin layer >
Export > Save Features As... - Choose a vector format like
GeoPackage, set CRS toEPSG:4326, save the new layer
- Right-click the admin layer >
- Then, calculate centroids on this reprojected layer:
- Use
Vector > Geometry Tools > Centroids(or the Processing Toolbox's "Centroids" tool) on the EPSG:4326 admin layer
- Use
- Finally, add X/Y fields to this new centroid layer (using
Field Calculatorwith$xand$yexpressions) and export to CSV—these coordinates will already be in decimal degrees
Quick Verification Check
After exporting, open the CSV and confirm:
- Longitude (X) values should fall between -180 and 180
- Latitude (Y) values should fall between -90 and 90 (Denmark is in Northern Europe, so your Y/lat should be positive, around 55-57)
Give these steps a try—one of them should get you the correct decimal degree coordinates you need!
内容的提问来源于stack exchange,提问作者Emil Nyboe Blicher

