3

I am new to QGIS.

I have 2 point layers. Layer 1: 1700 points, Layer 2: 1704 Points.. Both are shapefiles

1700 Points are identical. only 4 points are different (different coordinates). Now I want to compare both Layers and create a new layer from the result, so the final layer should only have these 4 points. My problem is the following:

If i choose Layer 1 first, the result is 1700 points. If I choose Layer 2 first, the result is 1704 points.. I guess the problem is, that both layers are completely different (not a single attribute is identical).

How I can I get the correct result, based on the geo-coordinates?

That should give me only 4 points output. I have to do this for around 46.000 points.

Field names Layer 1:

OBJECTID, FID_Hausko, nasoid, lebenszeit, lebensze_1, bundesland, ortschlues, ortschlu_1, ort, ortsteil, strassensc, strassen_1, hausnumm_1, unverschlu, infotext, xwert, ywert, aktuell, FID_Gemein, OBJECTID_1, gemeindezu, nasoid_1, id_1, lebensze_2, lebensze_3, anlass1, anlass2, schluessel, bezeichnun, gemeindeke, herkunft, herkunft_e, aktuell_1, hatgeometr

Field names Layer 2:

id, lat, lon, ags, kid, plz, ort, ortsteil, str, hnr, adz, kvz_id, apl_bez, nb, adsl, vdsl, vec, versorgt_d, knb, hh_me, hh_ibv, vzk_ist, db_ist, kabelnetz, mobilfunk_, mobilfun_1, mobilfun_2, mobilfun_3, fttb, ist_versor, hh_d_g, hh_u_g, ausbaug, exist, kein_Ausba

PolyGeo
  • 65,136
  • 29
  • 109
  • 338

1 Answers1

5

I think the answer is to use the Select By Location tool. Select By Location

Using the 'equals' option, you should be able to select all the matching points. Then use inverse selection to get the unique points.

Inverse Selection

Then use the save as option to create a new shapefile. Hope this helps!

Anonymous
  • 81
  • 6
  • doesn't seem to work... choosing Select by location tool gives me "0 objects selected"... here's a pic of my map.. the blue points are the different ones: https://img4.picload.org/image/riaciadr/al1.png – Patrick Hachmeyer May 27 '17 at 14:35
  • maybe the problem is the different EPSG? I've got the 2nd Layer file with different settings and "converted" it by "save as..".. now, both layers have the same "configuration", but maybe there are some issues with that? – Patrick Hachmeyer May 27 '17 at 14:56
  • I tried it out with a few demo points, which would be in the same CRS. Have you tried increasing the precision parameter in the select dialogue box? If the points are only slightly off, that may help. You should look at the CRS of each layer in the layer properties, as well as the QGIS project (which may have a different CRS). – Anonymous May 27 '17 at 15:07
  • CRS are identical - for all layers as well as for the project itself.. I tried to increase the precision without success... 0 precision gives me 0 objects and 0,000001 precision gives me ALL (1700) objects – Patrick Hachmeyer May 27 '17 at 15:14
  • I can't think of what the problem might be then, unless the points are slightly offset from each other. You could make a "lat" and "long" field for the other layer, and compare them. If the two layers really have identical geometry, a select by location should have worked. – Anonymous May 27 '17 at 15:24
  • Did one of the layers come from a delimeted text file? CRS seems to be a common problem with them; also, I have in the past accidentally rounded off xy fields when working with CSVs in excel. I might have misunderstood what the precision parameter does then. – Anonymous May 27 '17 at 15:29
  • unfortunately I don't know.. one layer came from the government and I have no idea what happend to that layer.. – Patrick Hachmeyer May 27 '17 at 15:50
  • Am I right in thinking that one layer was made from the other using "Save As, so it should have the same geometry?" I don't speak deutsch, but do the xwert, ywert, lat, and long fields contain xy coordinates? To compare the two layers' geometry, you could calculate an x and y field with the expression $x and $y. This question has more info on that field calculation if you want it. https://gis.stackexchange.com/questions/7199/how-do-i-calculate-the-latitude-and-longitude-of-points-using-qgis – Anonymous May 27 '17 at 15:58
  • If the x and y coordinates of each layer are slightly different (if the problem is that the second layer got rounded off at some point), you could export the layers to a CSV using the save as option, round off both x and y fields, add them into QGIS as delimeted text layers using the new x and y fields, save each as ESRI Shapefiles, and then do the Select by location as I said earlier. – Anonymous May 27 '17 at 16:09
  • If the points are just slightly off you could also try creating a buffer around the points and using the select by location tool on that layer. Other than that, I am not sure I can help you at all with this. – Anonymous May 27 '17 at 16:12
  • aaahh I see.. yea, they are rounded at some point.. I just saw that after exporting to CSV... could give me a short introduction how to import the two CSV-Files back to QGIS as delimeted text layers using the "new" x and y fields? – Patrick Hachmeyer May 27 '17 at 16:23
  • I am 35 minutes away from my computer right now, so I can't add a screenshot, but there is a tutorial here: http://www.qgistutorials.com/en/docs/importing_spreadsheets_csv.html They should import with a default CRS (probably wgs 84) or there will be a pop up crs selection window, depending on your settings. If the tutorial does not make it clear, the new xy fields will be selectable in a drop down menu in the import dialogue. I think it defaults to a csv in the dialogue. – Anonymous May 27 '17 at 16:55
  • okay I'm done with QGIS... in both layers I created 2 new fields: lat and lon and used the fieldcalculator to generate new latitude and longitude fields... then I checked both layers and all points are 100% identical !!!!! but whatever I do, I can not compare layer 1 with layer 2 >:( Here you can see that lat and lon are identical for 1 Point in Layer 1 and Layer 2: https://img4.picload.org/image/riawgiol/2pts.png – Patrick Hachmeyer May 28 '17 at 15:24
  • I also exported both layers and re-imported them to make sure, that QGIS uses the lat and lon fields as X and Y geometry fields – Patrick Hachmeyer May 28 '17 at 15:31
  • All I know is, it worked for me. The only things I can suggest now is that you try the select by location on a different set of layers to see if you can replicate the problem, and/or try the spatial query plugin (https://docs.qgis.org/2.2/en/docs/user_manual/plugins/plugins_spatial_query.html). – Anonymous May 28 '17 at 20:31