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 ...
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=...
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 ...
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 ...
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,))
Note that if you define a as LineString([(4, 3), (4, 6), (9, 6), (9, 1), (1, 1)]), you get 1.0.
Solution for ArcGIS using ArcPy
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
arcpy.env.workspace = r'C:\GIS\Somedatabase.gdb' #Change
lines = 'polyline' #Change
polygons = 'squares' #Change. WILL BE ...
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. ...
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).
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 ...
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')
addrlyr = QgsProject.instance().mapLayersByName('ADDRESS')
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 ...
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))
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.
Method 1 - point + rotation
Use the ...
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 ...
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 ...
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 ...
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 ...
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 *
if sys.version_info.major =...
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 <...
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 ...
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 ...
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):
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
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.
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
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.
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 ...
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".