3

Is there a sensible way to visualize coordinates like this as point layer in QGIS? X values starting with 2 are EPSG 31466, 3 is 31467 and 4 is 31468. I didn't try, but i think the same problem will arise with UTM zones?

hauptstadt.txt:
---------------
ID  Name    x   y
1   Kiel    3574000 6021000
2   Hamburg 3567000 5936000
3   Hannover    3551000 5805000
4   Bremen  3487000 5884000
5   Düsseldorf  2556000 5676000
6   Wiesbaden   3446000 5548000
7   Mainz   3447000 5541000
8   Stuttgart   3513000 5405000
9   München 4467000 5334000
10  Saarbrücken 2572000 5457000
11  Berlin  4593000 5822000
12  Schwerin    4461000 5945000
13  Potsdam 4573000 5807000
14  Dresden 5411000 5659000
15  Magdeburg   4475000 5777000
16  Erfurt  4433000 5649000
  • For UTM coordinates with zone numbers added to the Easting, see lgn.niedersachsen.de/download/71484/… – AndreJ Jan 29 '14 at 13:39
  • Which platform is used Windows or Unix. – huckfinn Jan 29 '14 at 16:05
  • I just added an answer which ensures data integrity and, at the same time, the right representation in a whatever GIS environment you like. – Antonio Falciano Jan 30 '14 at 10:28
2

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.

|improve this answer|||||
1

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:

  1. Add hauptstadt.txt as CSV in QGIS using custom delimiter as space, encoding ISO-8859-1, trim fields, skip empty fields and geometry type none.
  2. Save hauptstadt as DBF (i.e. hauptstadt.dbf) and load it in the ToC.
  3. 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
    
  4. 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 return hauptstadt_4326.shp and ...you're done!

enter image description here

|improve this answer|||||
1

You can use a pre processing routine ..here a small hack written in perl using proj.4 tools proj and invproj in an Unix environment. You can configure the printing routines in many ways to generate new text data, PostGIS statements and so on and reprojet it into may be in ETRS89 LEA (EPSG:3035).


        #!/usr/bin/perl -w
        # for the unix environment using proj.4
        use strict;

        # open the file
        open(FH,"<data.txt");

                    # Debug messages ON/OFF
        my $DEBUG = 0;

                    # Flag to dismiss the offset
                    # p.h. if you have UTM as source CRS
        my $dismiss_offset = 0;


        #ETRS89 LAEA
        my $dst_epsg = 3035;

        # setup the epsg dictionary
        my %epsg_dict = (
          2 => 31466, 
          3 => 31467,
          4 => 31468,   
          5 => 31469
        );

        # init line variable
        my $line='';

        # read the first 3 lines 
        $line=<FH>;
        $line=<FH>;
        $line=<FH>;

        # Iterate ove the data sets
        while ($line=<FH>) {

            # throw the \n line end away
            chomp($line);

            # Parse the fields wit mutiple spaces between
            my ($id, $name, $x, $y) = split(/\s+/,$line);

                            # skip this line if the first column 
                            # is'nt a integer
            next if ! ( $id =~ /\d+/ );

            # extract the offset 
            my $sector = int($x/1000000);

            # rebuild the real x coordinate
            # dismiss the sector offset
            $x -= ($sector * 1000000) if $dismiss_offset;

            my $epsg = $epsg_dict{$sector};

            # call proj and calc LonLat 
            my $result = `echo $x $y | invproj -f %2.8f +init=epsg:$epsg`;   

            # print control stuff
            print "INPUT: $id $name $x $y \n" if $DEBUG;
            print "PARAM: $epsg $sector \n"   if $DEBUG;
            print "TEXT:  $result" if $DEBUG;

            # reproject it and calc the new xy projection
            chomp $result;
            $result = `echo $result | proj +init=epsg:$dst_epsg`;
            $result =~ s/\t/ /;

            # Output coordinates in $dst_epsg
            print "$id $name $result";

        }
        # EOF

The result EPSG:3035:

  ./swap-epsg.pl 

    1 Kiel 4329933.80 3467667.74
    2 Hamburg 4321732.67 3382785.87
    3 Hannover 4303907.40 3252019.34
    4 Bremen 4240999.12 3331900.27
    5 Düsseldorf 4097611.47 3127822.91
    6 Wiesbaden 4195397.54 2996459.98
    7 Mainz 4196302.91 2989446.70
    8 Stuttgart 4260494.29 2852567.43
    9 München 4436877.87 2782391.59
    10 Saarbrücken 4101790.13 2908250.77
    11 Berlin 4549668.34 3273670.24
    12 Schwerin 4414292.21 3393007.22
    13 Potsdam 4530091.38 3258126.33
    14 Dresden 4582392.80 3112139.59
    15 Magdeburg 4432951.80 3225444.12
    16 Erfurt 4394464.89 3096328.57
|improve this answer|||||
  • The EPSG codes are valid, DHDN / 3-degree wide Gauss-Krueger zones. – mkennedy Jan 29 '14 at 17:18
  • I have to keep the sector offset in the x co-ordinate, right? – huckfinn Jan 29 '14 at 18:02
  • yep, these have the leading zone number in the false easting values. – mkennedy Jan 29 '14 at 18:17

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.