eblondel / cleangeo

Cleaning geometries from spatial objects in R

Home Page:https://github.com/eblondel/cleangeo/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with polygon slot

DerekYves opened this issue · comments

Hello,

Thank you for this excellent package. In updating from .1-2 to the current version on CRAN (or the dev version, same issue), I now get an error in my batch script. It seems that running spTransform from the sp package prior to running clgeo is what breaks the process, but I do need to perform this transformation so I'm a bit stuck. Running the cleo before the transformation creates other issues. What's strange for me is that reverting to .1-2 removes the problem and it appears to clean the spdf just find. The error message is:

Error in clgeo_CleanByPolygonation.Polygon(polygon) : 
  trying to get slot "polygons" from an object of a basic class ("NULL") with no slots
In addition: There were 38 warnings (use warnings() to see them)

The warnings I get are:

Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -73.487313999999998 42.049638000000002
2: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -72.847142000000005 42.036893999999997
3: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -72.816740999999993 41.997594999999997
4: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -72.606975289999994 42.025240289999999
5: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.890785789999995 42.024368150000001
6: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -73.521040999999997 41.619773000000002
7: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -73.516784999999999 41.687581000000002
8: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Ring Self-intersection at or near point -73.501983999999993 41.858716999999999
9: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -73.489615000000001 42.000091939999997
10: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Ring Self-intersection at or near point -71.582909999999998 42.195559000000003
11: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.574289500000006 42.263660889999997
12: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.597332859999995 42.39463087
13: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.552792400000001 42.433623500000003
14: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.560366999999999 42.474350000000001
15: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.531475999999998 42.520487000000003
16: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.533057600000006 42.525267939999999
17: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.594643000000005 42.543370000000003
18: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.636078999999995 42.539923999999999
19: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.635812000000001 42.524090999999999
20: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.664614 42.611589000000002
21: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.775412790000004 42.638295800000002
22: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.858410000000006 42.633839999999999
23: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.857820000000004 42.674987000000002
24: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.330206000000004 42.697189999999999
25: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.255606090000001 42.736388069999997
26: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.245503999999997 42.742589000000002
27: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.06420104 42.80628901
28: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.335196999999994 41.835500000000003
29: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.338697999999994 41.898398999999998
30: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.381400999999997 42.018797999999997
31: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.778613019999995 44.399799000000002
32: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.749533 44.401955000000001
33: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -70.848625029999994 42.860939010000003
34: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -70.96650004 42.868988989999998
35: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.059326839999997 42.818615870000002
36: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.181810409999997 42.737681600000002
37: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.294205000000005 42.69699
38: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.636214100000004 42.704887999999997

Thanks for reporting. By chance could you share some of your data on
which i could run tests?

Le 11/10/2016 à 16:43, Derek Darves a écrit :

Hello,

Thank you for this excellent package. In updating from .1-2 to the
current version on CRAN (or the dev version, same issue), I now get an
error in my batch script. It seems that running spTransform from the
sp package prior to running clgeo is what breaks the process, but I do
need to perform this transformation so I'm a bit stuck. Running the
cleo before the transformation creates other issues. What's strange
for me is that reverting to .1-2 removes the problem and it appears to
clean the spdf just find. The error message is:

|Error in clgeo_CleanByPolygonation.Polygon(polygon) : trying to get
slot "polygons" from an object of a basic class ("NULL") with no slots
In addition: There were 38 warnings (use warnings() to see them) |

The warnings I get are:

Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-73.487313999999998 42.049638000000002
2: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -72.847142000000005 42.036893999999997
3: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -72.816740999999993 41.997594999999997
4: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -72.606975289999994 42.025240289999999
5: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.890785789999995 42.024368150000001
6: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -73.521040999999997 41.619773000000002
7: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -73.516784999999999 41.687581000000002
8: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Ring Self-intersection at or near point -73.501983999999993
41.858716999999999
9: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -73.489615000000001 42.000091939999997
10: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Ring Self-intersection at or near point -71.582909999999998
42.195559000000003
11: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.574289500000006 42.263660889999997
12: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.597332859999995 42.39463087
13: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.552792400000001 42.433623500000003
14: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.560366999999999 42.474350000000001
15: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.531475999999998 42.520487000000003
16: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.533057600000006 42.525267939999999
17: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.594643000000005 42.543370000000003
18: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.636078999999995 42.539923999999999
19: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.635812000000001 42.524090999999999
20: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.664614
42.611589000000002
21: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.775412790000004 42.638295800000002
22: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.858410000000006 42.633839999999999
23: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.857820000000004 42.674987000000002
24: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.330206000000004 42.697189999999999
25: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.255606090000001 42.736388069999997
26: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.245503999999997 42.742589000000002
27: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.06420104 42.80628901
28: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.335196999999994 41.835500000000003
29: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.338697999999994 41.898398999999998
30: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.381400999999997 42.018797999999997
31: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.778613019999995 44.399799000000002
32: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point -71.749533
44.401955000000001
33: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -70.848625029999994 42.860939010000003
34: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -70.96650004 42.868988989999998
35: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.059326839999997 42.818615870000002
36: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.181810409999997 42.737681600000002
37: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Too few points in geometry component at or near point
-71.294205000000005 42.69699
38: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
Self-intersection at or near point -71.636214100000004 42.704887999999997


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#13, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABQ1bGGQWw6KBTskWJWeQ2bcm05_1itgks5qy6CJgaJpZM4KTtgk.

Emmanuel Blondel
International Consultant | CEO
/Geographic Information Systems in Agronomy, Environment, Fishery &
Marine Sciences/
41, Avenue du Vacayrial
81370 Saint Sulpice la Pointe, France
Tel: +33 (0) 6 45 97 87 52
Website: http://eblondel.github.io http://eblondel.github.io/#/services
Email: emmanuel.blondel1@gmail.com mailto:emmanuel.blondel1@gmail.com

Hello,

Thanks for your help with this. I've attached an RDS. The issue appears to be when this command is run on the data prior to cleaning:

c_1 <- spTransform(c_1, "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0")

I believe the attached should be fine with cl_geo, but once the above transformation is performed with v .2 I get the error noted above. Thanks!

clgeo_example.Rds.zip

Ok thanks i will have a look ASAP to the error.

For the warnings, these correspond to all issues of geometries that were found during cleaning. Possibly i should let user hide the warnings. The new cleangeo performs more advanced cleaning (by polygonation) that helps detecting and fixing more issues, in particular the "self-intersections" that's they are now appearing as warnings in cleangeo 0.2.

Fixed. Can you check on your side?

con <- gzfile("clgeo_example.rds")
sp <- readRDS(con)
sp2 <- spTransform(sp, "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0")
sp2.clean <- clgeo_Clean(sp2, verbose = TRUE)

I've also improved the cleangeo logger , see #14 . This includes applying a suppressWarnings when verbose = FALSE.

This change did the trick. Many, many thanks for the quick response!

Derek

you're welcome, thanks to you for reporting the issue!