2

I have a point (in the middle of the sea) and I have to measure the distance from this point to the land.

Normally I can use the measure tool.

However, if I have to know exactly the distance from this point to the land but exactly in the NW direction, then I s there a way to create "orientated" (N, S, W, E..) lines so that I can use the field calculator to measure the distance?

2 Answers 2

2

If you don't want to script a solution, there is a relatively easy way to achieve what you want using the editing tools (it is a lot easier to do than describe so don't be put off):

  1. Create a line layer and make it editable.
  2. In Settings->Snapping options set snapping on your point layer, the land layer and your new line layer. I usually use something like 4-10 pixels.
  3. with your new line layer highlighted click CAD-like improved line capture in the digitizing tools and set the angle in the dialog box to -45 degrees (for NW) and click on the lock check-box. Now you can only digitize lines NW from your point.
  4. left-click on your point (with snapping the red X will jump exactly to your point). Next right-click well inside your land polygon. A line will be drawn longer than you need but at exactly -45 degrees. For some reason this actually seems to give me two lines but we're going to ignore both of them shortly - this line(s) is just for reference.
  5. Switch to the trace edit tool and click again on your point and trace the line you have just created until you snap with both it and the land polygon. Delete or ignore all other lines
  6. Save your edits and you could label the layer using Geometry->$length or have QGIS calculate that as a new field.

I have had this tool installed as a plugin for so long I have come to think of it as standard! Go Plugins->Manage and install plugins and search for the Improved Polygon Capturing tool (works for lines as well). Click install and the button should appear in your standard editing tools bar.

5
  • HI, thanks for your reply. I cannot find the CAD-like improved line capture tool. Is this an additional plugin?
    – matteo
    Commented Nov 5, 2014 at 8:31
  • Yes! I forgot to mention it is a plugin - see my edit for instructions on how to get it. Commented Nov 5, 2014 at 8:41
  • unfortunately this plugin is deprecated for the new QGIS releases....
    – matteo
    Commented Nov 5, 2014 at 8:56
  • I have it installed in QGIS 2.6 and it works - I have just checked and it says that it works with V2.x so there should be no problem. The GitHub documentation lags behind. Note the updates and that it is no lonnger experimental Commented Nov 5, 2014 at 9:05
  • The plugin CADInput will replace Improved Polygon Capturing. The latter still works just fine for now (it just won't be updated in the future). I haven't tried CADInput yet but I know for certain that Improved Polygon Capturing works. Commented Nov 5, 2014 at 9:10
1

You can find methods to create lines from points on this post. How to draw lines from two points in a CSV?

So you need to add one pair of coordinate from your point based on your orientation and this defines your lines. This is basic trigonometry, but you should make sure that you work in a conformal projection (e.g. Mercator) if you want to preserve the angles.

Once you have your lines, you can use the "vector>geoprocessing tool>difference" tool to erase the "land" from your lines, and the lenght of the lines is then the distance to the coast.

2
  • thanks for your reply. so there isn't a way to draw lines from a point till they find another polygon?
    – matteo
    Commented Nov 4, 2014 at 11:34
  • not that I know, but in theory you could use the equation of a line to test its intersection with all polygons boundaries.
    – radouxju
    Commented Nov 4, 2014 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.