# Tag Info

21

Short answer: you can get it using a custom SVG. See bottom of this post for one. Long answer: I believe it is better to represent it than to modify the line geometry. Should you want to move an edge or do other actions on the geometry, it would be a nightmare to manage if the wiggles are part of the geometry instead of just a representation of a straight ...

19

So, by example. Here's a simple table with two connected groups of edges: drop table lines; create table lines ( id integer primary key, geom geometry(linestring) ); insert into lines (id, geom) values ( 1, 'LINESTRING(0 0, 0 1)'); insert into lines (id, geom) values ( 2, 'LINESTRING(0 1, 1 1)'); insert into lines (id, geom) values ( 3, 'LINESTRING(1 1, 1 2)...

19

You are going about it the right way, using ST_PointN and generate_series. One way of doing this, using dummy data (substitute your own in initial CTE) would be: WITH sample(geom, id) AS (VALUES (ST_MakePoint(0,0), 1), (ST_MakeLine( ARRAY[ST_MakePoint(0, 0), ST_MakePoint(10,10), ST_MakePoint(50, 50), ...

18

I propose a solution using PyQGIS. It should work both for Linestring and MultiLineString layers. This solution is based on the creation of semicircular rings, so you need to set a value for the diameter (i.e. the step variable in the code below). The step you choose won't be the real step used because it is adjusted on the basis of the line length (but it ...

16

I think I found an interim solution, which I'm posting in case it's useful for anyone: import pandas as pd import numpy as np from geopandas import GeoDataFrame from shapely.geometry import Point, LineString # Zip the coordinates into a point object and convert to a GeoDataFrame geometry = [Point(xy) for xy in zip(df.lon, df.lat)] df = GeoDataFrame(df, ...

15

Plugin mmqgis for QGIS. http://michaelminn.com/linux/mmqgis/ (http://plugins.qgis.org/plugins/tags/mmqgis/)- Delete Duplicate Geometries

14

select (ST_Azimuth(h.vec) - ST_Azimuth(h.seg)) from ( select ST_MakeLine(cp.p, point.geom) vec, ST_MakeLine(cp.p, ST_LineInterpolatePoint( line.geom, ST_LineLocatePoint(line.geom, cp.p) * 1.01) ) seg from ( select ST_ClosestPoint(line.geom, point....

12

You may not have to get too sophisticated--ArcGIS 10 has a tool to do just what you describe called Bearing Distance to Line (Data Management). You can even input a point shapefile as long as it has the attributes you need (i.e. X field, Y field, Distance Field, and Bearing). Of course you can add this tool to an arcpy script using: arcpy....

11

You could accomplish this a few different ways depending on what sort of output you are wanting, but the concept is the same. It's generally easier to do a simple rotation followed by a translation rather than trying to calculate the coordinates in a single step. In this case, the basic steps are: Create a line of the desired length at the origin (0,0). ...

11

Here's a query that should get you what you want: SELECT a.name, b.name, ST_LENGTH(ST_Intersection(a.geom, b.geom)) FROM polygons a, lines b WHERE ST_Intersects(a.geom, b.geom);

10

Here are a few new tricks, using: EXCEPT to remove geometries from either table that are the same, so we can focus only on geometries that are unique to each table (A_only and B_only). ST_Snap to get exact noding for overlay operators. Use the ST_SymDifference overlay operator to find the symmetric difference between the two geometry sets to show the ...

9

If the LineString is simply to be subdivided at a position closest to the given Point, you could do what you want with this (splits LineString at closest Point to given Point and remerges the two segements afterwards) SELECT ST_AsText( ST_LineMerge( ST_Union( ST_Line_Substring(line, 0, ST_Line_Locate_Point(line, point)), ...

9

According to Romain D on it1me.com, it can be done with the Leaflet.PolylineOffset as referenced in the comments by MattPil29 above. I have adapted it for the data in your example. I turned off your original line by changing opacity to 0 in myStyle. There is probably a more elegant way to not add it. The other key is flipping the x,y coordinate to make L....

9

There are several linear referencing functions that can be used to reference subsets of LineStrings, which can be converted to a geography and get the length of the geodesic with ST_Length. For example, get the distance along line that are near points pta and ptb: SELECT ST_Length(ST_LineSubstring( line, ST_LineLocatePoint(line, pta), ...

9

From the doc: ST_PointOnSurface — Returns a POINT guaranteed to lie on the surface.

9

Since you have successfully imported data, use the tool presented in the figure. QGIS 3.4

8

The thing you need to do is a temporal analysis. As you said you have two vector data(shp) of different times. you can find the change using geometry processing. In QGIS load two vectors and GoTo Vector->GeoProcessing and from there you can use Difference function which will give another shape as a result. Hope that helps

8

The ST_Polygonize aggregate in PostGIS will return a geometry_dump containing all possible polygons formed by a set of lines. I'm assuming the block IDs shown in your example are not related to the IDs of input linework. If this is the case, you can get your polygons and IDs with: SELECT (st_dump).path as poly_id, (st_dump).geom FROM (SELECT ...

8

You could, of course, do this with conversion via Well Known Text: spatialite> SELECT AsText(GeomFromText("LINESTRING(1 2, 3 4, 1 3)")); AsText(GeomFromText("LINESTRING(1 2, 3 4, 1 3)")) LINESTRING(1 2, 3 4, 1 3) However it is definitely possible to use MakeLine() with more than two points. Apart from the obvious version that you know about already, ...

8

In QGIS 3.10 it's possible to dynamically create zig-zag lines and wavelines with the help of the indispensable "geometry generator" and a custom Python expression function. from qgis.core import qgsfunction,QgsExpressionContextUtils,QgsExpression,QgsProject,QgsPoint,QgsGeometry @qgsfunction(args='auto', group='Custom', usesGeometry=False, referencedColumns=...

8

Some of many (somewhat hacky) solutions using the field calculator: select to add a field with type BOOLEAN use one of the expressions (returning true when line is curved) area( convex_hull( \$geometry ) ) > 0 AND area( convex_hull( \$geometry ) ) IS NOT NULL or, probably better performing length( \$geometry ) > distance( start_point( \$geometry ), ...

7

SELECT name,ref,type,ST_Distance(ST_Buffer(r.geom,20),ST_SetSRID(ST_MakePoint(lon, lat),4326)) FROM roads r ORDER BY 4 ASC LIMIT 1; For point in lon/lat coordinates: SELECT name,ST_Distance(r.geom,ST_SetSRID(ST_MakePoint(lon, lat),4326)) FROM roads r ORDER BY 2 ASC LIMIT 1;

7

To get point in order and link to orginal geometry use SELECT (ST_DumpPoints(the_geom)).path as path, id, (ST_DumpPoints(the_geom)).geom FROM linestrings) and remove dublicates from http://wiki.postgresql.org/wiki/Deleting_duplicates remember that you need to have one unique id for dublicate removing, if you dont have one you need to create it

7

Consider some test data similar top the thick line in the question's figure: SELECT 'LINESTRING (114 374, 200 380, 250 350, 259 343, 350 280, 380 180, 383 169, 360 80)'::geometry AS geom INTO TEMP data; the straight line (dashed) can be constructed from the start and end points: SELECT ST_AsText(ST_MakeLine(ST_StartPoint(geom), ST_EndPoint(geom))) FROM ...

7

aha! i found the solution: use: ST_Line_Locate_Point(geom_way,closest_point) to fetch the portion of the line and then can use the following to split it correctly: ST_Line_Substring (geom_way,0,ST_Line_Locate_Point(geom_way,closest_point)) as first_half ST_Line_Substring (geom_way,ST_Line_Locate_Point(geom_way,closest_point),1) as other_half

7

Here's an approach that uses a temporary table to incrementally aggregate clusters together. I don't really care for the temporary table approach, but this seems to perform quite well as the number of lines increases (I have 1.2 M lines in my input). DO \$\$ DECLARE this_id bigint; this_geom geometry; cluster_id_match integer; id_a bigint; id_b bigint; ...

7

The ST_Envelope() function operates on single geometries, therefore you are right, you need aggregate your MULTILINESTRINGs before you pass them by St_Envelope(). St_Collect() is a good aggregation function for that job. SELECT ST_Envelope(st_Collects(foo.geom)) FROM line_table as foo WHERE foo.type='a'; If you want to retrieve the bounding box for each ...

7

The length attribute of a LineString will return a value in the units of the coordinate system of the geometry. The coordinate system in your case is not specified, so there is not much meaning to the length. Your input of 360 is in degrees, so you assume an unprojected coordinate system, such as WGS84. This is why you get a length in degrees, even without ...

7

In my case I have each geometry in disctint tables. What I did was : For lines -> ST_LineInterpolatePoint() with 0.5 factor. For polygons -> Test if ST_Centroid() is inside its geometry. If so, ST_Centroid() is the best choice, if not I choose PointOnSurface(). Here's the query : SELECT CASE WHEN (SELECT the_geom FROM points WHERE gid = d.gid) IS NOT ...

7

You will need: 1) A table with LineString geometries: CREATE TABLE lin ( id serial PRIMARY KEY, geom geometry(LineString, 31370) ); CREATE INDEX ON lin (id); CREATE INDEX ON lin USING gist (geom); 2) A table with Point geometries where you want to split your overlapping lines. They can represent train/metro stations, intersections, bifurcations etc. (...

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