Read coordinates with variable Gauß-Krüger zone (meridian) in QGIS
I know no way to import point data with multiple projections from a single txt file into QGIS at once.
My quick-hack-solution would be to sort by x-coordinate, save all points within a single Gauß-Krüger zone as a separate txt-file, then load all 3 (?) of them as delimited text files with their respective correct coordinate systems (make sure on-the fly projection is activated).
Your project's projection will depend on your base map, but now all cities should show up in the correct places. I think you will even be able to merge them into a single point file.
The short answer is yes.
A good strategy without losing the data integrity consists into representing all the points in the same SRS, i.e. WGS84. In order to do this, you can:
- Add
hauptstadt.txt
asCSV
in QGIS using custom delimiter as space, encodingISO-8859-1
, trim fields, skip empty fields and geometry type none. - Save
hauptstadt
asDBF
(i.e.hauptstadt.dbf
) and load it in the ToC. Open the attribute table, start editing and calculate a new integer field
SRID
as:CASE WHEN regexp_match("x",'^(2[0-9]{6})$')=1 THEN 31466 WHEN regexp_match("x",'^(3[0-9]{6})$')=1 THEN 31467 WHEN regexp_match("x",'^(4[0-9]{6})$')=1 THEN 31468 WHEN regexp_match("x",'^(5[0-9]{6})$')=1 THEN 31469 END
Open a shell, change directory to the folder containing
hauptstadt.dbf
and then execute:ogr2ogr hauptstadt_4326.shp hauptstadt.dbf -dialect SQLite -sql "SELECT *, ST_Transform(MakePoint(x, y, SRID), 4326) AS geometry FROM hauptstadt"
ogr2ogr
will returnhauptstadt_4326.shp
and ... you're done!