2

In QGIS I am trying to convert coordinates from a CSV file. QGIS can use another projection, but when I try to export this layer (and changing the output CRS) the coordinates in the CSV file itself won't change. Is there a way to transform/convert these coordinates and get the new values exported?

Update of details:
I have coordinates for points in a circle around a center point (geocoded from a service using WGS84).

Points in a circle

These coordinates are in WGS84. I want these converted to SWEREF 99 TM, since that is what my other software is using. But when I import them, it looks like this: Import oval

I have use field calculator with on a CSV file and a SHP file, using this formula:

x(transform($geometry,'EPSG:4326','EPSG:3006'))

The attribute form for the CSV file looks like this: CSV attribute

The formula seems to be working.

The SHP file (exported from the CSV file) attribute form looks like this: SHP attribute

The formula is creating NULL values.

Still, if I use the converted coordinates from the CSV file (export it to a new CSV file)

Most likely there is some basic knowledge regarding coordinate transformation that I do not possess...

  • You might also be confusing "on the fly projection" with actually projecting it into a new coordinate system. I would suggest Projecting the actual file, or using the field calculator as suggested by Erik. Also, "changing the projection" on the file, may only produce great confusion for users downstream as you may be using the same coordinates, but telling the computer that they are in a different projection that they are... – bwp8nt Oct 2 at 23:54
  • Thank you for your clarification! I will have that in mind. – Andreas Oct 5 at 7:08
  • I suggest you read up on the differences between geographic (e.g. WGS84) and projected (e.g. SWEREF 99) CRS. Basically one preserves angles, while the other preserves areas & distances - this is why circles created in one type of CRS aren't circles in the other. – Erik Oct 13 at 13:51
  • Ok, thank you, I will do that. – Andreas Oct 14 at 14:02
7

Using the field calculator x(transform($geometry,'EPSG:source','EPSG:target') transforms the x coordinate of a point in the source EPSG-code to the target EPSG-code. Same goes for the y coordinate.

Or you could save the CSV as a shapefile to the desired CRS, use add geometry column and then export the data to CSV again.

| improve this answer | |
  • Thank you very much, this will help me. I didn't know about that function/command. – Andreas Oct 5 at 7:09
  • Unfortunately, I cannot get it to work. Probably because my lack of knowledge i QGIS expressions... I have tried that expression above, and other variants of it (I've searched for more posts on Stackexchange). I also tried the save CSV to desired CRS, but QGIS doesn't seem to transform it to another CRS. Is it possible to explain it even more to a beginner :-? – Andreas Oct 5 at 10:26
  • Which CRS/EPSG-codes did you use for source and target? – Erik Oct 5 at 10:48
  • Source = EPSG:4326 WGS84, target = EPSG:3006 (Swedish SWEREF 99 TM) – Andreas Oct 7 at 7:03
  • What happens when you run x(transform($geometry,'EPSG:4326','EPSG:3006'))? – Erik Oct 7 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.