Re: [R] dissolve tiny polygons to others with unionSpatialPolygons{maptools}

2016-06-06 Thread Kumar Mainali
Thank you, Roger. I cannot fix the upstream processes to eliminate
generation of these problems. So, I need to deal with the data I got.
I tried various online resources including
https://gist.github.com/mstrimas/1b4a4b93a9d4a158bce4 and tried:
setScales()
set_RGEOS_dropSlivers(TRUE)
set_RGEOS_polyThreshold()

before performing:
gUnaryUnion(p.ranges, id=NULL)

This eliminates the slivers but it also dissolves ALL the polygons to get a
single polygon. That is not something I wanted. I would like to dissolve
only the tiny polygons to the neighboring bigger ones.

Any help is very much appreciated!

ᐧ

Postdoctoral Associate
Department of Biology
University of Maryland, College Park

On Mon, Jun 6, 2016 at 9:24 AM, Roger Bivand  wrote:

> On Mon, 6 Jun 2016, Kumar Mainali wrote:
>
> I am trying to use unionSpatialPolygons() of maptools to eliminate sliver
>> in species range. I want to dissolve tiny sliver polygons in a shapefile
>> to
>> bigger polygons as "Eliminate (Data Management)" of ArcMap does. Whereas I
>> can dissolve polygons that have identical features in the argument "IDs",
>> I
>> cannot dissolve tiny polygons based on some threshold in area. In fact,
>> the
>> argument "threshold" has no effect in the output.
>>
>
> Indeed, threshold is not passed through, it was used when the function
> used gpclib rather than rgeos; I'm minded to deprecate
> maptools::unionSpatialPolygons anyway. Note that the data are in
> geographical coordinates, which may very well not be appropriate for the
> topological operations you are trying to do. Use rgeos::gUnaryUnion
> instead, and refer to this thread:
>
> https://stat.ethz.ch/pipermail/r-sig-geo/2015-November/023667.html
>
> for using rgeos::set_RGEOS_polyThreshold() and friends. They do not,
> however, try to guess which of the polygons neighbouring the sliver should
> get the extra area, so you'll have to think that through yourself.
>
> Googling for lists:R-sig-geo dissolve slivers gets a fair number of hits.
>
> There is always also the upstream question of where the slivers came from,
> and whether the resolution is not in the earlier process - generate a map
> without slivers that says exactly what you mean, rather than fudging it
> afterwards.
>
> Roger
>
>
>> ​Input data is available here: ​
>> https://www.dropbox.com/sh/a0x5bbo9u60y7is/AAB6RjXHFQKZv-i-t4JclF3ba?dl=0
>>
>> p.ranges <- shapefile{raster}
>> (IDs <- p.ranges$style_id)
>> library(maptools)
>> unionSpatialPolygons(p.ranges, IDs = IDs, threshold = 1.5)
>>
>> ​-- Kumar Mainali
>> Postdoctoral Associate
>> Department of Biology
>> University of Maryland, College Park
>>
>>
>> ᐧ
>>
>>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: roger.biv...@nhh.no
> http://orcid.org/-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0J=en
> http://depsy.org/person/434412

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] dissolve tiny polygons to others with unionSpatialPolygons{maptools}

2016-06-06 Thread Roger Bivand

On Mon, 6 Jun 2016, Kumar Mainali wrote:


I am trying to use unionSpatialPolygons() of maptools to eliminate sliver
in species range. I want to dissolve tiny sliver polygons in a shapefile to
bigger polygons as "Eliminate (Data Management)" of ArcMap does. Whereas I
can dissolve polygons that have identical features in the argument "IDs", I
cannot dissolve tiny polygons based on some threshold in area. In fact, the
argument "threshold" has no effect in the output.


Indeed, threshold is not passed through, it was used when the function 
used gpclib rather than rgeos; I'm minded to deprecate 
maptools::unionSpatialPolygons anyway. Note that the data are in 
geographical coordinates, which may very well not be appropriate for the 
topological operations you are trying to do. Use rgeos::gUnaryUnion 
instead, and refer to this thread:


https://stat.ethz.ch/pipermail/r-sig-geo/2015-November/023667.html

for using rgeos::set_RGEOS_polyThreshold() and friends. They do not, 
however, try to guess which of the polygons neighbouring the sliver should 
get the extra area, so you'll have to think that through yourself.


Googling for lists:R-sig-geo dissolve slivers gets a fair number of hits.

There is always also the upstream question of where the slivers came from, 
and whether the resolution is not in the earlier process - generate a map 
without slivers that says exactly what you mean, rather than fudging it 
afterwards.


Roger



​Input data is available here: ​
https://www.dropbox.com/sh/a0x5bbo9u60y7is/AAB6RjXHFQKZv-i-t4JclF3ba?dl=0

p.ranges <- shapefile{raster}
(IDs <- p.ranges$style_id)
library(maptools)
unionSpatialPolygons(p.ranges, IDs = IDs, threshold = 1.5)

​-- Kumar Mainali
Postdoctoral Associate
Department of Biology
University of Maryland, College Park


ᐧ



--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: roger.biv...@nhh.no
http://orcid.org/-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0J=en
http://depsy.org/person/434412
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] dissolve tiny polygons to others with unionSpatialPolygons{maptools}

2016-06-05 Thread Kumar Mainali
I am trying to use unionSpatialPolygons() of maptools to eliminate sliver
in species range. I want to dissolve tiny sliver polygons in a shapefile to
bigger polygons as "Eliminate (Data Management)" of ArcMap does. Whereas I
can dissolve polygons that have identical features in the argument "IDs", I
cannot dissolve tiny polygons based on some threshold in area. In fact, the
argument "threshold" has no effect in the output.

​Input data is available here: ​
https://www.dropbox.com/sh/a0x5bbo9u60y7is/AAB6RjXHFQKZv-i-t4JclF3ba?dl=0

p.ranges <- shapefile{raster}
(IDs <- p.ranges$style_id)
library(maptools)
unionSpatialPolygons(p.ranges, IDs = IDs, threshold = 1.5)

​-- Kumar Mainali
Postdoctoral Associate
Department of Biology
University of Maryland, College Park


ᐧ

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.