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


17

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


16

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) Pretty easy! I have wrapped it up in a plugin ...


12

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


9

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


8

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

This is a perfect task for the linear referencing capabilities in ArcGIS. See the help for Locating Features Along Routes and probe from there. The tools include the ability to turn a layer of points near a route (the river reaches) into "point event" descriptors, which name the route (the reach) and the distance from the beginning of the route. That's ...


7

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:


7

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


7

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


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

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

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


6

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


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

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

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


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

In QGIS 1) put the vector in editing mode, select all the features and in the editing toolbar use the "merge features" tool 2) the dynamic segmentation plugin should do the trick ( https://wiki.faunalia.it/dokuwiki/doku.php/qgis/lrs )


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


4

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.


4

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


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


4

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


4

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.


4

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


4

you can try the method that i used in ArcGIS: Create a line layer from a point layer and csv data file. one question regarding the lines: you are representing the world and all the lines converge or diverge from a given country, right? brasil, as in your case, has trading relations with a bunch of countries and it will be difficult to distinguish all the ...



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