[postgis-users] get the biggest intersection
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Jun 20 07:27:16 PDT 2012
Try:
select count(*) from polygons where not isvalid(geometry);
if count > 0 then
select count(*) from polygons where not isvalid(geometry) and not
isvalid(st_buffer(geometry, 0.0));
you can do an update to fix these:
update polygons set geometry=st_buffer(geometry, 0.0) where not
isvalid(geometry);
-Steve W
On 6/20/2012 7:54 AM, Denis Rouzaud wrote:
> Hi all,
>
> I have a table of line and a table of polygons. For a given line, I
> would like to get the polygon which has the biggest intersection with
> the line.
> I tried something like this:
>
> CREATE OR REPLACE FUNCTION distribution.get_zone_id(geometry) RETURNS
> integer AS '
> DECLARE
> inputgeom ALIAS FOR $1;
> id_poly integer;
> BEGIN
> SELECT id INTO id_poly
> FROM polygons
> WHERE ST_Intersects(inputgeom,geometry) IS TRUE
> ORDER BY ST_Length(ST_Intersection(inputgeom,geometry)) DESC
> LIMIT 1;
> RETURN id_poly;
> END
> ' LANGUAGE 'plpgsql';
>
> But I have the following error:
> ERROR: Error performing intersection: TopologyException: side location
> conflict at 553524.92178241001 147945.03792368001
>
> If anyone has any idea, tip or whatever, it is very welcome!
>
> Greetings,
>
> Denis
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list