Tag Info

Hot answers tagged

22

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


22

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


22

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


14

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


11

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


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

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


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

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


8

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


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

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


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


6

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


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

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


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

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


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

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


5

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


5

The usual approach consists of two steps: Map matching The process of "snapping" the vehicle location to the street geometries. The trivial approach is to snap the vehicle location to the nearest point on the nearest road geometry. (There are more sophisticated approaches, which I'm sure you can google easily.) Routing After map matching, you can route ...


5

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

Depending on how far you got in the process, you may want to skip to step six. I have however provided full steps for creating a layer below. The basic process you would want to follow for creating a layer in QGIS is: From the Layer Menu, choose New Shapefile Layer... Specify the type. In your case, for a road you likely will want to specify the type as ...


5

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. Hope that is of help. meryloo


5

One option is to create a fishnet grid specific to your area of interest. By specifying one row and X columns, you can very efficiently create a series of lines. I describe this method in greater detail here and here for two similar situations. For fine control of individual line placement, use the editor. From the image, you can see I created 16 lines ...


5

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.


4

GeographicLib has a python interface http://geographiclib.sourceforge.net/html/other.html#python This can computer geodesics on an ellipsoid (set flattening to zero to get great circles) and can generate intermediate points on a geodesic (see the "Line" commands in the sample). Here's how to print out intermediate points on the geodesic line from JFK to ...


4

This sample creates two polygons on either side of a linestring. It requires PostGIS 1.5 or greater. I'm not sure how well it will cope with lines that cross themselves. SELECT ST_AsText(geom) FROM ST_Dump (( SELECT ST_Polygonize(GEOMUNION(ST_Boundary(ST_Buffer(the_geom, 0.5, 'endcap=flat join=round')), the_geom)) AS buffer_sides FROM (SELECT ...



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