2

I was looking for a case to easily add points to a layer from coordinates. I my case I often want to quickly add one or a few points manually to an existing layer. I have seen an occasional reference that it would be possible to paste it directly into a layer. It would fit perfectly in my workflow to copy some coordinates in an external application e.g. google maps/osm to paste (ctrl-v) into an existing layer. So I tried pasting the syntax in the two CRS used in my current file:

  • "point(571287,6799222)" (CRS: New Amersfoort)
  • "point(48.0578195,7.2497044)" (CRS: WGS84)

Than QGIS prompts that features are pasted succesfully:

Paste features: 1 features were successfully pasted

The problem is that indeed a extra row is added to the table, but no coordinates are actually added. Also when I 'extract' the coordinates in the table field calculator with the functions $x adn $y it appears as null instead of points added in a different way and which are showing or giving an output : enter image description here

I guess there is something wrong in the syntax but I coul not find any references or guides on what syntax QGIS is expecting. Is there somebody who can provide more background on how this features is supposed to work?

P.s. I know there are different ways of getting points of exact coordinates into Qgis. My question is that apparantly this low-key workflow is supposed to work and I cannot figure out how or found any more info on this.

JosE
  • 73
  • 1
  • 6
  • 1
    Could you either describe the workflow in more detail, or add a reference to your question, so we can have a better look? Also: Should it be "now coordinates" or "no coordinates"? – Erik Aug 12 '19 at 07:03
  • So you copy some coordinates in textform and paste them into a shapefile layer in QGIS? – Erik Aug 12 '19 at 11:23
  • yes indeed, in Qgis 2.x a plugin was needed for that and apparantly in Qgis 3.x it could be done directly but I seem not to get the right syntax – JosE Aug 12 '19 at 11:30
  • What exactly happened in QGIS 2.X, when you used the plugin? – Erik Aug 12 '19 at 11:36
  • in Qgis 2.x you had to privide the coordinates separated by a comma (,) and than the point was added. But for Qgis 3.x the work as described by Andreas Muller below is supposed to work. – JosE Aug 12 '19 at 12:10

2 Answers2

1

For me it works with the following steps:

  • create a new layer, i tried the scratch layer, also it should be possible to load an existing layer
  • make sure it is editable
  • copy the coordinate (ctrl-c), i tried the WKT-Format, eg.: POINT (30 40) and paste it into the QGIS window (ctrl-v). Always use a blank as seperator.
  • look into the table and or zoom to layer, so see the new entry
  • save the changes
Andreas Müller
  • 2,622
  • 13
  • 20
  • And where do you paste the coordinate? – Erik Aug 12 '19 at 11:47
  • I used copy and paste (ctrl-c and ctrl-v), pasted it in to the QGIS window, which must be active, to receive the paste command. I am on windows, if that may matter? Updated my answer... – Andreas Müller Aug 12 '19 at 11:52
  • I can confirm, that pasting an uncompatible format wil create a feature without any data and qgis displays that "features were succesfully pasted". So try the points without Quotation Marks and crs. – Andreas Müller Aug 12 '19 at 11:58
  • Are capitals necessary, or does it not matter if you write point or POINT? – Erik Aug 12 '19 at 12:02
  • Both works, initially i used lowercase, but uppercase works too – Andreas Müller Aug 12 '19 at 12:04
  • This is indeed the workflow I try to get to work. So have you managed to actually get the point to be shown on the map? I tried it without the quotation marks: point(1325854,291524) Than the attribute is created in the table but no x and y coordinate is shown. Also null is presented when I extract the coordinate in the calculated column with $x and $y – JosE Aug 12 '19 at 12:07
  • i tried to add your point, but it was not created, just as you described. But my layer is set to WGS84. Inserting a point like in the answer above, it shows a point marker in map canvas. – Andreas Müller Aug 12 '19 at 12:33
  • so it looks like it is something on my local machine. I will give a few more goes with different format e.g. dot (.), comma(,) or semi colom (;) Maybe that is where it goes wrong. – JosE Aug 12 '19 at 12:39
  • Ok I have found the solution probably due to regional settings the syntax to be fed to Qgis is slightly different in my case I had to leave out the comma (,) but use a space. like this: point(49.0578195 8.2497044). In that case the point is shown on the map. Thanks for the feedback – JosE Aug 12 '19 at 12:56
  • Ah, ok, i wrote it wrong! WKT doesn't use a comma to seperate x and y, it has to be a blank. Corrected the answer. – Andreas Müller Aug 12 '19 at 13:00
0

If you want attributes to be automatically filled when you paste a feature into QGIS, use a default field value.

  1. open layer properties > attributes form
  2. check the box for "Apply default value on update"
  3. enter the appropriate expression (eg $x or $y) into the default value text box

The method is explained in more detail (with screenshots) here: How to set a default value for attributes in shapefiles? It's from an older version of QGIS but this feature hasn't changed.

You might need to save your edits to the layer for the change to be displayed. You might also need to close the attribute table and open it again before you see the field values.

csk
  • 24,827
  • 3
  • 32
  • 70