<div dir="ltr">Now, if you don't have a spatial index, the spatial index test (&&) does not run and all values are passed to the "internal" _st_intersects()</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 8:58 AM, Bborie Park <span dir="ltr"><<a href="mailto:dustymugs@gmail.com" target="_blank">dustymugs@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"><div>The first SELECT only uses the spatial index check (&&) and returns false.</div><div><br></div><div>The second SELECT uses ST_Intersects() (which makes use of the spatial index first) and also returns false.</div><div><br></div><div>The code for ST_Intersects(geom, raster) is...</div><div><br></div><div><div>CREATE OR REPLACE FUNCTION st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL)</div><div><span style="white-space:pre-wrap"> </span>RETURNS boolean AS</div><div><span style="white-space:pre-wrap"> </span>$$ SELECT $1 && $2::geometry AND _st_intersects($1, $2, $3); $$</div><div><span style="white-space:pre-wrap"> </span>LANGUAGE 'sql' IMMUTABLE</div><div><span style="white-space:pre-wrap"> </span>COST 1000;</div></div><div><br></div><div>Because the input geometry and raster fail the spatial index test (&&), the "internal" _st_intersects() function never receives any data where the SRID check is done.</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 8:52 AM, David Haynes II <span dir="ltr"><<a href="mailto:dahaynes@umn.edu" target="_blank">dahaynes@umn.edu</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">Sorry, I am not understanding what is happening can you explain?</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 10:18 AM, Bborie Park <span dir="ltr"><<a href="mailto:dustymugs@gmail.com" target="_blank">dustymugs@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"><div>Yes, the following explains it.</div><div><br></div>SELECT 'SRID=4269;POINT(-1 -1)'::geometry && ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 4326), 1, '16BUI', 1, 0)<br><div class="gmail_extra"><br></div><div class="gmail_extra">and</div><div class="gmail_extra"><br></div><div class="gmail_extra">SELECT ST_Intersects('SRID=4269;POINT(-1 -1)'::geometry, ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 4326), 1, '16BUI', 1, 0))<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 8:14 AM, Bborie Park <span dir="ltr"><<a href="mailto:dustymugs@gmail.com" target="_blank">dustymugs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Do you have a spatial index on<span style="font-size:13px"> IGBP_2012?</span><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">The only thing I can think of is that </span><span style="font-size:13px">dasymetric.us_dem_prj has a spatial index and since ST_Intersects() uses the spatial index first, there is no rows to consider in ST_Intersects and ST_Clip.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">-bborie</span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Jan 16, 2015 at 7:56 AM, David Haynes II <span dir="ltr"><<a href="mailto:dahaynes@umn.edu" target="_blank">dahaynes@umn.edu</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">Hello, <div><br></div><div>I have a question about an error I am not receiving when I believe I should.</div><div><br></div><div>Below are three datasets that with their SRID</div><div><div style="font-size:13px">igbp_2012 (6842), us_dem_prj (3410), and us_states (4326).</div><div style="font-size:13px"><br></div><div style="font-size:13px">When I run a query determining the SRID for these datasets in PostgreSQL they confirm their SRIDs</div><div style="font-size:13px">select st_srid(r.rast), st_srid(p.geom) from dasymetric.us_dem_prj r, dasymetric.us_states p limit 5<br></div><div style="font-size:13px"><br></div><div style="font-size:13px">When I run the next query, I do not receive an error, but no records are returned. The raster is in 3410 and the states geom column is in 4326</div><div style="font-size:13px"><div>SELECT state_label, ST_Clip(r.rast,p.geom) as rast FROM dasymetric.us_states p inner join dasymetric.us_dem_prj r on ST_Intersects(p.geom, r.rast) WHERE p.state_label = 'Minnesota'</div></div><div style="font-size:13px"><br></div><div style="font-size:13px">However, If I adjust the raster dataset to IGBP_2012, the error</div><div style="font-size:13px"><div>ERROR: Raster and geometry do not have the same SRID, shows up.</div><div><br></div><div>Why am I not receiving a conflict projection error for a raster in 3410 and a geometry in 4326? Any idea why that is occurring?</div></div><span><font color="#888888"><span><font color="#888888"><div><br></div>-- <br><div><div dir="ltr">David Haynes, Ph.D.<div>Research Associate Terra Populus</div><div>Minnesota Population Center</div><div><a href="http://www.terrapop.org" target="_blank">www.terrapop.org</a></div></div></div>
</font></span></font></span></div></div><span><font color="#888888">
<br></font></span></div></div><span><font color="#888888">_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br></font></span></blockquote></div><span><font color="#888888"><br></font></span></div>
</blockquote></div><br></div></div>
<br>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">David Haynes, Ph.D.<div>Research Associate Terra Populus</div><div>Minnesota Population Center</div><div><a href="http://www.terrapop.org" target="_blank">www.terrapop.org</a></div></div></div>
</div>
</div></div><br>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>