[R-sig-Geo] st_simplify outputs the input geometry with no simplification

Hugo Costa hugo@gco@t@ @end|ng |rom gm@||@com
Mon Jul 22 16:53:27 CEST 2019


I missed it completely.
Thank you very much!
Hugo

Michael Sumner <mdsumner using gmail.com> escreveu no dia segunda, 22/07/2019
à(s) 15:12:

> It has changed it, there's now a mix of POLYGON and MULTIPOLYGON
> geometries, but no change in the underlying coordinates. You have to use
> the dTolerance argument:
>
> nrow(st_coordinates(nc))
> [1] 2529
> nrow(st_coordinates(st_cast(nc_simplfy)))
> [1] 2529
> nrow(st_coordinates(st_cast(st_simplify(nc, dTolerance = 1000))))
> [1] 1941
>
> It still might change the geometry with dTolerance = 0 (the default), in
> that case it will remove vertices that are collinear (unnecessarily dense
> straight lines, reduce to two-vertex edges).  I only learnt that recently.
>
> HTH
>
>
>
> On Mon, Jul 22, 2019 at 8:15 PM Hugo Costa <hugoagcosta using gmail.com> wrote:
>
>> Dear list,
>>
>> function st_simplify outputs exactly the same geometry as the input. This
>> is an example:
>>
>> library(sf)
>>
>> nc = st_read(system.file("shape/nc.shp", package="sf"))
>> nc <- nc %>% st_transform(3857)
>> plot(st_geometry(nc))
>>
>> nc_simplfy<-st_simplify(nc)
>> plot(st_geometry(nc_simplfy))
>>
>> However, I'm quite sure some days ago st_simpliffy was working as
>> expected.
>> Could it be something wrong in my machine? What am I missing?
>>
>> > sessionInfo()
>> R version 3.5.3 (2019-03-11)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows >= 8 x64 (build 9200)
>>
>> Matrix products: default
>>
>> locale:
>> [1] LC_COLLATE=Portuguese_Portugal.1252  LC_CTYPE=Portuguese_Portugal.1252
>>    LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
>> [5] LC_TIME=Portuguese_Portugal.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] sf_0.7-3
>>
>> loaded via a namespace (and not attached):
>>  [1] compiler_3.5.3 magrittr_1.5   class_7.3-15   DBI_1.0.0
>>  tools_3.5.3    units_0.6-2    Rcpp_1.0.1     grid_3.5.3     e1071_1.7-0.1
>> [10] classInt_0.3-1
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsumner using gmail.com
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list