Tag Info

Hot answers tagged

30

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


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: ...


23

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


15

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

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( ...


10

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


10

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


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

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


9

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


9

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


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

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


8

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


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

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!


7

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


7

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.


6

It's not python but how is this? Select a point layer in the table of contents (TOC) then on that layer select the origin point feature. The script will draw a lines on another (Target) feature class from the selected point to all other points in the same feature class. Public Sub Distances Dim i As Long Dim pFeature As IFeature Dim ...


6

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


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


6

GPS Babel is the tool you want. It can convert between a huge number of formats!


6

The segments can be used to form an abstract graph G in which they play the role of nodes. Consider a node that is the segment (arc) from point P to point Q, PQ. Let R be the closest endpoint among all the other segment endpoints to P and let S be the other endpoint of R's segment. G then contains an edge from node PQ to node RS and we will label this ...


6

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


6

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


5

ET Geo Wizards has a function that will turn a set of points into lines. It produces a unique feature for each set of values based on a unique field value. Although it's not a free program, I believe this particular function is free to use without any limitations.


5

In Arc, they call these "Desire Lines" or "Spider Diagrams". There are a number of ArcGIS Toolbox tools that have already been created to to just this task: Take a look at the ArcGIS Resource center for Geoprocessing under Model and Script Tool Gallery: Spider Diagram Tool for ArcGIS 10.0 Spider Function For ArcGIS Desktop 10 Spider Or ArcScripts: ...


5

In December 2012, Esri has published a tool for generating flow maps. It is written in Python and available for ArcGIS Desktop users. And there is a ArcGIS Blogs post on generating flow maps with the links to the tool, some more information, and test data for the tool. I believe this is the kind of tool you would use to generate trade flows, too.



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