troubles with gPolygonize

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

troubles with gPolygonize

Masucci, A
Hi,
gPolygonize doesn't work with some simple geometries.
Here is an example:

> LS = list(
+ readWKT("LINESTRING (425963 576719, 425980 576703)"),
+ readWKT("LINESTRING (425963 576719, 425882 577073)"),
+ readWKT("LINESTRING (425980 576703, 426082 577072)"),
+ readWKT("LINESTRING (425882 577073, 426082 577072)"),
+ readWKT("LINESTRING (426138 577068, 426082 577072)"),
+ readWKT("LINESTRING (426138 577068, 426420 577039)"),
+ readWKT("LINESTRING (426420 577039, 426554 576990)"),
+ readWKT("LINESTRING (426751 576924, 426776 576823)"),
+ readWKT("LINESTRING (426751 576924, 426783 576919)"),
+ readWKT("LINESTRING (426751 576924, 426714 576953)"),
+ readWKT("LINESTRING (426776 576823, 426783 576919)"),
+ readWKT("LINESTRING (426658 576966, 426554 576990)"),
+ readWKT("LINESTRING (426658 576966, 426667 577031)"),
+ readWKT("LINESTRING (426658 576966, 426714 576953)"),
+ readWKT("LINESTRING (426667 577031, 426714 576953)")
+ )
> gPolygonize(LS)

Traceback:
 1: .Call("rgeos_polygonize", .RGEOS_HANDLE, splist, id, p4s, getCutEdges,     PACKAGE = "rgeos")
 2: gPolygonize(LS)
Error in gPolygonize(LS) : caught access violation - continue with care

I hope you can help me
Kindest regards

Paolo

_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: troubles with gPolygonize

Roger Bivand
This is a question about the use of the R package rgeos, which provides GEOS for sp classes. Consequently, this list is not a good choice; the R-sig-geo list would have been better. You have also not provided version information on rgeos, GEOS, or R; the two first are shown when rgeos is loaded, the latter as output from sessionInfo().

The problem was an assumption in the R code providing IDs for the output objects, not in GEOS. A fix has been committed to the R-Forge SVN repository for rgeos, together with your case in the examples for the function. If you can, please check out the source:

svn checkout svn://svn.r-forge.r-project.org/svnroot/rgeos/

and report back on whether the fix also works for your real use case.

Roger

Masucci, A wrote
Hi,
gPolygonize doesn't work with some simple geometries.
Here is an example:

> LS = list(
+ readWKT("LINESTRING (425963 576719, 425980 576703)"),
+ readWKT("LINESTRING (425963 576719, 425882 577073)"),
+ readWKT("LINESTRING (425980 576703, 426082 577072)"),
+ readWKT("LINESTRING (425882 577073, 426082 577072)"),
+ readWKT("LINESTRING (426138 577068, 426082 577072)"),
+ readWKT("LINESTRING (426138 577068, 426420 577039)"),
+ readWKT("LINESTRING (426420 577039, 426554 576990)"),
+ readWKT("LINESTRING (426751 576924, 426776 576823)"),
+ readWKT("LINESTRING (426751 576924, 426783 576919)"),
+ readWKT("LINESTRING (426751 576924, 426714 576953)"),
+ readWKT("LINESTRING (426776 576823, 426783 576919)"),
+ readWKT("LINESTRING (426658 576966, 426554 576990)"),
+ readWKT("LINESTRING (426658 576966, 426667 577031)"),
+ readWKT("LINESTRING (426658 576966, 426714 576953)"),
+ readWKT("LINESTRING (426667 577031, 426714 576953)")
+ )
> gPolygonize(LS)

Traceback:
 1: .Call("rgeos_polygonize", .RGEOS_HANDLE, splist, id, p4s, getCutEdges,     PACKAGE = "rgeos")
 2: gPolygonize(LS)
Error in gPolygonize(LS) : caught access violation - continue with care

I hope you can help me
Kindest regards

Paolo

_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: troubles with gPolygonize

Masucci, A
Dear Roger,
thanks for your reply and sorry for writing in the wrong mail list.
These are the information you asked me.

> library(rgeos)
Loading required package: sp
rgeos version: 0.2-12, (SVN revision 372)
 GEOS runtime version: 3.3.6-CAPI-1.7.6
 Polygon checking: TRUE

> sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: x86_64-pc-mingw32/x64 (64-bit)

Unfortunately I'm not able to open the svn link you sent me

Paolo



________________________________________
From: [hidden email] [[hidden email]] on behalf of Roger Bivand [[hidden email]]
Sent: 06 February 2013 09:19
To: [hidden email]
Subject: Re: [geos-devel] troubles with gPolygonize

This is a question about the use of the R package rgeos, which provides GEOS
for sp classes. Consequently, this list is not a good choice; the R-sig-geo
list would have been better. You have also not provided version information
on rgeos, GEOS, or R; the two first are shown when rgeos is loaded, the
latter as output from sessionInfo().

The problem was an assumption in the R code providing IDs for the output
objects, not in GEOS. A fix has been committed to the R-Forge SVN repository
for rgeos, together with your case in the examples for the function. If you
can, please check out the source:

svn checkout svn://svn.r-forge.r-project.org/svnroot/rgeos/

and report back on whether the fix also works for your real use case.

Roger


Masucci, A wrote

> Hi,
> gPolygonize doesn't work with some simple geometries.
> Here is an example:
>
>> LS = list(
> + readWKT("LINESTRING (425963 576719, 425980 576703)"),
> + readWKT("LINESTRING (425963 576719, 425882 577073)"),
> + readWKT("LINESTRING (425980 576703, 426082 577072)"),
> + readWKT("LINESTRING (425882 577073, 426082 577072)"),
> + readWKT("LINESTRING (426138 577068, 426082 577072)"),
> + readWKT("LINESTRING (426138 577068, 426420 577039)"),
> + readWKT("LINESTRING (426420 577039, 426554 576990)"),
> + readWKT("LINESTRING (426751 576924, 426776 576823)"),
> + readWKT("LINESTRING (426751 576924, 426783 576919)"),
> + readWKT("LINESTRING (426751 576924, 426714 576953)"),
> + readWKT("LINESTRING (426776 576823, 426783 576919)"),
> + readWKT("LINESTRING (426658 576966, 426554 576990)"),
> + readWKT("LINESTRING (426658 576966, 426667 577031)"),
> + readWKT("LINESTRING (426658 576966, 426714 576953)"),
> + readWKT("LINESTRING (426667 577031, 426714 576953)")
> + )
>> gPolygonize(LS)
>
> Traceback:
>  1: .Call("rgeos_polygonize", .RGEOS_HANDLE, splist, id, p4s, getCutEdges,
> PACKAGE = "rgeos")
>  2: gPolygonize(LS)
> Error in gPolygonize(LS) : caught access violation - continue with care
>
> I hope you can help me
> Kindest regards
>
> Paolo
>
> _______________________________________________
> geos-devel mailing list

> geos-devel@.osgeo

> http://lists.osgeo.org/mailman/listinfo/geos-devel





-----
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/troubles-with-gPolygonize-tp5032205p5032412.html
Sent from the GEOS Developers mailing list archive at Nabble.com.
_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: troubles with gPolygonize

Roger Bivand
rgeos 0.2-13 is now submitted to CRAN, should be built as a Windows binary shortly, probably also for your R 2.14.

Roger
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: troubles with gPolygonize

Masucci, A
Roger,
thank you very much

Paolo

________________________________________
From: [hidden email] [[hidden email]] on behalf of Roger Bivand [[hidden email]]
Sent: 06 February 2013 17:13
To: [hidden email]
Subject: Re: [geos-devel] troubles with gPolygonize

rgeos 0.2-13 is now submitted to CRAN, should be built as a Windows binary
shortly, probably also for your R 2.14.

Roger



-----
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/troubles-with-gPolygonize-tp5032205p5032540.html
Sent from the GEOS Developers mailing list archive at Nabble.com.
_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: troubles with gPolygonize

Masucci, A
In reply to this post by Roger Bivand
Dear Roger,
I found that the bug was fixed, thanks so much.
Now it works great with WKT lines, while it crashes if the lines are given as SpatialLines, but it's not an issue to feed it with WKT
Best regards

Paolo


________________________________________
From: [hidden email] [[hidden email]] on behalf of Roger Bivand [[hidden email]]
Sent: 06 February 2013 17:13
To: [hidden email]
Subject: Re: [geos-devel] troubles with gPolygonize

rgeos 0.2-13 is now submitted to CRAN, should be built as a Windows binary
shortly, probably also for your R 2.14.

Roger



-----
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/troubles-with-gPolygonize-tp5032205p5032540.html
Sent from the GEOS Developers mailing list archive at Nabble.com.
_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel
Reply | Threaded
Open this post in threaded view
|

Re: troubles with gPolygonize

Roger Bivand
Thanks for reporting back. I don't think you mean "crash" in the R sense (error exit from the R interpreter); if the first argument to gPolygonize() is not a list of SpatialLines objects - in your case it is:

> table(sapply(LS, class))

SpatialLines
          15

but a SpatialLines object, the function returns NULL if it cannot be made into a polygon. There are no WKT objects involved, as readWKT() returns a Spatial* object with its specific class determined by the type of the WKT string.

Roger

Masucci, A wrote
Dear Roger,
I found that the bug was fixed, thanks so much.
Now it works great with WKT lines, while it crashes if the lines are given as SpatialLines, but it's not an issue to feed it with WKT
Best regards

Paolo


________________________________________
From: [hidden email] [[hidden email]] on behalf of Roger Bivand [[hidden email]]
Sent: 06 February 2013 17:13
To: [hidden email]
Subject: Re: [geos-devel] troubles with gPolygonize

rgeos 0.2-13 is now submitted to CRAN, should be built as a Windows binary
shortly, probably also for your R 2.14.

Roger



-----
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/troubles-with-gPolygonize-tp5032205p5032540.html
Sent from the GEOS Developers mailing list archive at Nabble.com.
_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel


_______________________________________________
geos-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/geos-devel
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway