1

I have a csv list of points with their reference in UTM (X,Y) format: 33411590,4225441;5657743,8981463;

As you can see, the first two digits of the X column are the zone number. When importing these data into QGIS (Import Text file as Layer), QGIS asks for a CRS (EPSG:32633 would be the choice) and takes the content of the X column as the X value, including the first two digits. Thereby, it places my point 33.000km too far east.

Is there any solution to change this behavior (ignoring the digits or even extracting their real information)? Or do I need to "cut" between Zone number and X value by myself, before feeding the dataset to QGIS?

  • 1
    maybe in the import csv options you can set "^33" as a regular expression break – Elio Diaz Nov 29 '17 at 18:19
  • That's a good workaround, thank you! My reg_ex code is ;|;33 (UTM_X is not the first column). However, it's still somehow unhandy as my csv file has got some more columns, possibly also containing point IDs or anything else starting with "33" - that would be cut away as well (and I have no control about it). – fuzzysolutions Dec 1 '17 at 9:52
  • ok, maybe you can try according to length, I think you can still save it with regex – Elio Diaz Dec 1 '17 at 15:45
  • 1
    Another choice would be to use EPSG:5650 which has the leading zone number included. But you can't mix data from different UTM zones in one layer. – AndreJ Dec 5 '17 at 6:30
0

I finally decided to solve this issue by saving the .csv as a new .geojson layer. In this layer, i can modify the geometry in order to cut away the unnecessary digits using modulo division:

def recalc_utm_geometry(layer):
    iter = layer.getFeatures()
    geometry_map={}
    for feature in iter:
        geom = feature.geometry().asPoint()
        x = geom[0]
        y = geom[1]
        x = x % 1000000  # cut first 2 digits
        geometry_map[feature.id()]=QgsGeometry.fromPoint(QgsPoint(x, y))
    layer.dataProvider().changeGeometryValues(geometry_map)

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.