Hot answers tagged

11

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 / Toolbox / Create points along input lines to create points on the line in a set distance - as I can see in your screenshot, the points should have a distance of ...


10

In QGIS 3.10 it's possible to dynamically create zig-zag lines and wavelines with the help of the indispensable "geometry generator" and a custom Python expression function. from qgis.core import qgsfunction,QgsExpressionContextUtils,QgsExpression,QgsProject,QgsPoint,QgsGeometry @qgsfunction(args='auto', group='Custom', usesGeometry=False, referencedColumns=...


10

Solution for QGIS Let's assume there are two layers 'squares' (green) and 'lines' (blue) with its corresponding attribute tables accordingly, see image below. Step 1. Proceed with 'Extract vertices' (Apply additionally 'Delete duplicate geometries' or 'Remove duplicate vertices' if needed) Step 2. By means of a 'Virtual Layer' through Layer > Add ...


10

The symbol is from multiple parts: A white 5mm Simple Line as base, using a round join style. On top of that: A Hashed Line using an interval of 6mm and a hash length of 3mm which is drawing a red 3mm Simple Line, using a round cap style. On top of that: The same configuration for a Hashed Line but in white On the whole layer level (under Layer ...


8

You can use project() method. project returns the distance along this geometric object to a point nearest the other object. a = LineString([(1, 1), (9, 1), (9, 6), (4, 6), (4, 3)]) p = Point((4,4,)) a.project(p) #20.0 Note that if you define a as LineString([(4, 3), (4, 6), (9, 6), (9, 1), (1, 1)]), you get 1.0.


8

Solution for ArcGIS using ArcPy You can Generate Near Table to find coordinates to nearest line from each polygon Move each polygon to that coordinate with da.UpdateCursor Clip the line using polygons as clip features import arcpy arcpy.env.workspace = r'C:\GIS\Somedatabase.gdb' #Change lines = 'polyline' #Change polygons = 'squares' #Change. WILL BE ...


8

Change length to $length. length is a function which returns the length of any geometry linestring. It is used like this: length(geometry). $length returns the length of the actual line feature.


8

Using the following script you can get the result you expect. But firstly, use "Vector geometry > Multipart to singleparts" tool if the line pairs of the same color are the same features. Because the script uses the nearest point between geometries. Set layer name. You also need to set epsilon (eps) value to assume two lines intersect or touch. ...


7

This is a modification of Kazuhito's answer using native QGIS algorithms using QGIS 3.12. In the QGIS Processing Toolbox, there are the tools Split lines by maximum length and Drape (set Z value from raster). Before starting; 0.) make sure your DEM and road data are projected onto the same CRS.(This is no longer strictly necessary in QGIS 3.x using native ...


7

This is not taking any attributes into account (for example road name stored in each address point), just finds closest road using closestSegmentWithContext. Then you can merge (or spatial join etc.) output lines with your roads. roadlyr = QgsProject.instance().mapLayersByName('TR_ROAD')[0] addrlyr = QgsProject.instance().mapLayersByName('ADDRESS')[0] #List ...


6

In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Let's assume we have two layers 'points' and 'river' with its corresponding attribute tables, see image below. With the following query, it is possible to create new lines that will represent the connection between points to the nearest line ...


6

You can use the Field Calculator to create a new elevation field, using a way similar to the point layer. The operation will give you a punctual information extract from the raster. In the line layer's Attribute Table use the Field Calculator to create a new field (numeric, real) with this expression raster_value('DEM_NAME', 1, start_point($geometry)) + ...


6

You can try using the geometry generator in your label placement settings so you have fewer things to change (see screenshots in this slightly related answer for an example). They typically deal with offsets in map units but you can get it to work with your zoom level by working with the @map_scale variable. Two methods: Method 1 - point + rotation Use the ...


6

Try using "Line intersections" geoalgorithm that creates points where lines intersect. Note that for 'Input layer' and 'Intersect layer' the same line layer was chosen. If lines are disconnected (see image below), some additional geometry adjustment is required, i.e. snapping. For snapping geometries in a layer to the geometries within the same ...


6

You can use st_translate to move the point SELECT ST_MakeLine(geom, st_translate(geom,0,-500)) FROM liechtenstein.punkte_test;


5

In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... Let's assume we have two layers 'points_layer' (red) and 'lines_layer' (grey) respectively, see image below. With the following query, it is possible to add only the names of my vertices (from line intersection, duplicates deleted) to the ...


5

Try Dissolving first to close the gaps between lines. Then execute Line Substring on the dissolved lines.


5

Below, I propose a Field Calculator approach to obtain the distance from the head of the nearest route. This approach has two requirement: Need to install refFunctions plugin which provides geomnearest function. Your road network has to have an unique id field (e.g. "id", "fid", "road_name",...) Start the Field Calculator on your bus_stops point layer and ...


5

For your above example you need to apply one additional step before proceeding with the queries that I provided, for that please check these threads In PostGIS: how to split linestrings into their individual segments? and Splitting lines into basic segments at vertices with PostGIS? Notice: The example below does not include breaking lines into sections at ...


5

In your field calculator, go into the function editor, create a new file, insert this function : """ Define new functions using @qgsfunction. feature and parent must always be the last args. Use args=-1 to pass a list of values as arguments """ from qgis.core import * from qgis.gui import * import sys if sys.version_info.major =...


5

Assuming your roads layer has no respective field yet: mark the layer and open the Field Calculator toggle Create a new field choose an Output field name select Output field type: Whole number (integer) paste this expression:aggregate( '<tree_layer_name>', 'count', '', distance( geometry( @parent ), $geometry ) <= <dist> )with <...


5

Have you tried simply dissolving your data into your single feature dataset, then perfoming a multi-part to single part? Such that each geometry would then be its own new record? At a much grander scale, I think the approach you should take is to solve the problem on the creation of the dataset - rather than fixing this already erroneous dataset. There are ...


5

From the line X find the nearest point on the circle - see here how to do that: https://gis.stackexchange.com/a/381288/88814 Than you can use snapping to this point when drawing line A parallel to X. This was the short answer. But let's get a little bit more to the details, as geometry generator and QGIS expressions are a very powerful tool to create new ...


5

Use this expression with geometry generator or the Geometry by expression tool - the expression is adapted to the data you provided (layer name: 'Bounding Box', distance to extend the line: 65): intersection ( extend ( $geometry,65,65 ), geometry ( get_feature_by_id( 'Bounding Box',0 ) ) )


5

It may not be the most elegant way. However, you use "Extend line" to extend lines by the distance of the longest edge of the polygon. The output looks like this and you can clip by Polygon with the "Intersection" tool. And the output looks like this


4

It's built into the app now and no plugins are required. It is accessible via the Advanced digitizing panel that is not shown by default. https://docs.qgis.org/3.10/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#reverse-line


4

Use the following setting in the 'Labels' menu Coordinate X: x(end_point($geometry)) # add some delta or interpolate the line Coordinate Y: y(end_point($geometry)) # add some delta or interpolate the line Horizonal Alignment: 'Left' Vertical Alignment: 'Half' Rotation: angle_at_vertex($geometry, num_points($geometry)-1) - 90


4

As commented, it seems to be a collection of line and not a polyline. I tried to explain in the image below. The first one has a collection of polylines. You can see that when it is a polyline, the buffer stay connected. And when is another line it has a endpoint/cap. The second sample is when the buffer is checked the dissolve. It looks like your case. The ...


4

Based on your quesion and code I think you're after something like this: import arcpy, os, itertools arcpy.env.workspace = r"C:/test/Test.gdb" # could be trouble if arcpy.env.overwriteOutput is False and the feature class already exists arcpy.CreateFeatureclass_management("C:/test/Test.gdb", "linea", "POLYLINE") # I ...


4

You can try "Snap geometries to layer" from Processing Toolbox. You can select the same layer as input and reference. In your case I would try the "Behavior" (Move end points only), as well as a suiting "Tolerance".


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