[GRASS-user] Obtaining unique nodes from a topology

Hi all

I’ve used Grass to build a topology out of a polygon shapefile, so far so good.
I now need to export it as an arc-node topology (i.e. boundaries with startnode_id, endnode_id) which I will then use in PostGIS.

Does anyone know of a way to get the nodes from the topology and attach these attributes to the boundaries?
I know I can get the start/end coordinates, but I need the unique nodes and their ids.

Thanks

Will Temperley

Hi Will,

for lines you can use

v.to.db -p map=... option=start

-p to print your result
option=start to get start points
option=end to get end points

the result looks like
cat|x|y|z
...

without -p you can upload the results to the table with:
columns=x,y(,z)

Hope it helps,
Achim

William Temperley schrieb:

Hi all

I've used Grass to build a topology out of a polygon shapefile, so far so good.
I now need to export it as an arc-node topology (i.e. boundaries with startnode_id, endnode_id) which I will then use in PostGIS.

Does anyone know of a way to get the nodes from the topology and attach these attributes to the boundaries?
I know I can get the start/end coordinates, but I need the unique nodes and their ids.

Thanks

Will Temperley

------------------------------------------------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi Achim

Thanks - but what I really want is a list of unique nodes (i.e. where three boundaries meet, there would be one node, with an id) and assign this id to the relevant boundaries. Perhaps that isn’t possible. It might be easier to do this in PostGIS. I need to be able to run recursive queries in PostGIS to pick up connected boundaries.

Cheers

Will

2010/1/15 Achim Kisseler <ak7@jupiter.uni-freiburg.de>

Hi Will,

for lines you can use

v.to.db -p map=… option=start

-p to print your result
option=start to get start points
option=end to get end points

the result looks like
cat|x|y|z

without -p you can upload the results to the table with:
columns=x,y(,z)

Hope it helps,
Achim

William Temperley schrieb:

Hi all

I’ve used Grass to build a topology out of a polygon shapefile, so far so good.
I now need to export it as an arc-node topology (i.e. boundaries with startnode_id, endnode_id) which I will then use in PostGIS.

Does anyone know of a way to get the nodes from the topology and attach these attributes to the boundaries?
I know I can get the start/end coordinates, but I need the unique nodes and their ids.

Thanks

Will Temperley



grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi Will,

I think it is possible:
building a network from boundaries with
v.net

and then using the report option in v.net
it is not possible to update the table with these infos, but it is possible to save the results in a list, import this to your database and connect these infos to the table.

Achim

William Temperley schrieb:

Hi Achim

Thanks - but what I really want is a list of unique nodes (i.e. where three boundaries meet, there would be one node, with an id) and assign this id to the relevant boundaries. Perhaps that isn't possible. It might be easier to do this in PostGIS. I need to be able to run recursive queries in PostGIS to pick up connected boundaries.

Cheers

Will

2010/1/15 Achim Kisseler <ak7@jupiter.uni-freiburg.de <mailto:ak7@jupiter.uni-freiburg.de>>

    Hi Will,

    for lines you can use

    v.to.db -p map=... option=start

    -p to print your result
    option=start to get start points
    option=end to get end points

    the result looks like
    cat|x|y|z
    ...

    without -p you can upload the results to the table with:
    columns=x,y(,z)

    Hope it helps,
    Achim

    William Temperley schrieb:

        Hi all

        I've used Grass to build a topology out of a polygon shapefile,
        so far so good.
        I now need to export it as an arc-node topology (i.e. boundaries
         with startnode_id, endnode_id) which I will then use in PostGIS.

        Does anyone know of a way to get the nodes from the topology and
        attach these attributes to the boundaries?
        I know I can get the start/end coordinates, but I need the
        unique nodes and their ids.

        Thanks

        Will Temperley
         
        ------------------------------------------------------------------------

        _______________________________________________
        grass-user mailing list
        grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>
        http://lists.osgeo.org/mailman/listinfo/grass-user

Ah this is probably what I’m looking for, thanks Achim

Will

2010/1/15 Achim Kisseler <ak7@jupiter.uni-freiburg.de>

Hi Will,

I think it is possible:
building a network from boundaries with
v.net

and then using the report option in v.net
it is not possible to update the table with these infos, but it is possible to save the results in a list, import this to your database and connect these infos to the table.

Achim

William Temperley schrieb:

Hi Achim

Thanks - but what I really want is a list of unique nodes (i.e. where three boundaries meet, there would be one node, with an id) and assign this id to the relevant boundaries. Perhaps that isn’t possible. It might be easier to do this in PostGIS. I need to be able to run recursive queries in PostGIS to pick up connected boundaries.

Cheers

Will

2010/1/15 Achim Kisseler <ak7@jupiter.uni-freiburg.de mailto:[ak7@jupiter.uni-freiburg.de](mailto:ak7@jupiter.uni-freiburg.de)>

Hi Will,

for lines you can use

v.to.db -p map=… option=start

-p to print your result
option=start to get start points
option=end to get end points

the result looks like
cat|x|y|z

without -p you can upload the results to the table with:
columns=x,y(,z)

Hope it helps,
Achim

William Temperley schrieb:

Hi all

I’ve used Grass to build a topology out of a polygon shapefile,
so far so good.
I now need to export it as an arc-node topology (i.e. boundaries
with startnode_id, endnode_id) which I will then use in PostGIS.

Does anyone know of a way to get the nodes from the topology and
attach these attributes to the boundaries?
I know I can get the start/end coordinates, but I need the
unique nodes and their ids.

Thanks

Will Temperley



grass-user mailing list

grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)

http://lists.osgeo.org/mailman/listinfo/grass-user

Will wrote:

Thanks - but what I really want is a list of unique nodes
(i.e. where three boundaries meet, there would be one node,
with an id) and assign this id to the relevant boundaries.
Perhaps that isn't possible. It might be easier to do
this in PostGIS. I need to be able to run recursive
queries in PostGIS to pick up connected boundaries.

Hi,

have a look at 'v.build option=dump,sdump,cdump'.

there you can export the topology to stdout, etc.

it would be nice if you could write up your findings/method
into a small wiki page when you are done, there is a real lack
of PostGIS+GRASS documentation.

Hamish

2010/1/15 Hamish <hamish_b@yahoo.com>

Will wrote:

Thanks - but what I really want is a list of unique nodes
(i.e. where three boundaries meet, there would be one node,
with an id) and assign this id to the relevant boundaries.
Perhaps that isn’t possible. It might be easier to do
this in PostGIS. I need to be able to run recursive
queries in PostGIS to pick up connected boundaries.

Hi,

have a look at ‘v.build option=dump,sdump,cdump’.

there you can export the topology to stdout, etc.

it would be nice if you could write up your findings/method
into a small wiki page when you are done, there is a real lack
of PostGIS+GRASS documentation.

Hamish

Hi Hamish

Where should I write such a wiki page do you think? To be honest I’m not sure I’m using best practices - I needed a quick fix for a one-off job - I’ve been using shapefiles as an interchange medium.

I just rolled my own start/endpoint thing - it was pretty simple in Postgis to run
/* get table of unique start/endpoints */
insert into node (geom)
select st_startpoint(geom) from bound
union
select st_endpoint(geom) from bound

then
/* assign node ids to bounds */
update bound set startnode_id = (select id from node where node.geom = st_startnode(bound.geom))

Cheers

Will

Hamish:

> it would be nice if you could write up your findings/method
> into a small wiki page when you are done, there is a real
> lack of PostGIS+GRASS documentation.

Will wrote:

Where should I write such a wiki page do you think?

http://grass.osgeo.org/wiki/PostGIS

To be honest I'm not sure I'm using best practices - I
needed a quick fix for a one-off job - I've been using
shapefiles as an interchange medium.

None the less, even if it is not the most efficient or elegant solution
in the world I'm of the thought that something is better than nothing,
and it might spark the basis of a more formal solution. Add editorial
comments as needed...
btw, shapefiles can be a lossy format, but I'm not sure what a better
solution would be.

I just rolled my own start/endpoint thing - it was pretty
simple in Postgis to run
/* get table of unique start/endpoints */
insert into node (geom)
select st_startpoint(geom) from bound
union

select st_endpoint(geom) from bound

then
/* assign node ids to bounds */
update bound set startnode_id = (select id from node where
node.geom = st_startnode(bound.geom))

thanks,
Hamish