<div dir="ltr"><div>Hi,</div><div><br></div><div>To test the geometry output type you can also call st_relate to examine the spatial relations between the two geometries using the DE-9IM model.</div><div><a href="http://postgis.net/docs/using_postgis_dbmanagement.html#DE-9IM">http://postgis.net/docs/using_postgis_dbmanagement.html#DE-9IM</a><br></div><div><br><div class="gmail_quote"><div dir="ltr">Le mar. 29 mai 2018 à 08:22, Marcin Mionskowski <<a href="mailto:mionskowskimarcin@gmail.com">mionskowskimarcin@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">1. To cast resulting geom to linestring try "st_intersection(adoquin.geom,pol.geom)::geometry(Linestring,32614)" in your SELECT clause.<br>
<br>
2. && operator will check if bounding boxes of your geoms intersects. Your check on ST_IsEmpty(..) is basicaly the same as ST_Intersects(...) check, and the second does not involve ST_Intersection(...). I think, that the query should perform better with && combined with ST_Intersects (in my testing it is ~25% faster).<br>
If your intersections can be a multilinestrings or points, then IMO you need WHERE condition "and geometrytype(st_intersection(adoquin.geom,pol.geom))='LINESTRING'". If you add this to your query, then try its performance with ST_IsEmpty() and ST_Intersects() checks. <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regards,<br>
Marcin<br>
<br>
<br>
On Fri, 25 May 2018 21:42:54 +0200, Nahum Castro <<a href="mailto:nahumcastro@gmail.com" target="_blank">nahumcastro@gmail.com</a>> wrote:<br>
<br>
> Hello all.<br>
><br>
> Can you help me on the next:<br>
><br>
> I can create a materialized view like this to extract data from other<br>
> tables within a polygon,<br>
><br>
> query:<br>
> create materialized view vm_adoquin as<br>
> select adoquin.gid,<a href="http://adoquin.id" rel="noreferrer" target="_blank">adoquin.id</a>,adoquin.control,st_intersection(adoquin.geom,<br>
> pol.geom) as geom<br>
> from  adoquin, municipio pol<br>
> where pol.municipio = 23<br>
> and adoquin.geom && pol.geom<br>
> and ST_IsEmpty(ST_Intersection(adoquin.geom, pol.geom)) != TRUE;<br>
><br>
> the resulting materialized view has geom type GEOMETRY but I need the geom<br>
> type as LINESTRING<br>
><br>
> How I can cast the view if I know that<br>
> geometrytype(st_intersection(autopista.geom, pol.geom))=LINESTRING<br>
><br>
> but can't use<br>
><br>
> st_intersection(autopista.geom,<br>
> pol.geom)::geometry(geometrytype(st_intersection(autopista.geom,<br>
> pol.geom)), 32614) to cast because can't use functions in type conversions.<br>
><br>
><br>
><br>
> Thanks in advance.<br>
> Nahum<br>
_______________________________________________<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="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div></div></div>