I know, my question is similar to some old ones on this site.
I've a lot of CSV files (geo coordinates) to import to qgis (and then to convert them), and the usual way is not the best way to do it (too long).
I have almost 500 CSV files (wgs84 coordinates) and this is what I want to do:
- Import all CSV files at once into QGIS
- Project them
- Export them into CSV files (again) but with different coordinates (convertion to UTM33N)
I'm trying to understand how to use the python console but I'm not moving on 🙁
Can anyone explain to me how to achieve it step by step?
Best Answer
If you're looking to reproject csv files from the Python Console in QGIS then you could use the following script. All you would need to change are the three paths which are mentioned in the comments.
Essentially, the script imports your csv files into QGIS as shapefiles (assuming your geometric fields are named
X
andY
). It then uses theqgis:reprojectlayer
andqgis:fieldcalculator
algorithms from the Processing Toolbox to reproject and update theX
andY
fields with the new coordinates. It then saves these in a folder and converts them to csv files in a path you specify. So in the end, you have updated shapefiles and csv files in separate folders.Hope this helps!