[postgis-users] help with the Union of 2 shp

Rémi Cura remi.cura at gmail.com
Thu Dec 12 06:29:41 PST 2013


Seems like If you want :
for each little square, get the id of big square overlaping.
If this is simply this, you don't need the "intersection" function,
but only the "intersects" function :

You could do something like this

SELECT ss.id, bs.id , ss.geom
FROM smal_square_table AS ss, big_square_table AS bs
WHERE ST_Intersects(ss.geom,bs.geom)=TRUE

Cheers,
Rémi-C




2013/12/12 <islanis at infomed.sld.cu>

> Hi,
>>
>> Try pg 21 of this: http://presentations.opengeo.
>> org/2011_FOSS4G/postgis-power.pdf
>>
>> That will give you the metacode.
>>
>> Overlays. (he sighs.)  Be glad you only have 2 layers... .
>>
>> Best,
>> Steve
>>
> Hey steve thanks for the book is really good as a resume, but the only
> apart that it have to do with my problem is the intersection of 2 shapes
> "SELECT
> a.*, b.*,
> ST_Intersection(a.geom, b.geom)
> FROM
> a, b
> WHERE
> ST_Intersects(a.geom, b.geom);"
>
> but my problem  is different, i got as a mention 2 shapes with the same
> projection and place,
> and are the same but one is from one study, and the other is from other
> stufy, but are the same
> place and each one have data, the only things that they got different are
> the size of the squares,the data they got and the
> name of the columns are the same, but the values are different cause the
> type of the study
> ,there is one that have the squares more smaller that the other, but i
> dont want lose any data, i need that in the map it has seen like
>  the figure "A and B" but in the data each row got the values of A and the
> values of B
>
>  1-the first shapefile
>  __________________
>  |                 |
>  |                 |
>  |         1       |     shp=A
>  |                 |
>  |                 |
>  |_________________|
>
>  The one big country, this is a multipolygon shape
>
>  DATA=>dni01 numeric,dni02 numeric,dni03 numeric,
>        dni04 numeric,dni05 numeric,dni06 numeric,
>        dni07 numeric,dni08 numeric,dni09 numeric,
>        dni10 numeric,dni11 numeric,dni12 numeric,
>        dniann numeric,the_geom geometry
>
>
>  2-and the second shapefile
>  __________________
>  |     2  |  2     |
>  |________|________|
>  |     2  |  2     |     shp=B
>  |________|________|
>  |     2  |  2     |
>  |________|________|
>  The same country, but this time in little pieces, the states, this is a
> multipolygon shape too
>
>  DATA=>dni01 numeric,dni02 numeric,dni03 numeric,
>        dni04 numeric,dni05 numeric,dni06 numeric,
>        dni07 numeric,dni08 numeric,dni09 numeric,
>        dni10 numeric,dni11 numeric,dni12 numeric,
>        dniann numeric,the_geom geometry
>
>
>  and i want join the 2 shapes in only one shapefile getting something like
> this
>
>  __________________
>  |    1,2 |   1,2  |
>  |________|________|
>  |    1,2 |   1,2  |     shp=A and B
>  |________|________|
>  |    1,2 |   1,2  |
>  |________|________|
>
> DATA=>dni01A numeric,dni02A numeric,dni03A numeric,dni04A numeric,
>       dni05A numeric,dni06A numeric,dni07A numeric,dni08A numeric,
>       dni09A numeric,dni10A numeric,dni11A numeric,dni12A numeric,
>       dniannA numeric,dni01B numeric,dni02B numeric,dni03B numeric,
>       dni04B numeric,dni05B numeric,dni06B numeric,dni07B numeric,
>       dni08B numeric,dni09B numeric,dni10B numeric,dni11B numeric,
>       dni12B numeric,dniannB numeric,the_geom geometry
>
>  i think that this is posible to do with postgis, but i dont know why, am
> looking in quantumGIS but i lose data cause the big suare overlap the little
>  ones and i lose data cause there is some places that i get NULL.
>
>  please help
>  thanks for all
>
>
>
>>
>>
>>
>>
>>  On Mon, Dec 9, 2013 at 11:03 AM, J.Alejandro Martinez Linares <
>>> islanis at infomed.sld.cu> wrote:
>>>
>>>    Hi People, i need your help, let say that i have 2 shapefiles
>>>
>>>    1-the first shapefile
>>>    __________________
>>>    |                 |
>>>    |                 |
>>>    |         1       |     shp=B
>>>    |                 |
>>>    |                 |
>>>    |_________________|
>>>
>>>    One big country, this is a multipolygon shape
>>>
>>>    2-and the second shapefile
>>>    __________________
>>>    |     2  |  2     |
>>>    |________|________|
>>>    |     2  |  2     |     shp=B
>>>    |________|________|
>>>    |     2  |  2     |
>>>    |________|________|
>>>    The same country, but this time in little pieces, the states, this is
>>> a multipolygon shape too
>>>
>>>    and i want join the 2 shapes in only one shapefile getting something
>>> like this
>>>
>>>    __________________
>>>    |    1,2 |   1,2  |
>>>    |________|________|
>>>    |    1,2 |   1,2  |     shp=A and B
>>>    |________|________|
>>>    |    1,2 |   1,2  |
>>>    |________|________|
>>>
>>>    i think that this is posible, please help me to get somthing like
>>> this i need it.
>>>
>>>
>>>
>>>    --
>>>
>>>    Este mensaje le ha llegado mediante el servicio de correo electronico
>>> que ofrece Infomed para respaldar el cumplimiento de las misiones del
>>> Sistema Nacional de Salud. La persona que envia este correo asume el
>>> compromiso de usar el servicio a tales fines y cumplir con las regulaciones
>>> establecidas
>>>
>>>    Infomed: http://www.sld.cu/
>>>
>>>    _______________________________________________
>>>    postgis-users mailing list
>>>    postgis-users at lists.osgeo.org
>>>    http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>>>
>>
>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> --
>
> Este mensaje le ha llegado mediante el servicio de correo electronico que
> ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema
> Nacional de Salud. La persona que envia este correo asume el compromiso de
> usar el servicio a tales fines y cumplir con las regulaciones establecidas
>
> Infomed: http://www.sld.cu/
>
> _______________________________________________
> postgis-users mailing list
> 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/20131212/37190256/attachment.html>


More information about the postgis-users mailing list