Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider implementing st_makevalid #67

Closed
cjtexas opened this issue Nov 10, 2016 · 10 comments
Closed

Please consider implementing st_makevalid #67

cjtexas opened this issue Nov 10, 2016 · 10 comments

Comments

@cjtexas
Copy link

cjtexas commented Nov 10, 2016

I've searched many times over the years for an R version of postgis' st_makevalid() function (via liblwgeom) and wonder if this would be a good time and place for it. Thanks for all your hard work!

@tiernanmartin
Copy link

I'll second that.

I have frequently resorted to pre-processing spatial data in GRASS (via rgrass7) because there isn't a good R implementation of makevalid. While this usually resolves my issue, the installation and setup of GRASS is non-trivial (esp. for Mac users) and it detracts from the reproducibility of an analysis.

@edzer
Copy link
Member

edzer commented Nov 10, 2016

It's definitely out of scope for this project, and would require additional packages on all CRAN check serves. But surely a nice idea!

@rsbivand
Copy link
Member

Does cleangeo go in that direction? Maybe helping Emmanuel with enabling or duplicating this for sf is a better way forward than making sf too big?

@edzer
Copy link
Member

edzer commented Nov 20, 2016

More realistically, @onehundredpercenttexan , where is the stand-alone lwgeom library to which one could possibly link? Your link seems to points to a component of PostGIS.

@edzer edzer added the wontfix label Nov 21, 2016
@cjtexas
Copy link
Author

cjtexas commented Nov 23, 2016

I was under the impression that there were changes made to lwgeom that allow for somewhat standalone use:
postgis/postgis#6

@cjtexas cjtexas closed this as completed Nov 23, 2016
@edzer
Copy link
Member

edzer commented Dec 19, 2016

Is the RT Topology Library what you had in mind?

@edzer
Copy link
Member

edzer commented Mar 7, 2017

Some good news to be reported here: we have sf now autodeting lwgeom, and if present provide a working st_make_valid:

> library(sf)
Linking to GEOS 3.5.0, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.2.1 r14555
> x = st_sfc(st_polygon(list(rbind(c(0,0),c(0.5,0),c(0.5,0.5),c(0.5,0),c(1,0),c(1,1),c(0,1),c(0,0)))))
> st_is_valid(x)
[1] FALSE
Warning message:
In eval(substitute(expr), envir, enclos) :
  Self-intersection at or near point 0.5 0
> y = st_make_valid(x)
> st_is_valid(y)
[1] TRUE
> y
Geometry set for 1 feature 
geometry type:  GEOMETRYCOLLECTION
dimension:      XY
bbox:           xmin: 0 ymin: 0 xmax: 1 ymax: 1
epsg (SRID):    NA
proj4string:    NA
GEOMETRYCOLLECTION(POLYGON((0.5 0, 0 0, 0 1, 1 ...
> y %>% st_cast()
Geometry set for 2 features 
geometry type:  GEOMETRY
dimension:      XY
bbox:           xmin: 0 ymin: 0 xmax: 1 ymax: 1
epsg (SRID):    NA
proj4string:    NA
POLYGON((0.5 0, 0 0, 0 1, 1 1, 1 0, 0.5 0))
LINESTRING(0.5 0, 0.5 0.5)
> 

I render it quite unlikely that there will be support for lwgeom on CRAN, i.e. in the binary versions distributed there for Windows and Mac, any time soon. If there are other things in lwgeom useful for sf, let me know.

@Demetrio92
Copy link

@edzer Somehow I don't get if this is actualy a wontfix, or if it is fixed.
I just installed the latest version via devtools::install_github("r-spatial/sf"), but st_make_valid doesn't seem to be a part of the package.
Any way I can get it?

Thanks!

@rsbivand
Copy link
Member

st_make_valid() is in lwgeom on CRAN, including Windows and OSX binaries.

@Demetrio92
Copy link

@rsbivand so it is actually a desired behaviour that although I have lwgeom and r-spatial/lwgeom sf doesn't automatically connect to it? [in the example above provided by @edzer it does]

> library(sf)
Linking to GEOS 3.5.1, GDAL 2.2.2, proj.4 4.9.2
> library(lwgeom)
Linking to liblwgeom 2.4.2 r16113, GEOS 3.5.1, proj.4 4.9.2

Anyways, it is working, thanks a lot! Especially for a super quick reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants