[GRASS-user] How to detect/remove overlapping polygons (imported with v.in.ogr )based on the data attributes
B H
hemantbist at gmail.com
Tue Feb 22 15:53:21 PST 2022
Hi Veronica,
Here is what I meant by the problem I get with using -c. ( Without -c and
a snap value v.in.ogr only has duplicates and no errors)
But with -c option there are lot of topological errors as well (since
v.in.ogr does not do cleaning without -c)
All the warnings about topological errors/incorrect boundaries,centroid
outside areas, duplicate centroid are fixed without -c option
grass78 -c EPSG:3857 $PWD/grassdata/loc --exec v.in.ogr -c
input=$PWD/input.shp snap=0.5 output=outtab
----- snipped relevant output
WARNING: Number of centroids exceeds number of areas: 1057 > 627
WARNING: Number of incorrect boundaries: 979
WARNING: Number of centroids outside area: 181
WARNING: Number of duplicate centroids: 331
-----------------------------------------------------
WARNING: The output contains topological errors:
Number of incorrect boundaries: 979
Number of centroids outside area: 181
Number of duplicate centroids: 331
The input could be cleaned by snapping vertices to each other.
Estimated range of snapping threshold: [1e-08, 10]
Try to import again, snapping with 5: 'snap=5'
Execution of <v.in.ogr -c input=/tmp/chkgrass/input.shp snap=0.5
output=outtab> finished.
Cleaning up default sqlite database ...
On Tue, Feb 22, 2022 at 10:17 AM Veronica Andreo <veroandreo at gmail.com>
wrote:
> [adding grass-user back]
>
> Please, always keep the list when responding
>
> I'm not sure I understand what you mean, but you can see what 2 or n
> categories an overlapping polygon has by displaying categories and
> centroids from layer 2 in d.vect. Layer 2 is usually where GRASS will store
> these topology errors after import.
>
> [image: image.png]
>
> [image: image.png]
> HTH,
> Vero
>
> El mar, 22 feb 2022 a las 14:56, B H (<hemantbist at gmail.com>) escribió:
>
>> Hi Veronica,
>> My understanding (I am not advanced user) that -c will also prevent any
>> other cleaning of polygons imported from shapefile.
>> There are some small errors in the data that are corrected by v.in.ogr.
>> These are the overlaps well above the "snap" threshold I use to import data.
>>
>> (I may be completely wrong here and would love to correct my
>> understanding).
>> I think that the two overlapping polygons are represented in Grass GIS
>> using a single area with the unique centroid (and multiple category ids).
>> I was hoping that grass has a way of associating and exposing to user a
>> unique "centroid id" for each centroid (So I know that two overlapping
>> parts are from same area).
>> thanks,
>> Hemant Bist.
>>
>>
>>
>>
>> On Mon, Feb 21, 2022 at 4:27 AM Veronica Andreo <veroandreo at gmail.com>
>> wrote:
>>
>>> Hello Hemant,
>>>
>>> The discussion continued in the thread you linked (see next messages in
>>> the thread). I used the -c flag of v.in.ogr to avoid cleaning polygons when
>>> importing the shapefile as I needed the simple features to extract zonal
>>> stats from raster maps afterwards. Would that be useful to you too in this
>>> case?
>>>
>>> Vero
>>>
>>>
>>>
>>>
>>>
>>> El sáb, 19 feb 2022 a las 0:23, B H (<hemantbist at gmail.com>) escribió:
>>>
>>>> I have data in a Shapefile which has genuine cases of overlapping
>>>> geometries. (As documented in v.in.ogr) the common areas appear with
>>>> multiple categories.
>>>> I need to find these common areas and "dedupe" them.
>>>> Currently I export the data out via v.out.ogr and in postgis do
>>>> select distinct on (st_asbinary(geometrycomlum)) from tablename order by
>>>> priorityattribute
>>>>
>>>> Is there some way to either dedupe it in grass Gis itself, or have
>>>> v.out.ogr output some common attribute in the two geometries that
>>>> represent the common area
>>>> from two polygons.
>>>> There is a similar question in this old thread. However I could not
>>>> find the solution.
>>>> https://lists.osgeo.org/pipermail/grass-user/2019-May/080293.html
>>>>
>>>>
>>>>
>>>>
>>>> ---
>>>> clip from v.in.ogr man page describing how the overlapping polygons
>>>> are handled.
>>>>
>>>> Overlapping polygons
>>>> When importing overlapping polygons, the overlapping parts will become
>>>> new areas with multiple categories, one unique category for each original
>>>> polygon. An original polygon will thus be converted to multiple areas with
>>>> the same shared category. These multiple areas will therefore also link to
>>>> the same entry in the attribute table. A single category value may thus
>>>> refer to multiple non-overlapping areas which together represent the
>>>> original polygon overlapping with another polygon. The original polygon can
>>>> be recovered by using v.extract with the desired category value or where
>>>> statement and the -d flag to dissolve common boundaries
>>>> Thanks,
>>>> Hemant
>>>>
>>>> _______________________________________________
>>>> grass-user mailing list
>>>> grass-user at lists.osgeo.org
>>>> https://lists.osgeo.org/mailman/listinfo/grass-user
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20220222/0bc9dc3c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 77690 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20220222/0bc9dc3c/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 69019 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20220222/0bc9dc3c/attachment-0003.png>
More information about the grass-user
mailing list