[postgis-users] Creating an ID field in a view

ValiSystem vali.system at free.fr
Fri Mar 30 02:57:04 PDT 2007


On 30 mars 07, at 09:01, Jose Gomez-Dans wrote:

> Greg,
>
>
> On 3/29/07, Greg Robillard <greg at ecotrust.org> wrote:
>> Perhaps I'm missing something, but in traditional database-speak a  
>> view
>> is just a read-only version of a table, and a spatial view should  
>> be the
>> same. So if your base table has a unique, nonrepeating ID field,  
>> if you
>> include it in the syntax that creates your view it should be  
>> correctly
>> propagated.
>
> True, but since the Union splits features ("one-to-many" mapping), the
> same unique ID from the initial table is assigned to all the resulting
> split features. In my case, I have a set of land plots, and I want to
> do a Union with a grid. Some parcels (which lie in the boundary) will
> get split, and will appear as two different parcels, but still sharing
> the same ID code from the initial feature, which is correct, but not
> what I want, which is an unique identifier for each of the final
> parcels.
>
> Thanks!
> Jose

In this case, i would add a column with serial type to my union  
result table. It will be incremented automatically for each row. Note  
that you can add this column afterwards, and it will be initialized  
automatically at creation. 



More information about the postgis-users mailing list