Ravi | 1 Dec 2009 07:07
Picon
Favicon

Re: PostGIS FDO

Great News. I always knew that it was bound to happen. 
Ravi Kumar

--- On Tue, 1/12/09, Andreas Neumann <a.neumann <at> carto.net> wrote:

> From: Andreas Neumann <a.neumann <at> carto.net>
> Subject: Re: [postgis-users] PostGIS FDO
> To: "PostGIS Users Discussion" <postgis-users <at> postgis.refractions.net>
> Date: Tuesday, 1 December, 2009, 2:29 AM
> This is great news. I have been
> waiting for an officially supported FDO Postgis provider for
> a long time!
> 
> We are using Postgis as our main data warehouse and
> Autodesk tools as expert GIS (editing survey data and waste
> water data). Other GIS tasks are done with QGIS. Having a
> good FDO Postgis provider will help us to better integrate
> all those technologies - and hopefully some day to fully
> migrate away from Oracle (the day that Autodesk Topobase
> supports Postgis).
> 
> Thanks for sharing,
> Andreas
> 
> Paul Ramsey wrote:
> > FYI, some encouraging news out of Autodesk,
> > 
> > http://lists.osgeo.org/pipermail/fdo-internals/2009-November/003238.html
> > 
> > looks like they are internally taking up the flag of
(Continue reading)

Nicklas Avén | 1 Dec 2009 08:41
Picon

merging linestrings between roadcrossings

Hallo
 
I have a quite big dataset (approx 1.2 mill rows) with roads. What I would like to to is merging all linestrings between crossings so I get one linestring between two crossings or between a crossing and the end of the road. Now there can be many small parts cut by a bridge or some border. For quality I also have to check so no linestrings are just passing a crossing too, but that is secondary because I don't think that is a problem with this dataset.
 
A while ago I saw a solution on this list which included merging all and dumping, but I think that will be a little heavy in this case.
 
I have been struggling some with recursive queries but I haven't found the way.
How to do it?
 
Thanks
/Nicklas
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Alexander Strunck | 1 Dec 2009 09:58
Picon

count points for every polygon

hello

i am new to postgis and sql. my problem is that i want to count the points that are in every polygon. the polygon
table contains gid, id, geom. the points table contains id, geom. 
i found in the internet this sql
> UPDATE polygon SET number_points = foo.count
> FROM (
>   SELECT polygon.name, count(point.gid) AS count
>   FROM point, polygon
>   WHERE ST_Contains(polygon.the_geom, point.the_geom)
>   GROUP BY polygon.name
> ) AS foo
> WHERE polygon.name = foo.name;

but it don´t seem to work for me.

Has anyone an idea how to make this work??

thx

alex
--

-- 
Endlich! Das Debüt-Album von Pop-Diva Sarah Kreuz ist da!                          
Jetzt bei GMX Musik Downloads. http://portal.gmx.net/de/go/musik01
Astrid Emde | 1 Dec 2009 10:23
Favicon
Gravatar

Re: count points for every polygon

Hello Alexander,

have a look at

http://postgis.org/documentation/manual-1.4/ch07.html

and try

* ST_NumPoints - to get the Number of Points of a Linestring
* ST_ExteriorRing - to get a linestring from your Polygon
* if you have MULTIPOLYGONS you may need ST_NumGeometries, ST_GeometryN

Best regards

Astrid

On Tue, December 1, 2009 8:58 am, Alexander Strunck wrote:
> hello
>
> i am new to postgis and sql. my problem is that i want to count the
> points that are in every polygon. the polygon table contains gid, id,
> geom. the points table contains id, geom. i found in the internet this sql
>
>> UPDATE polygon SET number_points = foo.count
>> FROM (
>> SELECT polygon.name, count(point.gid) AS count
>> FROM point, polygon
>> WHERE ST_Contains(polygon.the_geom, point.the_geom)
>> GROUP BY polygon.name
>> ) AS foo
>> WHERE polygon.name = foo.name;
>>
>
> but it don´t seem to work for me.
>
> Has anyone an idea how to make this work??
>
>
> thx
>
> alex --
> Endlich! Das Debüt-Album von Pop-Diva Sarah Kreuz ist da!
> Jetzt bei GMX Musik Downloads. http://portal.gmx.net/de/go/musik01
> _______________________________________________
> postgis-users mailing list postgis-users <at> postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
Stephen Woodbridge | 1 Dec 2009 15:00
Favicon
Gravatar

Re: merging linestrings between roadcrossings

Nicklas Avén wrote:
> 
> Hallo
>  
> I have a quite big dataset (approx 1.2 mill rows) with roads. What I 
> would like to to is merging all linestrings between crossings so I get 
> one linestring between two crossings or between a crossing and the end 
> of the road. Now there can be many small parts cut by a bridge or some 
> border. For quality I also have to check so no linestrings are just 
> passing a crossing too, but that is secondary because I don't think that 
> is a problem with this dataset.
>  
> A while ago I saw a solution on this list which included merging all and 
> dumping, but I think that will be a little heavy in this case.
>  
> I have been struggling some with recursive queries but I haven't found 
> the way.
> How to do it?

Nicklas,

If I understand what you want correctly, the problem is probably best 
solved, by something like the following:

1) assign unique nodes to all segment end points and add start_node_id 
and end_node_id to all your edges. look at pgRouting this have code to 
do this already implemented.

vertex_ids table
uid, lat, lon

2) add a num_segments column to you unique node table
3) update vertex_ids set num_segments=(select count(*) from edges e 
where e.start_node_id=uid or e.end_node_id=uid);

now num_segments will tell you what you need to know

num_segments
  0   - should not happen
  1   - these are dead end streets
  2   - these are joinable segments
  3+  - these are crossing segments

For the joinable segments create a new joined segment use the segments
   select * from edges
    where e.start_node_id=<uid_in_question>
       or e.end_node_id=<uid_in_question>;

insert that, and delete the two old segments and fixup your node counts.

-Steve
Daniel Grum | 1 Dec 2009 15:21
Picon
Favicon

Re: merging linestrings between roadcrossings

Stephen Woodbridge schrieb:
> Nicklas Avén wrote:
>>
>> Hallo
>>  
>> I have a quite big dataset (approx 1.2 mill rows) with roads. What I 
>> would like to to is merging all linestrings between crossings so I 
>> get one linestring between two crossings or between a crossing and 
>> the end of the road. Now there can be many small parts cut by a 
>> bridge or some border. For quality I also have to check so no 
>> linestrings are just passing a crossing too, but that is secondary 
>> because I don't think that is a problem with this dataset.
>>  
>> A while ago I saw a solution on this list which included merging all 
>> and dumping, but I think that will be a little heavy in this case.
>>  
>> I have been struggling some with recursive queries but I haven't 
>> found the way.
>> How to do it?
>
> Nicklas,
>
> If I understand what you want correctly, the problem is probably best 
> solved, by something like the following:
>
> 1) assign unique nodes to all segment end points and add start_node_id 
> and end_node_id to all your edges. look at pgRouting this have code to 
> do this already implemented.
>
> vertex_ids table
> uid, lat, lon
>
> 2) add a num_segments column to you unique node table
> 3) update vertex_ids set num_segments=(select count(*) from edges e 
> where e.start_node_id=uid or e.end_node_id=uid);
>
> now num_segments will tell you what you need to know
>
> num_segments
>  0   - should not happen
>  1   - these are dead end streets
>  2   - these are joinable segments
>  3+  - these are crossing segments
>
> For the joinable segments create a new joined segment use the segments
>   select * from edges
>    where e.start_node_id=<uid_in_question>
>       or e.end_node_id=<uid_in_question>;
>
> insert that, and delete the two old segments and fixup your node counts.
>
> -Steve
> _______________________________________________
> postgis-users mailing list
> postgis-users <at> postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
Hi

I think I have the same problem!

Are there any ideas how I can construct an SQL script that join 
streets-->merging linestrings that are not joined?

So a user often build street, that endnodes are not joined with the 
other street. So, if the endnode is an a buffer to a digitized 
street-->the sql will join this line?!

Is there a way to do this?!

--daniel
Stephen Woodbridge | 1 Dec 2009 16:06
Favicon
Gravatar

Re: merging linestrings between roadcrossings

If you use the code from pgRouting to create the unique vertex ids you 
can assign a tolerance to use when matching nodes. then I would write a 
stored procedure to apply the test and rules that are appropriate to 
your data model.

I don't have my postgis manual handy but there is a function the will 
allow you to merge two segments IIRC. If not it is pretty easy to 
extract the points of the two segments and create a new one combining 
the two sets.

-Steve

Daniel Grum wrote:
> Stephen Woodbridge schrieb:
>> Nicklas Avén wrote:
>>>
>>> Hallo
>>>  
>>> I have a quite big dataset (approx 1.2 mill rows) with roads. What I 
>>> would like to to is merging all linestrings between crossings so I 
>>> get one linestring between two crossings or between a crossing and 
>>> the end of the road. Now there can be many small parts cut by a 
>>> bridge or some border. For quality I also have to check so no 
>>> linestrings are just passing a crossing too, but that is secondary 
>>> because I don't think that is a problem with this dataset.
>>>  
>>> A while ago I saw a solution on this list which included merging all 
>>> and dumping, but I think that will be a little heavy in this case.
>>>  
>>> I have been struggling some with recursive queries but I haven't 
>>> found the way.
>>> How to do it?
>>
>> Nicklas,
>>
>> If I understand what you want correctly, the problem is probably best 
>> solved, by something like the following:
>>
>> 1) assign unique nodes to all segment end points and add start_node_id 
>> and end_node_id to all your edges. look at pgRouting this have code to 
>> do this already implemented.
>>
>> vertex_ids table
>> uid, lat, lon
>>
>> 2) add a num_segments column to you unique node table
>> 3) update vertex_ids set num_segments=(select count(*) from edges e 
>> where e.start_node_id=uid or e.end_node_id=uid);
>>
>> now num_segments will tell you what you need to know
>>
>> num_segments
>>  0   - should not happen
>>  1   - these are dead end streets
>>  2   - these are joinable segments
>>  3+  - these are crossing segments
>>
>> For the joinable segments create a new joined segment use the segments
>>   select * from edges
>>    where e.start_node_id=<uid_in_question>
>>       or e.end_node_id=<uid_in_question>;
>>
>> insert that, and delete the two old segments and fixup your node counts.
>>
>> -Steve
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users <at> postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
> Hi
> 
> I think I have the same problem!
> 
> Are there any ideas how I can construct an SQL script that join 
> streets-->merging linestrings that are not joined?
> 
> So a user often build street, that endnodes are not joined with the 
> other street. So, if the endnode is an a buffer to a digitized 
> street-->the sql will join this line?!
> 
> Is there a way to do this?!
> 
> --daniel
> _______________________________________________
> postgis-users mailing list
> postgis-users <at> postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
Nicklas Avén | 1 Dec 2009 16:21
Picon

Re: merging linestrings between roadcrossings

Hallo Stephen, thanks for answer
 
I think I have been moving in the direction of your solution but with a little bit other approach.
 
I don't want to modify my large table so I want to get some id (groupid) , identifying my new merged roads and then in the end merge them together to a new table.
 
What I have got is a sql-query that seems to be working on smaller tables, but I have to run it over and over again until no more rows are affected. But it does about what you mentionwed Stephen if I get things right:
 

update test set groupid = c.groupid from
 (
 select  max(groupid) as groupid , array_agg(groupid) as gidarray from
  (
  select groupid, (st_dump(st_collect(startpoint(the_geom), endpoint(the_geom)))).geom as thepoint from
   (
   select groupid, st_union(the_geom) as the_geom from test group by groupid
   ) a -- The lines unioned to not repeat the same thing again (this I guess is the weakest part
  ) b --All the start and end points
 group by thepoint having count(*) =2
 ) c -- the highest of the included gids
where test.groupid = any (gidarray) -- all roadparts in this array should get this highest gidvalue
 
/Nicklas

2009-12-01 Stephen Woodbridge wrote:

Nicklas Avén wrote:
>>
>> Hallo
>>
>> I have a quite big dataset (approx 1.2 mill rows) with roads. What I
>> would like to to is merging all linestrings between crossings so I get
>> one linestring between two crossings or between a crossing and the end
>> of the road. Now there can be many small parts cut by a bridge or some
>> border. For quality I also have to check so no linestrings are just
>> passing a crossing too, but that is secondary because I don't think that
>> is a problem with this dataset.
>>
>> A while ago I saw a solution on this list which included merging all and
>> dumping, but I think that will be a little heavy in this case.
>>
>> I have been struggling some with recursive queries but I haven't found
>> the way.
>> How to do it?
>
>Nicklas,
>
>If I understand what you want correctly, the problem is probably best
>solved, by something like the following:
>
>1) assign unique nodes to all segment end points and add start_node_id
>and end_node_id to all your edges. look at pgRouting this have code to
>do this already implemented.
>
>vertex_ids table
>uid, lat, lon
>
>2) add a num_segments column to you unique node table
>3) update vertex_ids set num_segments=(select count(*) from edges e
>where e.start_node_id=uid or e.end_node_id=uid);
>
>now num_segments will tell you what you need to know
>
>num_segments
> 0 - should not happen
> 1 - these are dead end streets
> 2 - these are joinable segments
> 3+ - these are crossing segments
>
>For the joinable segments create a new joined segment use the segments
> select * from edges
> where e.start_node_id=
> or e.end_node_id= ;
>
>insert that, and delete the two old segments and fixup your node counts.
>
>-Steve
>_______________________________________________
>postgis-users mailing list
>postgis-users <at> postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Mark Cave-Ayland | 1 Dec 2009 16:46
Picon

Re: Length of Bigint, Double and Text fields

Peter Hopfgartner wrote:

> Dear PostGIS devels,
> 
> since we right in the middle of comparing interoperability of shape 
> files between some FOSS programs and ArcGIS, we encoutered also the 
> following:
> 
> gvSIG chokes on the Bigint as produced by pgsql2shp. Looking at ArcGIs 
> generated files, the max length for numbers is 19, compared to 20 for 
> integers and 32 for floating points as in pgsql2shp. This seems to be 
> confirmed by some Borland tools, when configured for dBase III+.
> 
> Another limit seems to be that of text fields, that must be no longer 
> then 254. This is the maximum as given by ArcGIS and by the Borland tool.
> 
> Another point is Boolean: ArcGIS seems to not allow the creation of 
> boolean fields and the Borland Tool ("Database Desktop") says that 
> Booleans have a length of 1.
> 
> Regards,
> 
> Peter

Hi Peter,

You've brought up some interesting points here. Can you actually clarify 
these changes with regard to parts of the official shapefile spec, or 
have they been found purely through experimentation?

ATB,

Mark.

--

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs
Frank Warmerdam | 1 Dec 2009 17:11
Picon
Favicon
Gravatar

Re: Length of Bigint, Double and Text fields

Mark Cave-Ayland wrote:
> Hi Peter,
> 
> You've brought up some interesting points here. Can you actually clarify 
> these changes with regard to parts of the official shapefile spec, or 
> have they been found purely through experimentation?

Mark,

I would note that the shapefile specification is essentially silent on
the details of the .dbf file, apparently under the assumption that this is
a well known format from other sources and does not need to be specified.

Best regards,
--

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam <at> pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

Gmane