Hot answers tagged

47 votes

Creating point features with exact coordinates in QGIS

No Plugin Required This is possible with QGIS without extra plugins using the Advanced Digitizing panel. This tool allows entering exact coordinate values as well as constructing points at given ...
Matthias Kuhn's user avatar
30 votes

Extracting raster values at points using Open Source GIS?

I was having problems with the QGIS and SAGA GUI tools mentioned in this thread (Raster values to points was failing for some reason and throwing unhelpful errors and the GRASS v.sample created a ...
Ian's user avatar
  • 465
30 votes

Calculating latitude and longitude of points using QGIS

With QGIS 3 you can use two simple expressions doing all the reprojection in one go without having to care about settings or projections of the layer. To get decimal degrees as float values use: For x ...
MrXsquared's user avatar
  • 32.5k
30 votes
Accepted

How to randomly subset X% of selected points?

Here's a python function that will select random features in a layer based on percent, ignoring current selection: def SelectRandomByPercent (layer, percent): #layer variable is the layer name in ...
Emil Brundage's user avatar
28 votes
Accepted

Nearest distance between point and line layers in QGIS

As an alternative, you could: Use the Convert Lines to Points tool from: Processing Toolbox > SAGA > Shapes - Points > Convert Lines to Points (Add points over small distances. E.g. add a point ...
Joseph's user avatar
  • 75k
28 votes
Accepted

Generating rectangle centered by point in QGIS

Check the "Rectangles, Ovals, Diamonds" geoalgorithm in the QGIS's Processing Toolbox (Ctrl+Alt+T)
Taras's user avatar
  • 29.9k
27 votes

Drawing lines from points in QGIS

To create polygons from points, you can also use "Points to path", then "Lines to polygons" tools without need to install any plugin
ncelik's user avatar
  • 542
27 votes

Displaying overlapping points in QGIS

Try renderers: "Point displacement" or "Point Cluster" from symbology menu. (QGIS 3.x required for point cluster.) As point displacement they can look like this for example: And ...
MrXsquared's user avatar
  • 32.5k
21 votes
Accepted

Representing uneven tree canopy spread around point in QGIS

I have exactly the same use case at work, so this is what I have come up with: Solution 1 (ellipse) This looks fairly regular, but is the least precise generally, IMO. Use the ellipse marker symbology ...
she_weeds's user avatar
  • 10.1k
21 votes

Generating start and end points for LineStrings

If you have QGIS 3.4 you can use Extract specific vertices tool to extract the endpoints by inputting 0, -1 at the vertex indices as you can see below: The tool is located in Processing toolbox -> ...
ahmadhanb's user avatar
  • 40.2k
21 votes

Generating rectangle centered by point in QGIS

There is "Geometry by Expression" tool. You should use in a Projected Coordinate System. Select "Polygon" as "Output geometry type" option. Click "Expression" ...
Kadir Şahbaz's user avatar
20 votes
Accepted

Re-locating points randomly at certain distance in QGIS

This answer has been updated several times to get a solution that gradually adds complexity to the expression. For the final solution, you should go directely to the very bottom (step 5). The history ...
Babel's user avatar
  • 63.1k
19 votes
Accepted

Creating all possible line segments between all points using QGIS

You can achieve your goal using the Field Calculator. Using the Geometry Generator, with Linestring geometry type, use this expression: collect_geometries( array_foreach( aggregate('...
Val P's user avatar
  • 3,808
19 votes

Creating perpendicular lines on line using QGIS

Edited answer: My first solution (see below) was for visualisation purposes only. But as you mentioned afterwards, you need the actual geometry. So this here is how to do it: Go to Menu Processing / ...
Babel's user avatar
  • 63.1k
18 votes

Is it possible to create a point within a Polygon (not a centroid)?

EDIT : answer by @Kampau Ocu : "point on surface is already within QGIS3 Processing Toolbox" You can also use the plugin RealCentroid that does just what you're looking for : RealCentroids plugin ...
gisnside's user avatar
  • 7,768
18 votes
Accepted

What's the difference between QgsPoint, QgsPointXY and QgsGeometry.fromPointXY(QgsPointXY()) in PyQGIS?

QgsPoint is a point class which supports Z (3D) and M values. (What are Z and M?) x, y, z, m = 10, 10, 20, 5 QgsPoint(x, y) # 2D # <QgsPoint: Point (10 10)> QgsPoint(x, y, z) # 3D # <...
Kadir Şahbaz's user avatar
18 votes
Accepted

Creating equally split buffers between points in QGIS

You can use "Voronoi Polygons", "Buffer" and "Clip" tools, respectively (or "Buffer" > "Voronoi Polygons" > "Clip"). Step 1. "...
Kadir Şahbaz's user avatar
17 votes

Creating point features with exact coordinates in QGIS

In QGIS 3, the NumericalDigitize tool no longer seems to be available but here is a further solution. As of QGIS 3 you can simply copy and past WKT directly into the canvas. This works for single or ...
MappaGnosis's user avatar
  • 33.6k
17 votes
Accepted

How to use ST_VoronoiPolygons() in PostGIS?

The trick when using a table of points is to feed all the points into ST_VoronoiPolygons by using ST_Collect, which simply combines all the points into a MultiPoint, without performing any spatial ...
John Powell's user avatar
  • 13.6k
17 votes
Accepted

Creating point at line end using QGIS

There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Let's assume there is a polyline layer called 'polylines' (blue lines). With the ...
Taras's user avatar
  • 29.9k
17 votes
Accepted

Convex Hull in GeoPandas

If you want a single geometry representing the whole DataFrame, this should do it: within_15_hull = within_15mins.unary_union.convex_hull According to the unary_union docs: Returns a geometry ...
snowman2's user avatar
  • 7,141
16 votes
Accepted

Finding closest polygon to point in PostGIS

Several ways to do this. One is to find the distance and order ascending. SELECT geom FROM polys, points WHERE points.gid = 1 AND ST_DWithin(poly.geom, points.geom, 1000) ORDER BY ST_Distance(a....
Rob Skelly's user avatar
  • 3,101
16 votes

Splitting line layer using another point layer in QGIS

There is the SAGA's "Split Lines at Points" module (search in the Processing Toolbox Ctrl+Alt+T: QGIS Processing Toolbox > SAGA > Vector line tools) In the above example all my points ...
Kazuhito's user avatar
  • 30.4k
16 votes

Creating square polygons of given length from single corner point in QGIS

There is "Vector geometry > Geometry by Expression" tool in Processing Toolbox. You should use in a projected coordinate system. Select "Polygon" as "Output geometry type&...
Kadir Şahbaz's user avatar
15 votes

Joining attributes from nearest point in QGIS?

In QGIS 3.8 and above the "Join attributes by nearest" native tool in Processing Toolbox does the job easily!
Antonis Michalakis's user avatar
15 votes

Calculating latitude and longitude of points using QGIS

Since QGIS 3.8 (June 2019), there is now an algorithm to add the X and Y values called "Add X/Y fields to layer". It can reproject coordinates on the fly. If you still need a Degree Minute ...
etrimaille's user avatar
  • 7,040
15 votes
Accepted

Detecting if point is on left or right side of line in PostGIS?

select (ST_Azimuth(h.vec) - ST_Azimuth(h.seg)) from ( select ST_MakeLine(cp.p, point.geom) vec, ST_MakeLine(cp.p, ST_LineInterpolatePoint( line.geom, ...
dmitry.v.kiselev's user avatar
15 votes
Accepted

Getting correct WKT result to 4 decimal places using PostGIS

The simplest way to round geometry coordinates is to use ST_SnapToGrid: SELECT ST_AsText(ST_SnapToGrid('POINT(-0.685239554498251 51.4940418030595)', 0.0001)); st_astext ----------------------- ...
Mike T's user avatar
  • 41.6k
15 votes
Accepted

Getting coordinates of point on mouse click using PyQGIS

You need QgsMapToolEmitPoint class to do that. Following code works well for that purpose: from qgis.gui import QgsMapToolEmitPoint def display_point( pointTool ): print '({:.4f}, {:.4f})'....
xunilk's user avatar
  • 29.4k
15 votes

Finding nearest neighbor for each point in the same table

This is essentially a duplicate question of multiple others, with the sole difference being a table self-join. However, all queries currently present in this post have delicate CRS misunderstandings, ...
geozelot's user avatar
  • 28.7k

Only top scored, non community-wiki answers of a minimum length are eligible