Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

Do I have to worry about players making “bad” choices on level up?

Is thermodynamics only applicable to systems in equilibrium?

gnu parallel how to use with ffmpeg

Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?

Reverse the word in a string with the same order in javascript

Is creating your own "experiment" considered cheating during a physics exam?

How to stop co-workers from teasing me because I know Russian?

What is a Recurrent Neural Network?

Any examples of headwear for races with animal ears?

Confusion about capacitors

TikZ how to make supply and demand arrows for nodes?

Does a creature that is immune to a condition still make a saving throw?

How to verbalise code in Mathematica?

Upright [...] in italics quotation

Cannot populate data in lightning data table

Stark VS Thanos

Binary Numbers Magic Trick

In gnome-terminal only 2 out of 3 zoom keys work

You look catfish vs You look like a catfish

Why is the origin of “threshold” uncertain?

What is the difference between `a[bc]d` (brackets) and `ab,cd` (braces)?

Feels like I am getting dragged in office politics

When India mathematicians did know Euclid's Elements?

Is GOCE a satellite or aircraft?



Identifying “long and narrow” polygons in with PostGIS


length and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








7















I have a set of polygons representing large areas, say city neighborhoods. I want to identify the large overlapping areas between them.



But there's a problem: sometimes these polygons will overlap along their perimeters (because they were drawn with little precision). This will generate long and narrow overlaps that I do not care about.



But other times there will be big overlaps of robust polygons, meaning large areas where a neighborhood's polygon overlaps another. I want to select only these.



See the picture below of just the overlaps. Imagine I wanted to select only the blue polygon in the lower left corner.



overlap



I could look at areas, but sometimes the narrow ones are so long they end up having areas as large as the blue polygon. I've tried to do a ratio of area / perimeter, but that has also yielded mixed results.



I've even tried using ST_MinimumClearance, but sometimes the large areas will have a narrow part attached to it, or two very close vertices.



Any ideas of other approaches?




In the end what worked best for me was using a negative buffer, as suggested by @Cyril and @FGreg below.



I used something like:



ST_Area(ST_Buffer(geom, -10)) as neg_buffer_area


In my case, units were meters, so 10 m negative buffer.



For narrow polygons, this area returned zero (also, the geometry would be empty). Then I used this column to filter out the narrow polygons.










share|improve this question



















  • 4





    Certainly the area/perimeter ratio could be used for this.

    – Vince
    Mar 20 at 15:17











  • It's hard to tell where the distinct polygons are from the image, but doing something like this gis.stackexchange.com/a/265233/64838 might work? Calculate minimum rotated bounding box then discard ones with small width or height.

    – FGreg
    Mar 20 at 22:31











  • You could also try using a negative buffer as described here: How can I identify really thin polygons in my shape file?

    – FGreg
    Mar 20 at 22:46

















7















I have a set of polygons representing large areas, say city neighborhoods. I want to identify the large overlapping areas between them.



But there's a problem: sometimes these polygons will overlap along their perimeters (because they were drawn with little precision). This will generate long and narrow overlaps that I do not care about.



But other times there will be big overlaps of robust polygons, meaning large areas where a neighborhood's polygon overlaps another. I want to select only these.



See the picture below of just the overlaps. Imagine I wanted to select only the blue polygon in the lower left corner.



overlap



I could look at areas, but sometimes the narrow ones are so long they end up having areas as large as the blue polygon. I've tried to do a ratio of area / perimeter, but that has also yielded mixed results.



I've even tried using ST_MinimumClearance, but sometimes the large areas will have a narrow part attached to it, or two very close vertices.



Any ideas of other approaches?




In the end what worked best for me was using a negative buffer, as suggested by @Cyril and @FGreg below.



I used something like:



ST_Area(ST_Buffer(geom, -10)) as neg_buffer_area


In my case, units were meters, so 10 m negative buffer.



For narrow polygons, this area returned zero (also, the geometry would be empty). Then I used this column to filter out the narrow polygons.










share|improve this question



















  • 4





    Certainly the area/perimeter ratio could be used for this.

    – Vince
    Mar 20 at 15:17











  • It's hard to tell where the distinct polygons are from the image, but doing something like this gis.stackexchange.com/a/265233/64838 might work? Calculate minimum rotated bounding box then discard ones with small width or height.

    – FGreg
    Mar 20 at 22:31











  • You could also try using a negative buffer as described here: How can I identify really thin polygons in my shape file?

    – FGreg
    Mar 20 at 22:46













7












7








7


0






I have a set of polygons representing large areas, say city neighborhoods. I want to identify the large overlapping areas between them.



But there's a problem: sometimes these polygons will overlap along their perimeters (because they were drawn with little precision). This will generate long and narrow overlaps that I do not care about.



But other times there will be big overlaps of robust polygons, meaning large areas where a neighborhood's polygon overlaps another. I want to select only these.



See the picture below of just the overlaps. Imagine I wanted to select only the blue polygon in the lower left corner.



overlap



I could look at areas, but sometimes the narrow ones are so long they end up having areas as large as the blue polygon. I've tried to do a ratio of area / perimeter, but that has also yielded mixed results.



I've even tried using ST_MinimumClearance, but sometimes the large areas will have a narrow part attached to it, or two very close vertices.



Any ideas of other approaches?




In the end what worked best for me was using a negative buffer, as suggested by @Cyril and @FGreg below.



I used something like:



ST_Area(ST_Buffer(geom, -10)) as neg_buffer_area


In my case, units were meters, so 10 m negative buffer.



For narrow polygons, this area returned zero (also, the geometry would be empty). Then I used this column to filter out the narrow polygons.










share|improve this question
















I have a set of polygons representing large areas, say city neighborhoods. I want to identify the large overlapping areas between them.



But there's a problem: sometimes these polygons will overlap along their perimeters (because they were drawn with little precision). This will generate long and narrow overlaps that I do not care about.



But other times there will be big overlaps of robust polygons, meaning large areas where a neighborhood's polygon overlaps another. I want to select only these.



See the picture below of just the overlaps. Imagine I wanted to select only the blue polygon in the lower left corner.



overlap



I could look at areas, but sometimes the narrow ones are so long they end up having areas as large as the blue polygon. I've tried to do a ratio of area / perimeter, but that has also yielded mixed results.



I've even tried using ST_MinimumClearance, but sometimes the large areas will have a narrow part attached to it, or two very close vertices.



Any ideas of other approaches?




In the end what worked best for me was using a negative buffer, as suggested by @Cyril and @FGreg below.



I used something like:



ST_Area(ST_Buffer(geom, -10)) as neg_buffer_area


In my case, units were meters, so 10 m negative buffer.



For narrow polygons, this area returned zero (also, the geometry would be empty). Then I used this column to filter out the narrow polygons.







qgis postgis slivers






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 22:14









PolyGeo

54.1k1782248




54.1k1782248










asked Mar 20 at 14:42









bplmpbplmp

1036




1036







  • 4





    Certainly the area/perimeter ratio could be used for this.

    – Vince
    Mar 20 at 15:17











  • It's hard to tell where the distinct polygons are from the image, but doing something like this gis.stackexchange.com/a/265233/64838 might work? Calculate minimum rotated bounding box then discard ones with small width or height.

    – FGreg
    Mar 20 at 22:31











  • You could also try using a negative buffer as described here: How can I identify really thin polygons in my shape file?

    – FGreg
    Mar 20 at 22:46












  • 4





    Certainly the area/perimeter ratio could be used for this.

    – Vince
    Mar 20 at 15:17











  • It's hard to tell where the distinct polygons are from the image, but doing something like this gis.stackexchange.com/a/265233/64838 might work? Calculate minimum rotated bounding box then discard ones with small width or height.

    – FGreg
    Mar 20 at 22:31











  • You could also try using a negative buffer as described here: How can I identify really thin polygons in my shape file?

    – FGreg
    Mar 20 at 22:46







4




4





Certainly the area/perimeter ratio could be used for this.

– Vince
Mar 20 at 15:17





Certainly the area/perimeter ratio could be used for this.

– Vince
Mar 20 at 15:17













It's hard to tell where the distinct polygons are from the image, but doing something like this gis.stackexchange.com/a/265233/64838 might work? Calculate minimum rotated bounding box then discard ones with small width or height.

– FGreg
Mar 20 at 22:31





It's hard to tell where the distinct polygons are from the image, but doing something like this gis.stackexchange.com/a/265233/64838 might work? Calculate minimum rotated bounding box then discard ones with small width or height.

– FGreg
Mar 20 at 22:31













You could also try using a negative buffer as described here: How can I identify really thin polygons in my shape file?

– FGreg
Mar 20 at 22:46





You could also try using a negative buffer as described here: How can I identify really thin polygons in my shape file?

– FGreg
Mar 20 at 22:46










5 Answers
5






active

oldest

votes


















4














I would try to create a negative buffer, if it eats thin polygons, then it’s good, if it doesn’t eat the polygon, then it’s mine ... :-)



run this script, having previously set 2/3 of the width of the linear polygons ...



create table name_table as
SELECT ST_Buffer(
(ST_Dump(
(ST_Union(
ST_Buffer(
(geom),-0.0001))))).geom,
0.0001)) as geom from source_table


OS :-)...






share|improve this answer

























  • in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

    – bplmp
    Mar 21 at 14:11











  • Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

    – Cyril
    Mar 21 at 14:12


















9














Instead of area/perimeter, it is better to use the area divided by the square of the perimeter (or its inverse).



This is also called "shape index". The square of the perimeter divided by the area has a minimum value of 4*Pi() (in the case of a disk, which is the most compact 2D geometry), so it can be normalized by 4*Pi() for an easy interpretation (normalized values close to 1 then mean that you have very compact objects and squares have a values of approximately 1.27).



EDIT: A threshold on the area would be usefull to remove the very small artefacts, which could be compact. Then the shape index would show better contrast.
EDIT: in addition to this answer, the use of ST_Snap could help you solve the problem before it occurs.






share|improve this answer

























  • Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

    – bplmp
    Mar 20 at 15:55











  • Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

    – bplmp
    Mar 20 at 16:09






  • 2





    Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

    – John Powell
    Mar 20 at 16:50











  • @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

    – radouxju
    Mar 21 at 7:15











  • @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

    – radouxju
    Mar 21 at 7:20


















5














One option would be to use the ratio of the area of the polygon to the longest line that can be drawn using its extremities. Identifying long narrow polygons.



select * from polygons where ST_Length(ST_LongestLine(geom, geom)) < ST_Area(geom) * 4



This works pretty well for sliver polygons. You can adjust what the ratio (what you multiply the area with) to suit your needs and projection.






share|improve this answer






























    1














    It sounds like this might match your use case: Eliminate selected polygons




    Combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated.



    Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.




    It sounds like you'd want to try the "Largest Common Boundary" option.






    share|improve this answer























    • I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

      – FGreg
      Mar 20 at 22:49


















    0














    This looks to me like a perfect use case for PostGIS topology extension. The topology's tolerance parameter will determine how far you allow vertices to snap to other existing polygons, to cope with the low precision of the source data and to clean it.



    In short, the strategy is:



    1. Enable the topology extension



    CREATE EXTENSION postgis_topology;


    2. Create a new empty topology



    SELECT topology.CreateTopology('neighborhoods_topo', 4326, 1e-7);


    The third parameter is the tolerance, in the units of the CRS; choose it wisely. Ideally, you want a CRS where unit is meters. If the CRS unit is not meters, as with WGS 84 aka 4326, use ST_Transform to reproject your polygons.



    3. Add a TopoGeometry column to the polygons table



    SELECT topology.AddTopoGeometryColumn('neighborhoods_topo', 'public', 'neighborhoods', 'topogeom', 'POLYGON');


    This returns a new layer_id. Save it, it will be needed later. It will be layer 1 if your start from scratch, and incremented at every new call.



    4. Add all polygons into the topology



    UPDATE public.neighborhoods
    SET topogeom = topology.toTopoGeom(geom, 'neighborhoods_topo', 1, 1e-7);


    This can take several hours for a large dataset, be patient. 1 is the layer_id returned earlier.



    5. Find faces appearing in several neighbourhoods



    Find all faces from the topology that are present in 2 or more topogeometries. I will leave the query as an exercise. Easiest is probably with the GetTopoGeomElements function, then group by face id, and look at the ones with a count of 2 or more. Alternatively, you could create a new table with the cleaned geometry from the topogeom column, just cast it to standard geometry topogeom::geometry, and repeat what you already have now, but now with a clean dataset without the sliver overlaps.






    share|improve this answer

























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "79"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316128%2fidentifying-long-and-narrow-polygons-in-with-postgis%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      I would try to create a negative buffer, if it eats thin polygons, then it’s good, if it doesn’t eat the polygon, then it’s mine ... :-)



      run this script, having previously set 2/3 of the width of the linear polygons ...



      create table name_table as
      SELECT ST_Buffer(
      (ST_Dump(
      (ST_Union(
      ST_Buffer(
      (geom),-0.0001))))).geom,
      0.0001)) as geom from source_table


      OS :-)...






      share|improve this answer

























      • in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

        – bplmp
        Mar 21 at 14:11











      • Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

        – Cyril
        Mar 21 at 14:12















      4














      I would try to create a negative buffer, if it eats thin polygons, then it’s good, if it doesn’t eat the polygon, then it’s mine ... :-)



      run this script, having previously set 2/3 of the width of the linear polygons ...



      create table name_table as
      SELECT ST_Buffer(
      (ST_Dump(
      (ST_Union(
      ST_Buffer(
      (geom),-0.0001))))).geom,
      0.0001)) as geom from source_table


      OS :-)...






      share|improve this answer

























      • in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

        – bplmp
        Mar 21 at 14:11











      • Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

        – Cyril
        Mar 21 at 14:12













      4












      4








      4







      I would try to create a negative buffer, if it eats thin polygons, then it’s good, if it doesn’t eat the polygon, then it’s mine ... :-)



      run this script, having previously set 2/3 of the width of the linear polygons ...



      create table name_table as
      SELECT ST_Buffer(
      (ST_Dump(
      (ST_Union(
      ST_Buffer(
      (geom),-0.0001))))).geom,
      0.0001)) as geom from source_table


      OS :-)...






      share|improve this answer















      I would try to create a negative buffer, if it eats thin polygons, then it’s good, if it doesn’t eat the polygon, then it’s mine ... :-)



      run this script, having previously set 2/3 of the width of the linear polygons ...



      create table name_table as
      SELECT ST_Buffer(
      (ST_Dump(
      (ST_Union(
      ST_Buffer(
      (geom),-0.0001))))).geom,
      0.0001)) as geom from source_table


      OS :-)...







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 27 at 2:22









      ahmadhanb

      24.1k32156




      24.1k32156










      answered Mar 21 at 7:21









      CyrilCyril

      1,2301317




      1,2301317












      • in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

        – bplmp
        Mar 21 at 14:11











      • Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

        – Cyril
        Mar 21 at 14:12

















      • in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

        – bplmp
        Mar 21 at 14:11











      • Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

        – Cyril
        Mar 21 at 14:12
















      in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

      – bplmp
      Mar 21 at 14:11





      in the end your suggestion is what worked best for me. I ended using something like ST_Area(ST_Buffer(geom, -10)), the -10 being -10 meters in my case. If anything returned 0 from that expression then I could filter it out.

      – bplmp
      Mar 21 at 14:11













      Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

      – Cyril
      Mar 21 at 14:12





      Thank you, I am glad that it helped you, use this approach in such cases, with respect ...

      – Cyril
      Mar 21 at 14:12













      9














      Instead of area/perimeter, it is better to use the area divided by the square of the perimeter (or its inverse).



      This is also called "shape index". The square of the perimeter divided by the area has a minimum value of 4*Pi() (in the case of a disk, which is the most compact 2D geometry), so it can be normalized by 4*Pi() for an easy interpretation (normalized values close to 1 then mean that you have very compact objects and squares have a values of approximately 1.27).



      EDIT: A threshold on the area would be usefull to remove the very small artefacts, which could be compact. Then the shape index would show better contrast.
      EDIT: in addition to this answer, the use of ST_Snap could help you solve the problem before it occurs.






      share|improve this answer

























      • Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

        – bplmp
        Mar 20 at 15:55











      • Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

        – bplmp
        Mar 20 at 16:09






      • 2





        Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

        – John Powell
        Mar 20 at 16:50











      • @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

        – radouxju
        Mar 21 at 7:15











      • @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

        – radouxju
        Mar 21 at 7:20















      9














      Instead of area/perimeter, it is better to use the area divided by the square of the perimeter (or its inverse).



      This is also called "shape index". The square of the perimeter divided by the area has a minimum value of 4*Pi() (in the case of a disk, which is the most compact 2D geometry), so it can be normalized by 4*Pi() for an easy interpretation (normalized values close to 1 then mean that you have very compact objects and squares have a values of approximately 1.27).



      EDIT: A threshold on the area would be usefull to remove the very small artefacts, which could be compact. Then the shape index would show better contrast.
      EDIT: in addition to this answer, the use of ST_Snap could help you solve the problem before it occurs.






      share|improve this answer

























      • Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

        – bplmp
        Mar 20 at 15:55











      • Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

        – bplmp
        Mar 20 at 16:09






      • 2





        Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

        – John Powell
        Mar 20 at 16:50











      • @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

        – radouxju
        Mar 21 at 7:15











      • @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

        – radouxju
        Mar 21 at 7:20













      9












      9








      9







      Instead of area/perimeter, it is better to use the area divided by the square of the perimeter (or its inverse).



      This is also called "shape index". The square of the perimeter divided by the area has a minimum value of 4*Pi() (in the case of a disk, which is the most compact 2D geometry), so it can be normalized by 4*Pi() for an easy interpretation (normalized values close to 1 then mean that you have very compact objects and squares have a values of approximately 1.27).



      EDIT: A threshold on the area would be usefull to remove the very small artefacts, which could be compact. Then the shape index would show better contrast.
      EDIT: in addition to this answer, the use of ST_Snap could help you solve the problem before it occurs.






      share|improve this answer















      Instead of area/perimeter, it is better to use the area divided by the square of the perimeter (or its inverse).



      This is also called "shape index". The square of the perimeter divided by the area has a minimum value of 4*Pi() (in the case of a disk, which is the most compact 2D geometry), so it can be normalized by 4*Pi() for an easy interpretation (normalized values close to 1 then mean that you have very compact objects and squares have a values of approximately 1.27).



      EDIT: A threshold on the area would be usefull to remove the very small artefacts, which could be compact. Then the shape index would show better contrast.
      EDIT: in addition to this answer, the use of ST_Snap could help you solve the problem before it occurs.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 21 at 10:39

























      answered Mar 20 at 15:36









      radouxjuradouxju

      41.5k145122




      41.5k145122












      • Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

        – bplmp
        Mar 20 at 15:55











      • Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

        – bplmp
        Mar 20 at 16:09






      • 2





        Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

        – John Powell
        Mar 20 at 16:50











      • @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

        – radouxju
        Mar 21 at 7:15











      • @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

        – radouxju
        Mar 21 at 7:20

















      • Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

        – bplmp
        Mar 20 at 15:55











      • Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

        – bplmp
        Mar 20 at 16:09






      • 2





        Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

        – John Powell
        Mar 20 at 16:50











      • @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

        – radouxju
        Mar 21 at 7:15











      • @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

        – radouxju
        Mar 21 at 7:20
















      Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

      – bplmp
      Mar 20 at 15:55





      Thanks! But I'm unsure how ST_Snap could help in this case... If I got it right, you're suggesting something like (o.overlap_perimeter^2 / o.overlap_area) / (4 * Pi()) as overlap_ratio? This is having worse results for me than just area / perimeter.

      – bplmp
      Mar 20 at 15:55













      Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

      – bplmp
      Mar 20 at 16:09





      Now using o.overlap_perimeter / (4 * sqrt(o.overlap_area)) as overlap_ratio according to this paper, but still worse results (although that's hard to quantify what I mean by worse) isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/I-7/135/…, page 183.

      – bplmp
      Mar 20 at 16:09




      2




      2





      Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

      – John Powell
      Mar 20 at 16:50





      Thank you for this, I had never heard of the "shape index". I had always thought that using a minimum bounding rectangle was the best way to answer this sort of question. I found this, repository.asu.edu/attachments/111230/content/…, which is interesting.

      – John Powell
      Mar 20 at 16:50













      @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

      – radouxju
      Mar 21 at 7:15





      @JohnPowell intersting paper, thanks. I see that what I know as a shape index is called circularity index in the paper. My problem with minimum bounding rectangles is that it doesn't work with very concave objects (e.g. U-shaped)

      – radouxju
      Mar 21 at 7:15













      @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

      – radouxju
      Mar 21 at 7:20





      @bplmp ST_Snap would help you snap the vertices of "nearly" adjacent polygons so that they do no overlap anymore. There is no scale on your figures, but your artefact look like lines, so I guess that you can use a tolerance value theat is enough to avoid artefacts but does not affect the large polygons.

      – radouxju
      Mar 21 at 7:20











      5














      One option would be to use the ratio of the area of the polygon to the longest line that can be drawn using its extremities. Identifying long narrow polygons.



      select * from polygons where ST_Length(ST_LongestLine(geom, geom)) < ST_Area(geom) * 4



      This works pretty well for sliver polygons. You can adjust what the ratio (what you multiply the area with) to suit your needs and projection.






      share|improve this answer



























        5














        One option would be to use the ratio of the area of the polygon to the longest line that can be drawn using its extremities. Identifying long narrow polygons.



        select * from polygons where ST_Length(ST_LongestLine(geom, geom)) < ST_Area(geom) * 4



        This works pretty well for sliver polygons. You can adjust what the ratio (what you multiply the area with) to suit your needs and projection.






        share|improve this answer

























          5












          5








          5







          One option would be to use the ratio of the area of the polygon to the longest line that can be drawn using its extremities. Identifying long narrow polygons.



          select * from polygons where ST_Length(ST_LongestLine(geom, geom)) < ST_Area(geom) * 4



          This works pretty well for sliver polygons. You can adjust what the ratio (what you multiply the area with) to suit your needs and projection.






          share|improve this answer













          One option would be to use the ratio of the area of the polygon to the longest line that can be drawn using its extremities. Identifying long narrow polygons.



          select * from polygons where ST_Length(ST_LongestLine(geom, geom)) < ST_Area(geom) * 4



          This works pretty well for sliver polygons. You can adjust what the ratio (what you multiply the area with) to suit your needs and projection.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 20 at 15:54









          HeikkiVesantoHeikkiVesanto

          9,3502245




          9,3502245





















              1














              It sounds like this might match your use case: Eliminate selected polygons




              Combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated.



              Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.




              It sounds like you'd want to try the "Largest Common Boundary" option.






              share|improve this answer























              • I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

                – FGreg
                Mar 20 at 22:49















              1














              It sounds like this might match your use case: Eliminate selected polygons




              Combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated.



              Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.




              It sounds like you'd want to try the "Largest Common Boundary" option.






              share|improve this answer























              • I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

                – FGreg
                Mar 20 at 22:49













              1












              1








              1







              It sounds like this might match your use case: Eliminate selected polygons




              Combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated.



              Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.




              It sounds like you'd want to try the "Largest Common Boundary" option.






              share|improve this answer













              It sounds like this might match your use case: Eliminate selected polygons




              Combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated.



              Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.




              It sounds like you'd want to try the "Largest Common Boundary" option.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 20 at 22:29









              FGregFGreg

              1135




              1135












              • I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

                – FGreg
                Mar 20 at 22:49

















              • I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

                – FGreg
                Mar 20 at 22:49
















              I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

              – FGreg
              Mar 20 at 22:49





              I realize now you were asking for postgis solutions not qgis solutions. My apologies, I don't think postgis has an equivalent function but I'll leave this up for posterity.

              – FGreg
              Mar 20 at 22:49











              0














              This looks to me like a perfect use case for PostGIS topology extension. The topology's tolerance parameter will determine how far you allow vertices to snap to other existing polygons, to cope with the low precision of the source data and to clean it.



              In short, the strategy is:



              1. Enable the topology extension



              CREATE EXTENSION postgis_topology;


              2. Create a new empty topology



              SELECT topology.CreateTopology('neighborhoods_topo', 4326, 1e-7);


              The third parameter is the tolerance, in the units of the CRS; choose it wisely. Ideally, you want a CRS where unit is meters. If the CRS unit is not meters, as with WGS 84 aka 4326, use ST_Transform to reproject your polygons.



              3. Add a TopoGeometry column to the polygons table



              SELECT topology.AddTopoGeometryColumn('neighborhoods_topo', 'public', 'neighborhoods', 'topogeom', 'POLYGON');


              This returns a new layer_id. Save it, it will be needed later. It will be layer 1 if your start from scratch, and incremented at every new call.



              4. Add all polygons into the topology



              UPDATE public.neighborhoods
              SET topogeom = topology.toTopoGeom(geom, 'neighborhoods_topo', 1, 1e-7);


              This can take several hours for a large dataset, be patient. 1 is the layer_id returned earlier.



              5. Find faces appearing in several neighbourhoods



              Find all faces from the topology that are present in 2 or more topogeometries. I will leave the query as an exercise. Easiest is probably with the GetTopoGeomElements function, then group by face id, and look at the ones with a count of 2 or more. Alternatively, you could create a new table with the cleaned geometry from the topogeom column, just cast it to standard geometry topogeom::geometry, and repeat what you already have now, but now with a clean dataset without the sliver overlaps.






              share|improve this answer





























                0














                This looks to me like a perfect use case for PostGIS topology extension. The topology's tolerance parameter will determine how far you allow vertices to snap to other existing polygons, to cope with the low precision of the source data and to clean it.



                In short, the strategy is:



                1. Enable the topology extension



                CREATE EXTENSION postgis_topology;


                2. Create a new empty topology



                SELECT topology.CreateTopology('neighborhoods_topo', 4326, 1e-7);


                The third parameter is the tolerance, in the units of the CRS; choose it wisely. Ideally, you want a CRS where unit is meters. If the CRS unit is not meters, as with WGS 84 aka 4326, use ST_Transform to reproject your polygons.



                3. Add a TopoGeometry column to the polygons table



                SELECT topology.AddTopoGeometryColumn('neighborhoods_topo', 'public', 'neighborhoods', 'topogeom', 'POLYGON');


                This returns a new layer_id. Save it, it will be needed later. It will be layer 1 if your start from scratch, and incremented at every new call.



                4. Add all polygons into the topology



                UPDATE public.neighborhoods
                SET topogeom = topology.toTopoGeom(geom, 'neighborhoods_topo', 1, 1e-7);


                This can take several hours for a large dataset, be patient. 1 is the layer_id returned earlier.



                5. Find faces appearing in several neighbourhoods



                Find all faces from the topology that are present in 2 or more topogeometries. I will leave the query as an exercise. Easiest is probably with the GetTopoGeomElements function, then group by face id, and look at the ones with a count of 2 or more. Alternatively, you could create a new table with the cleaned geometry from the topogeom column, just cast it to standard geometry topogeom::geometry, and repeat what you already have now, but now with a clean dataset without the sliver overlaps.






                share|improve this answer



























                  0












                  0








                  0







                  This looks to me like a perfect use case for PostGIS topology extension. The topology's tolerance parameter will determine how far you allow vertices to snap to other existing polygons, to cope with the low precision of the source data and to clean it.



                  In short, the strategy is:



                  1. Enable the topology extension



                  CREATE EXTENSION postgis_topology;


                  2. Create a new empty topology



                  SELECT topology.CreateTopology('neighborhoods_topo', 4326, 1e-7);


                  The third parameter is the tolerance, in the units of the CRS; choose it wisely. Ideally, you want a CRS where unit is meters. If the CRS unit is not meters, as with WGS 84 aka 4326, use ST_Transform to reproject your polygons.



                  3. Add a TopoGeometry column to the polygons table



                  SELECT topology.AddTopoGeometryColumn('neighborhoods_topo', 'public', 'neighborhoods', 'topogeom', 'POLYGON');


                  This returns a new layer_id. Save it, it will be needed later. It will be layer 1 if your start from scratch, and incremented at every new call.



                  4. Add all polygons into the topology



                  UPDATE public.neighborhoods
                  SET topogeom = topology.toTopoGeom(geom, 'neighborhoods_topo', 1, 1e-7);


                  This can take several hours for a large dataset, be patient. 1 is the layer_id returned earlier.



                  5. Find faces appearing in several neighbourhoods



                  Find all faces from the topology that are present in 2 or more topogeometries. I will leave the query as an exercise. Easiest is probably with the GetTopoGeomElements function, then group by face id, and look at the ones with a count of 2 or more. Alternatively, you could create a new table with the cleaned geometry from the topogeom column, just cast it to standard geometry topogeom::geometry, and repeat what you already have now, but now with a clean dataset without the sliver overlaps.






                  share|improve this answer















                  This looks to me like a perfect use case for PostGIS topology extension. The topology's tolerance parameter will determine how far you allow vertices to snap to other existing polygons, to cope with the low precision of the source data and to clean it.



                  In short, the strategy is:



                  1. Enable the topology extension



                  CREATE EXTENSION postgis_topology;


                  2. Create a new empty topology



                  SELECT topology.CreateTopology('neighborhoods_topo', 4326, 1e-7);


                  The third parameter is the tolerance, in the units of the CRS; choose it wisely. Ideally, you want a CRS where unit is meters. If the CRS unit is not meters, as with WGS 84 aka 4326, use ST_Transform to reproject your polygons.



                  3. Add a TopoGeometry column to the polygons table



                  SELECT topology.AddTopoGeometryColumn('neighborhoods_topo', 'public', 'neighborhoods', 'topogeom', 'POLYGON');


                  This returns a new layer_id. Save it, it will be needed later. It will be layer 1 if your start from scratch, and incremented at every new call.



                  4. Add all polygons into the topology



                  UPDATE public.neighborhoods
                  SET topogeom = topology.toTopoGeom(geom, 'neighborhoods_topo', 1, 1e-7);


                  This can take several hours for a large dataset, be patient. 1 is the layer_id returned earlier.



                  5. Find faces appearing in several neighbourhoods



                  Find all faces from the topology that are present in 2 or more topogeometries. I will leave the query as an exercise. Easiest is probably with the GetTopoGeomElements function, then group by face id, and look at the ones with a count of 2 or more. Alternatively, you could create a new table with the cleaned geometry from the topogeom column, just cast it to standard geometry topogeom::geometry, and repeat what you already have now, but now with a clean dataset without the sliver overlaps.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 27 at 0:35

























                  answered Mar 27 at 0:23









                  FrançoisFrançois

                  1987




                  1987



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316128%2fidentifying-long-and-narrow-polygons-in-with-postgis%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Masuk log Menu navigasi

                      Старые Смолеговицы Содержание История | География | Демография | Достопримечательности | Примечания | НавигацияHGЯOLHGЯOL41 206 832 01641 606 406 141Административно-территориальное деление Ленинградской области«Переписная оброчная книга Водской пятины 1500 года», С. 793«Карта Ингерманландии: Ивангорода, Яма, Копорья, Нотеборга», по материалам 1676 г.«Генеральная карта провинции Ингерманландии» Э. Белинга и А. Андерсина, 1704 г., составлена по материалам 1678 г.«Географический чертёж над Ижорскою землей со своими городами» Адриана Шонбека 1705 г.Новая и достоверная всей Ингерманландии ланткарта. Грав. А. Ростовцев. СПб., 1727 г.Топографическая карта Санкт-Петербургской губернии. 5-и верстка. Шуберт. 1834 г.Описание Санкт-Петербургской губернии по уездам и станамСпецкарта западной части России Ф. Ф. Шуберта. 1844 г.Алфавитный список селений по уездам и станам С.-Петербургской губернииСписки населённых мест Российской Империи, составленные и издаваемые центральным статистическим комитетом министерства внутренних дел. XXXVII. Санкт-Петербургская губерния. По состоянию на 1862 год. СПб. 1864. С. 203Материалы по статистике народного хозяйства в С.-Петербургской губернии. Вып. IX. Частновладельческое хозяйство в Ямбургском уезде. СПб, 1888, С. 146, С. 2, 7, 54Положение о гербе муниципального образования Курское сельское поселениеСправочник истории административно-территориального деления Ленинградской области.Топографическая карта Ленинградской области, квадрат О-35-23-В (Хотыницы), 1930 г.АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1933, С. 27, 198АрхивированоАдминистративно-экономический справочник по Ленинградской области. — Л., 1936, с. 219АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1966, с. 175АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1973, С. 180АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1990, ISBN 5-289-00612-5, С. 38АрхивированоАдминистративно-территориальное деление Ленинградской области. — СПб., 2007, с. 60АрхивированоКоряков Юрий База данных «Этно-языковой состав населённых пунктов России». Ленинградская область.Административно-территориальное деление Ленинградской области. — СПб, 1997, ISBN 5-86153-055-6, С. 41АрхивированоКультовый комплекс Старые Смолеговицы // Электронная энциклопедия ЭрмитажаПроблемы выявления, изучения и сохранения культовых комплексов с каменными крестами: по материалам работ 2016-2017 гг. в Ленинградской области