[postgis-users] flow analysis
Jonatan Malaver
jon.malaver at shrewsburyma.gov
Thu May 16 06:31:11 PDT 2013
Yes, they were all multilinestrings. I got it to work with the following query
WITH RECURSIVE flow(gid, geom) AS (
SELECT gid, geom FROM l4_3 WHERE gid = 105
UNION ALL
SELECT n.gid, n.geom
FROM l4_3 n, flow f
WHERE ST_DWithin(ST_EndPoint(ST_GeometryN(ST_Multi(f.geom),1)),ST_StartPoint(ST_GeometryN(ST_Multi(n.geom),1)),0.01)
)
SELECT gid
FROM flow;
However, since they were all multilinestrings I alter the table to set all geometry type to LineStrings. The only problem that I found now is that some of the lines startpoint are backwards which brings a whole new problem.
Thanks,
Jonatan
From: postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Nicolas Ribot
Sent: Thursday, May 16, 2013 8:31 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] flow analysis
Are they all multilinestrings ?
What gives :
select distinct geometryType(geom) from l4_3
If it is only Linestrings, then you can update your table:
update l4_3 set geom = st_geometryN(geom);
(If you have constraint on the geoemtry's type, you should use an "alter table..." construct to change the geometry type)
Nicolas
On 16 May 2013 14:03, Hugues François <hugues.francois at irstea.fr<mailto:hugues.francois at irstea.fr>> wrote:
Hello,
You may try to work with a dump of your multi into single (st_dump(geom)).geom
Hugues.
________________________________
From: postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org> [mailto:postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org>] On Behalf Of Jonatan Malaver
Sent: Thursday, May 16, 2013 2:01 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] flow analysis
OK, so after some research I found out that ST_StartPoint() returns NULL for multilinestring. Anyone know a work around?
Thanks,
Jonatan
From: postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org> [mailto:postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org>] On Behalf Of Jonatan Malaver
Sent: Thursday, May 16, 2013 7:46 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] flow analysis
Here's my query
WITH RECURSIVE flow(gid, geom) AS (
SELECT gid, geom FROM l4_3 WHERE gid = 212
UNION ALL
SELECT n.gid, n.geom
FROM l4_3 n, flow f
WHERE ST_DWithin(ST_EndPoint(f.geom),ST_StartPoint(n.geom),0.01)
)
SELECT gid, ST_AsText(geom)
FROM flow;
Here's the result
212;"MULTILINESTRING((589700.21 2926252.04,589698.873744219 2926256.62316697))"
l4_3 is a multilinestring of and electrical circuit. I would like to see what's downstream the grid from a transformer, fuse, or upstream from a house meter.
Thanks,
Jonatan
From: postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org> [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Nicolas Ribot
Sent: Wednesday, May 15, 2013 12:55 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] flow analysis
Hello,
This precise example, no, but the "WITH RECURSIVE" construct yes.
Could you post your query and the data model ?
Nicolas
On 15 May 2013 17:56, Jonatan Malaver <jon.malaver at shrewsburyma.gov<mailto:jon.malaver at shrewsburyma.gov>> wrote:
Hello again,
I tried the example, but it only returns the same line. Has anyone tried that example?
Thanks,
Jonatan
From: postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org> [mailto:postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org>] On Behalf Of Nicolas Ribot
Sent: Tuesday, May 14, 2013 1:02 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] flow analysis
Hi,
The WITH RECURSIVE construct allows to walk a graph:
This link may help:
http://blog.cleverelephant.ca/2010/07/network-walking-in-postgis.html
Nicolas
On 14 May 2013 18:40, Jonatan Malaver <jon.malaver at shrewsburyma.gov<mailto:jon.malaver at shrewsburyma.gov>> wrote:
Hello, is it possible to do any flow analysis? For example, query postgis for what down flow a certain point?
Thanks,
Jonatan Malaver
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130516/d2176995/attachment.html>
More information about the postgis-users
mailing list