[postgis-users] Merging lines - one on another
Hi all, I am using QGIS with PostGIS with the data that represents some cables on the terrain. There are some segments where the cables are drawn one near another (for example about 30 cm apart) and they even cross sometimes. My goal is to get the trenches, so to "merge" those parts of lines, that are separated for example for 50 cm at most into one so that later I can get the length of the trenches required (in the cases where lines are separated for less than 50 cm, of course one trench will be planned and it should be in the middle of both lines with the defined width). What would be the best procedure to follow to achieve this? I have tried ST_Equals and ST_HausdorffDistance, but I can't get on the right track ... Thanks, Matej ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Merging lines - one on another
Thanks to both of you. Now I have a query like: SELECT * FROM public.my_table AS part_1, public.my_table AS part_2 WHERE ST_SharedPaths(part_2.wkb_geometry_4326, ST_SnapToGrid(part_1.wkb_geometry_4326, part_2.wkb_geometry_4326, 0.5, 0, 0, 0)) - it seems that ST_Snap(geom, geom, float) doesn't exist at my PostGIS - is it correctly that I have changed it to ST_SnapToGrid, which also requires more float parameters? - it seems also that ST_SharedPath doesn't exist. Did you mean ST_SharedPaths? When I run this query, I get an error: ERROR: function st_sharedpaths(geometry, geometry) does not exist LINE 3: WHERE ST_SharedPaths(part_2.wkb_geometry_4326, ST_SnapToGrid... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. Do I need some other PostGIS version or am I doing it wrong? TIA, Matej 2012/1/21 Sandro Santilli : > On Sat, Jan 21, 2012 at 02:19:06PM +0100, Andrea Peri wrote: > >> ST_SharedPath(geom1, ST_Snap(geom1, geom2, 0.5)) > > I guess you meant: > > ST_SharedPath(geom2, ST_Snap(geom1, geom2, 0.5)) > > --strk; > > () Free GIS & Flash consultant/developer > /\ http://strk.keybit.net/services.html > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Merging lines - one on another
Should this work if I have all the data in one table and thus using the same geom1 and geom2? I have now installed PostGIS 2.0 and use only one geom as an input to the ST_Snap and have problems with the result being only one geometry data row. What should I change? I will really appreciate any answer since I'm completely lost here. Thanks! 2012/1/21 Sandro Santilli : > On Sat, Jan 21, 2012 at 02:19:06PM +0100, Andrea Peri wrote: > >> ST_SharedPath(geom1, ST_Snap(geom1, geom2, 0.5)) > > I guess you meant: > > ST_SharedPath(geom2, ST_Snap(geom1, geom2, 0.5)) > > --strk; > > () Free GIS & Flash consultant/developer > /\ http://strk.keybit.net/services.html > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to match lines between two similar graphs?
Hi, I am having somehow similar issue: I have a (single) table with the lines that represent cables on the ground. Those cables sometimes cross, sometimes they go in the same direction in some distance between them, sometimes one on another and my goal is to get the trenches (that are wide for example 1 meter) that would include the cables. So basically if the cables are for 1 meter apart from each other (no matter if they cross, lie on on another or go into the same direction) within this radius, the result should be one line representing them. If they are more far apart, another line would represent that line (another trench would have to be dig). Some guys posted ST_SharedPath(geom1, ST_Snap(geom1, geom2, radius)) as a possible solution, but I can't seem to get it to work properly in PostGIS 2.0. I get just one result set - could it be because both geometries are the same (same table). Being not so fluent in PostGIS this is really driving me nuts and would appreciate any help. I could also post some sample SHP data if anyone would be so nice to look at it. Thanks, Matej 2012/1/26 Stephen Woodbridge : > Hi All, > > I have an interesting problem I am trying to solve and would love some > feedback on how to best go about it. > > I have road data from two different vendor data sets. But this could also be > one road network and a GPS track, so I think this is a pretty common use > case. > > Assumptions: > > o the networks are similar, ie: they have similar roadway coverage > o the two sets might be slightly misaligned, ie: shifted by some amount > o the segments in the two data sets do not have to be broken into equivalent > segments, ie: one segment in A might be represented my multiple segments in > B > o segments are not aligned end point wise, ie: a segment in A might go from > mid-point one segment in B to the midpoint of a connected segment in B > o in many cases I will be working with a set of lines in one set that I need > to match to the other to select a matching set of lines. > > So strategies for matching these: > > 1. take a segment from A and buffer it, then intersect the data in B and > select the longest intersected object. I can probably throw out any pieces > smaller than the buffer distance. > > 2. Do the same but buffer and union the set of lines into a single > multipolygon, and intersect that with the other set. > > 3. ??? Other ideas? > > Thoughts on performance? > > Typically I will have a small set (1-20) of segments to compare against a > larger (100K-2M) set. Obvious a spatial index will will be used. But I'm > wondering what is the fast way to do this matching computationally. I think > I will want to be able to compare 1-200 sets like this every 5 mins as data > comes in from a feed, while supporting other queries. > > Thoughts would be appreciated. > > -Steve > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
[postgis-users] Length of a line above polygon
Hi all, We have a layer that contains polygons and another that contains lines that lie on them. Parts of the lines are laying "inside" the polygons and I would like to get a sum of all the lengths of lines that lie on the polygons. What is the easiest way to achieve this? TIA, Matej ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Length of a line above polygon
Hi, Thank you for the answer. However, I don't get the right result. For example, when there is a line that is long 500 meters and it crosses 5 polygons (on each of them maybe just a meter or few meters, except one where lies a majority of the line), I get the full length of the lines for corresponding polygons - i.e. as every polygon that is crossed is crossed by the total line length. What I want to get is the actual length of the part of the line that crosses every specific polygon. TIA, Matej 2012/7/3 Denis Rouzaud : > Hi, > > You can use something like > > SELECT areas.id, SUM( ST_Length( lines.geometry) ) FROM lines,areas WHERE > ST_Intersects(lines.geometry,areas.geometry) GROUP BY areas.id ; > > Greetings, > > Denis > > > On 07/03/2012 01:36 PM, Matej Mailing wrote: >> >> Hi all, >> >> We have a layer that contains polygons and another that contains lines >> that lie on them. Parts of the lines are laying "inside" the polygons >> and I would like to get a sum of all the lengths of lines that lie on >> the polygons. What is the easiest way to achieve this? >> >> TIA, >> Matej >> ___ >> postgis-users mailing list >> postgis-users@postgis.refractions.net >> http://postgis.refractions.net/mailman/listinfo/postgis-users > > > ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Length of a line above polygon
I think I have just found it out. I just add ST_Intersection to have a query like: SELECT areas.id, SUM( ST_Length( ST_Intersection(lines.geometry, areas.geometry) ) ) FROM lines,areas WHERE ST_Intersects(lines.geometry,areas.geometry) GROUP BY areas.id ; Now the numbers seem to be correct :-) Hopefully this could be of some use to anyone else when having such a problem. Thanks, Matej 2012/7/4 Matej Mailing : > Hi, > > Thank you for the answer. However, I don't get the right result. For > example, when there is a line that is long 500 meters and it crosses 5 > polygons (on each of them maybe just a meter or few meters, except one > where lies a majority of the line), I get the full length of the lines > for corresponding polygons - i.e. as every polygon that is crossed is > crossed by the total line length. What I want to get is the actual > length of the part of the line that crosses every specific polygon. > > TIA, > Matej > > > 2012/7/3 Denis Rouzaud : >> Hi, >> >> You can use something like >> >> SELECT areas.id, SUM( ST_Length( lines.geometry) ) FROM lines,areas WHERE >> ST_Intersects(lines.geometry,areas.geometry) GROUP BY areas.id ; >> >> Greetings, >> >> Denis >> >> >> On 07/03/2012 01:36 PM, Matej Mailing wrote: >>> >>> Hi all, >>> >>> We have a layer that contains polygons and another that contains lines >>> that lie on them. Parts of the lines are laying "inside" the polygons >>> and I would like to get a sum of all the lengths of lines that lie on >>> the polygons. What is the easiest way to achieve this? >>> >>> TIA, >>> Matej >>> ___ >>> postgis-users mailing list >>> postgis-users@postgis.refractions.net >>> http://postgis.refractions.net/mailman/listinfo/postgis-users >> >> >> ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users