[postgis-users] How cutting out polygon

Daniel Grum daniel.grum at unibw.de
Tue Sep 1 10:20:49 PDT 2009


Daniel Grum schrieb:
> Pavel Iacovlev schrieb:
>> You should translate the error message by the way if you want to get 
>> answers :)
>>
>> I think the problem is that your select returns multiple
>> rows(geometries) but update expect 1 row. Try putting a
>> ST_COLLECT/ST_UNION in your query.
>>
>> UPDATE fog_of_war
>> SET the_geom = (    SELECT
>> ST_Union(ST_Intersection(grenze_by.the_geom,ST_Expand(holzfaeller.the_geom, 
>>
>> 5000)))
>>                               FROM public.grenze_by grenze_by,
>> public.holzfaeller holzfaeller                               WHERE
>> grenze_by.the_geom && ST_Expand(holzfaeller.the_geom, 5000));
>>
>> 2009/9/1 Daniel Grum <daniel.grum at unibw.de>:
>>  
>>> Hi.
>>>
>>> How I can cut 4 or more differnt polygon geometries out of one big
>>> geomtry[MULTIPOLYGON].
>>>
>>> I have one polygon (saved in the schema.tabel.column:
>>>  public.fog_of_war.the_geom)
>>> and from this I want to cut out  the squares, that I create with:
>>>
>>> SELECT 
>>> ST_Intersection(grenze_by.the_geom,ST_Expand(holzfaeller.the_geom,
>>> 5000))
>>> FROM public.grenze_by grenze_by, public.holzfaeller holzfaeller WHERE
>>> grenze_by.the_geom && ST_Expand(holzfaeller.the_geom, 5000));
>>>
>>> I don't want to save this cut out information in an extra table, I 
>>> only want
>>> to get a fog_of_war layer.
>>> And You only can see what is behind this Layer(than you see the map and
>>> bulidings) where the layer was cut out.
>>>
>>> Can I solve this problem with UPDATE like this:
>>>
>>> UPDATE fog_of_war
>>> SET the_geom = (    SELECT
>>> ST_Intersection(grenze_by.the_geom,ST_Expand(holzfaeller.the_geom, 
>>> 5000))
>>>                               FROM public.grenze_by grenze_by,
>>> public.holzfaeller holzfaeller                               WHERE
>>> grenze_by.the_geom && ST_Expand(holzfaeller.the_geom, 5000));
>>>
>>> I ask because I get the message: "FEHLER:  als Ausdruck verwendete
>>> Unteranfrage ergab mehr als eine Zeile"
>>>
>>> Thanks in advance.
>>>
>>> --Daniel
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>>     
>>
>>
>>
>>   
> I have edited my SQL
>
> The problem now is, that only the first row  will be regarded in this:
>
> UPDATE fog_of_war
> SET the_geom = ST_BuildArea(St_Collect(grenze_by.the_geom, 
> ST_Expand(holzfaeller.the_geom, 3000)))
> FROM public.grenze_by grenze_by, public.holzfaeller holzfaeller;
>
> How I can regard all rows of the table in a UPDATE query --> because 
> ST_Union or ST_Collect don't work in a UPDATE query
>
> --Daniel
>
And why only the last cut out was done, if I work with this repeatedly???:

UPDATE fog_of_war
SET the_geom = ST_BuildArea(St_Collect(grenze_by.the_geom, 
ST_Expand(holzfaeller.the_geom, 3000)))
FROM public.grenze_by grenze_by, public.holzfaeller holzfaeller;
UPDATE fog_of_war
SET the_geom = ST_BuildArea(St_Collect(grenze_by.the_geom, 
ST_Expand(steinbruch.the_geom, 3000)))
FROM public.grenze_by grenze_by, public.steinbruch steinbruch;
UPDATE fog_of_war
SET the_geom = ST_BuildArea(St_Collect(grenze_by.the_geom, 
ST_Expand(erzmine.the_geom, 3000)))
FROM public.grenze_by grenze_by, public.erzmine erzmine;

Is this a problem in using the function ST_BuildArea in UPDATE the 
table: fog_of_war ???

--Daniel



More information about the postgis-users mailing list