In the Python console:
you can use the Shapely module (as in How to create equidistant points in QGIS?) with the function
point = line.interpolate(currentdistance)
The new Python API of the master version (1.9) has an equivalent command (as in Generating chainage (distance) nodes in QGIS of Nathan Woodrow)
point = geom.interpolate(currentdistance)
You can use PyQGIS to measure the distances between all vertices of each polygon and find max:
layer = iface.activeLayer() #Click layer in tree
for feat in layer.getFeatures():
verts = [v for v in feat.geometry().vertices()] #List all vertices
maxdistance = max([p1.distance(p2) for p1,p2 in itertools.combinations(verts, 2)]) #Find ...
You can achieve your goal using the Field Calculator.
Using the Geometry Generator, with Linestring geometry type, use this expression
It will create an array of lines that connect any point with all the others point on the same layer.
You can create a new layer ...
I've written a script that changes the Sextante Densify geometries tool to accept a certain distance. It's called Densify geometries given an interval.
After running Densify, you can extract the points using Extract nodes tool.
You can get it from Github and install instructions are on my blog.
pyproj has the Geod.npts function that will return an array of points along the path. Note that it doesn't include the terminal points in the array, so you need to take them into account:
# calculate distance between points
g = pyproj.Geod(ellps='WGS84')
(az12, az21, dist) = g.inv(startlong, startlat, endlong, endlat)
# calculate line string ...
Bear in mind that someone correctly pointed out very soon in comments that I had misread the question. My answer gives the diameter of the minimal circle but this does not always correspond to the longest distance between vertices in a polygon. As soon as more than 2 vertices touch the circle or if the vertices defining the circle are adjacent, the values ...
I assume you are wanting to join two line segments into one line.
This is how I did it ...
Turn on snapping ( Settings -> Snapping Options ... )
Select the node node tool.
Double click close to the end of one of the lines to add a node.
Drag the node at the end to snap onto the the end of the other line
Select both lines
Merge their ...
You can make use of the virtual layers.
Go to Layer/ Add layer/ add-edit virtual layer and enter the following query. Feel free to add as many field as you want. The trick is to do a cross-join on the same table, generating every combination between the two layers.
select a.id, b.id, makeline(a.geometry, b.geometry) as geometry
from myLayer a, myLayer b
For anyone coming to this with newer versions of QGIS, the function to do it is now called "Collect Geometries" rather than "Single parts to Multipart" so it's now Vector > Geometry Tools > Collect Geometries.
You can then choose a field (or fields) to use as your grouping variable (Unique ID Fields).
I used it to fix up some statistical areas which included ...
This should be possible without any plugin using the default Processing tools, particularly Distance to nearest hub:
In QGIS, use "Geometry by Expression" tool (in a projected CRS). It will also add points information/attributes to polygons.
Select "Polygon" as "Output geometry type" option.
Add the following expression as "Geometry expression" value:
make_square(make_point($x, $y), make_point($x+100, $y+100))
Following Nathan's answer, you can create a python action in the layer where you want to swap lines:
layer = QgsMapLayerRegistry.instance().mapLayer("_your_layer_id_")
r = QgsFeatureRequest([% $id %])
f = QgsFeature()
geom = f.geometry().asPolyline()
geom = QgsGeometry.fromPolyline(geom)
One approach is to convert this to raster and then extract contours
Another is to find the buffer for each point;Dissolve those buffers to get a narrow polygon;Find the center line of each dissolved polygon.
If you are not forced to use QGIS, another Open Source GIS software OpenJUMP http://openjump.org/ has a Planer Graph tool that may be exactly what you need.
Here you can find the tool.
If you need only the edges you can uncheck all extra options.
The result contains the common edges only once. With real data the result may not be perfect because adjacent ...
If you snap the point to the line then you can split the line and then extract the parts from the resulting collection. Use a really small tolerance, I don't know how small it needs to be...
> site_snap = st_snap(site, reach, tol=1e-9)
> parts = st_collection_extract(st_split(reach$geometry, site_snap$geometry),"LINESTRING")
parts is now two features,...
Use the ogr2ogr utility with the ST_REVERSE function in a SQL statement and OGR SQLite dialect:
ogr2ogr -dialect SQLITE -sql "select st_reverse(GEOMETRY), * from input" output.shp input.shp
Note: You need to pass in the st_reverse(GEOMETRY) first as the GEOMETRY field is automatically selected if the * wildcard is used and ogr will write only ...
When holes of the polygons have to be avoided
So, this is an extension to my previous answer Calculating the longest distance within polygon in QGIS but with some changes in the Step 3, particularly in the query.
SELECT p1.id, setsrid(make_line(p1.geometry, p2.geometry), #put your srid here),
max(st_length(make_line(p1.geometry, p2.geometry))) AS ...
Using a Virtual layer, you can create a polygon of the desired dimension and move it to each location of the point layer. You can then save as the output if you want to persist the data.
Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the following query. Replace the layer name for yours.
WITH src AS (
First, add a field (name: geometry, type: string, length: 1000 keep it long). Then use the following script:
lyr = iface.activeLayer()
for f in lyr.getFeatures():
f["geometry"] = f.geometry().asWkt()
There is this QGIS plugin which says it does exactly what you want.
(However, I was not able to use it correctly in QGIS 2.6)
I would create a geometry collection from the points using st_collect():
Then I would create convex hull from the point collection:
If you have a table of point geometries called testpoints where geometry column name was the_geom, this should create the polygon that you are ...
Drag&Drop your CSV-file into QGIS, so you can see it in Layers tab
Use a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... with the following query
SELECT make_line(setsrid(make_point(start_easting, start_northing),27700),
) AS geom
Considering IE8 support requirement, we don't have many options on the table.
I can only recall one SVG lib that has VML fallback — Raphaël.js
So you can try this Raphaël layer plugin implementation for Leaflet.
I didn't try plugin myself, but successfully used Raphaël. Hope you can find a use of it.
Here is the ...
Based on Nathan's post I've created a processing script to reverse the direction of features:
# -*- coding: utf-8 -*-
# define Interface
##QGIS tools (QGIS 2.x)=group
##Reverse vector direction=name
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import *
I don't know of any built-in tools that track the length of lines as you are editing.
Assuming you are already Editing a layer, one work-around would be (in qGIS 2.0.x):
Open the Layer's Attribute Table.
Open the Field Calculator (Ctrl-I)
Create a new field, name it something like "Length", set the type to decimal width 18, precision 10, or ...