<div dir="ltr"><div><div>Nicolas,<br></div>Thanks - I think this should solve my problem. <br><br></div>Clifford<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 29, 2016 at 12:41 AM, Nicolas Ribot <span dir="ltr"><<a href="mailto:nicolas.ribot@gmail.com" target="_blank">nicolas.ribot@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>For this kind of query, you can compute the area of the intersection of the building with each parcel, and order buildings according to the biggest intersection with row_number():</div><div><br></div><div><font face="monospace, monospace">with tmp as (</font></div><div><font face="monospace, monospace"> select <a href="http://p.id" target="_blank">p.id</a>, <a href="http://b.id" target="_blank">b.id</a>,</font></div><div><font face="monospace, monospace"> row_number() over (partition by <a href="http://b.id" target="_blank">b.id</a> order by </font></div><div><font face="monospace, monospace"> st_area(st_intersection(b.<wbr>geom, p.geom)) desc) as rn</font></div><div><font face="monospace, monospace"> from parcel p join building b on st_intersects(b.geom, p.geom)</font></div><div><font face="monospace, monospace">) select t.*</font></div><div><font face="monospace, monospace">from tmp </font></div><div><font face="monospace, monospace">where rn = 1;</font></div><div><br></div><div>Nicolas</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 29 October 2016 at 00:38, Clifford Snow <span dir="ltr"><<a href="mailto:clifford@snowandsnow.us" target="_blank">clifford@snowandsnow.us</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div>I am working with some parcel data and building outlines. I'd like to associate an outline to a parcel if it is located mostly in the parcel. Buildings completely within the parcel can easily be found with st_contains. How do I find buildings if they are just over the parcel boundary. For example, in the first screenshot [1] the outline is just over the boundary. I'd like to be able to run a query that would find those that are just over. In a second example, this building [2] sits in the middle of two parcels. I can safely ignore it. <br><br>[1] <a href="https://www.dropbox.com/s/5xdx404ip4g7ycm/just_over.png?dl=0" target="_blank">https://www.dropbox.com/s/5xdx<wbr>404ip4g7ycm/just_over.png?dl=0</a><br>[2] <a href="https://www.dropbox.com/s/wah2bcg6tz6jw4n/middle.png?dl=0" target="_blank">https://www.dropbox.com/s/wah2<wbr>bcg6tz6jw4n/middle.png?dl=0</a><br><br></div>Thanks,<br></div>Clifford<span class="m_-2756388853148235379HOEnZb"><font color="#888888"><br clear="all"><div><div><div><br>-- <br><div class="m_-2756388853148235379m_-112694024232147719gmail_signature"><div dir="ltr"><div>@osm_seattle<br></div><div><a href="http://osm_seattle.snowandsnow.us" target="_blank">osm_seattle.snowandsnow.us</a></div><div>OpenStreetMap: Maps with a human touch</div></div></div>
</div></div></div></font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/postgis-users</a><br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/postgis-users</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>@osm_seattle<br></div><div><a href="http://osm_seattle.snowandsnow.us" target="_blank">osm_seattle.snowandsnow.us</a></div><div>OpenStreetMap: Maps with a human touch</div></div></div>
</div>