Hot answers tagged

38

Ok here is the Python that I used to do it: layer = qgis.utils.iface.mapCanvas().currentLayer() for feature in layer.selectedFeatures(): geom = feature.geometry() nodes = geom.asPolyline() nodes.reverse() newgeom = QgsGeometry.fromPolyline(nodes) layer.changeGeometry(feature.id(),newgeom) Before running the above code: Select the layer ...


25

It seems the most common problem with these types of "flow maps" is that when many lines are included, they collide to such a great extent that it makes it difficult to discern any non-obvious pattern (when reciprocal flows are considered it happens to an even greater extent). Also the long lines tend to dominate the graphic, although it is quite possible ...


23

It seems like the crucial thing you want here is for the points in the line to be sorted by the time of capture, spread across three column rows. While you could organise the data in a spreadsheet, I often find writing a quick script provides the most flexibility: import csv from datetime import datetime try: from osgeo import ogr except ImportError: ...


17

First, a little background to indicate why this is not a hard problem. The flow through a river guarantees that its segments, if correctly digitized, can always be oriented to form a directed acyclic graph (DAG). In turn, a graph can be linearly ordered if and only if it is a DAG, using a technique known as a topological sort. Topological sorting is fast: ...


12

Proper one-sided buffers were supposed to have landed in 1.5, but it looks to me that while the styles did land, sidedness didn't make it in. There is however a current patchset which exposes GEOSSingleSidedBuffer and performs the one-sided buffer as expected, under the name ST_OffsetCurve; see further background in ticket #413. In use: select ...


12

This code will work on the lastest dev build of QGIS. from qgis.utils import iface from qgis.core import * from PyQt4.QtCore import QVariant import random def createRandomPoints(count): # Create a new memory layer to store the points. vl = QgsVectorLayer("Point", "distance nodes", "memory") pr = vl.dataProvider() pr.addAttributes( ...


12

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) or ...


11

The endpoint is displaced from the origin by 800 meters, of course. The displacement in the direction of the x-coordinate is proportional to the sine of the angle (east of north) and the displacement in the direction of the y-coordinate is proportional to the cosine of the angle. Thus, from sin(15 degrees) = sin(0.261799) = 0.258819 and cos(15 degrees) = ...


11

Building on whuber's answer, if you wanted to implement this in Python, you'd calculate the displacement as stated, then create an output as a collection of points like so: import arcpy from math import radians, sin, cos origin_x, origin_y = (400460.99, 135836.7) distance = 800 angle = 15 # in degrees # calculate offsets with light trig (disp_x, disp_y) = ...


10

Just use an ArcToolbox command, such as "Feature Class to Feature Class" Click the "Environments..." button In the "M Values" and/or "Z Values" just specify the Output as "Disabled" Simple as this!


10

You need to break the polyline at the +-180 degree meridian. This requires finding the latitude at which the polyline crosses that meridian. Your GIS probably has methods to do the breaking. If not, a simple solution can be derived from code shown in a related thread. Here are some details. A polyline is represented as a sequence of vertices, each ...


10

You can accomplish this with a combination of QGIS and GRASS. Import your vector layer into a GRASS mapset ( Grass | File > Import Vector Data ) Open your mapset in QGIS ( QGIS | Plugins > GRASS > Open mapset ) Add vector layer from your GRASS mapset to your QGIS project ( QGIS | Plugins > GRASS > Add GRASS vector layer ) Use v.clean.snap ( QGIS | Plugins ...


9

A radial sweep algorithm will do fine, Duncan. Be aware that the centroid can lie outside the polygon, whence there won't exist any solution in such cases. Notice, too, that this construction is a strange one: whereas the centroid is a global property of the polygon, the line you are constructing is a local property of the polygon in the vicinity of this ...


9

Assuming that your database schema looks like this: table customer: table shops: customer_id | shop_id | the_geom shop_id | the_geom -------------------------------- ------------------ 1000 | 100 | ... 100 | ... 1001 | 100 | ... 101 | ... 1002 | 101 | ... The ...


9

Use QGIS - http://www.qgis.org/ First import the GPX file, then from print composer export SVG.


9

I assume you are wanting to join two line segments into one line. This is how I did it ... Enable editing. 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 ...


8

The question is more or less answered, I just would like to add a few comments to point out the flexibility and power of doing things like this with spatial sql As I read the question it can be divided in two questions. One GIS question and one sql question about how to combine rows in different tables. The gis-part can as mentioned before best be solved ...


8

QGIS Plugin "Points2One" should be what you're looking for. If you don't tick "Sort points by this field", the plugin connects them in the internal point order in the layer. I used your sample, arranged the points in a zigzag order and it worked as expected:


8

If you have the GRASS plugin use the v.flip option - http://grass.osgeo.org/wiki/GRASS_AddOns#v.flip


8

While jeb's answer led me to this answer, his lacked a little bit of detail that I would have liked in an answer. This is the easiest way I found to convert PolyLine-M to Polyline. Open your ArcToolBox Open "Conversion Tools" Expand "To Shapefile" Run "Feature Class to Shapefile (multiple)" Select your input shapefile Choose your destination folder in ...


8

You don't say which software you're using, but the thing you're looking for is Voronoi polygons (AKA Theissen polygons). This is the set of polygons such that any point within a polygon is nearest to its seed point. You will find that the polygons tessellate, which might be a problem if your offices have a maximum distance of responsibility. If that is the ...


8

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.


7

The answers provided by others are a little more elegant, but here's an ultrasimple, somewhat unpythonic, bit of Python that provides the basics. The function takes two coordinate pairs and a user-specified number of segments. It yields a set of intermediate points along a great circle path. Output: text ready to write as KML. Caveats: The code does not ...


7

This question (Representation of network flows) on network flows might be of interest.


7

Quick answer: no! There's no tool like that to do that operation directly on the layer (the "Join Two Lines" plugin requires intersection). You could do it for a very simple layer by turning the lines to points (extract nodes) then joining with points2one (line output) but this would be MUCH slower than just editing by hand: Make sure you have snapping ...


7

We came up with this technique at work that uses geoprocessing tools to do the job: First off, make sure your line segs have unique IDs. Buffer "FLAT" in each direction of the line, add a new field of the same name to each and give them a direction ("L","R"). Merge the buffers together. Buffer the original line again, this time "FULL". Convert the FULL ...


7

Try ET Geowizards Generate (Import from Text) and use a Box type. If new to this free (some tools only) ArcGIS addon, go to http://www.ian-ko.com. For this you need to do a some simple formatting of your excel to be id,xmin,ymin,xmax,ymax - formatting is explained in the tool help.


7

There is now a plugin called QChainage that does exactly what you want. You specify an interval distance and the plugin creates points along your line at the specified interval.


7

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.


6

You have drawn a good approximation to the Medial Axis Transform. The Delaunay triangulation indeed offers a good approach to it. (The principal challenge is that parts of the MAT are pieces of parabolas, not just line segments.) I have run across references to working code (usually in C/C++ I recall) in the academic literature. Do a search on Google ...



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