Error using spsample on SpatialLines in Linux OS

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

Error using spsample on SpatialLines in Linux OS

Glenn Stauffer
I ran across a problem when trying to use spsample to sample points along a
line, while in a Linux OS (Mint 18.3). The following code (which works fine
in Win 10):

 

pts <- matrix(c(c(6000,6015,6021,6035,6050),
c(6000,5995,6000,6040,6095)),5,2,byrow=FALSE)
L = SpatialLines(list(Lines(list(Line(coordinates(pts))),"X")),proj4string =
CRS("+init=epsg:3071"))
plot(L)
Lsamp <- spsample(L,10,type="regular",offset=0.5) # this is the line that
generates the error

 

produces the following error:

 

Error in .C("sp_lengths", x, y, n, lengths, lonlat, PACKAGE = "sp") :
  "sp_lengths" not available for .C() for package "sp"

Could this be related to some wrong versions of certain dependencies (e.g.,
GDAL)? I don't know much about that, but I did run into that issue with
trying to install other packages (rgeos, sf). In any case, how can I prevent
this error?

 

Thanks,

Glenn

 

 


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error using spsample on SpatialLines in Linux OS

edzer
I would try reinstalling the package.

On 04/26/2018 06:31 PM, Glenn Stauffer wrote:

> I ran across a problem when trying to use spsample to sample points along a
> line, while in a Linux OS (Mint 18.3). The following code (which works fine
> in Win 10):
>
>  
>
> pts <- matrix(c(c(6000,6015,6021,6035,6050),
> c(6000,5995,6000,6040,6095)),5,2,byrow=FALSE)
> L = SpatialLines(list(Lines(list(Line(coordinates(pts))),"X")),proj4string =
> CRS("+init=epsg:3071"))
> plot(L)
> Lsamp <- spsample(L,10,type="regular",offset=0.5) # this is the line that
> generates the error
>
>  
>
> produces the following error:
>
>  
>
> Error in .C("sp_lengths", x, y, n, lengths, lonlat, PACKAGE = "sp") :
>   "sp_lengths" not available for .C() for package "sp"
>
> Could this be related to some wrong versions of certain dependencies (e.g.,
> GDAL)? I don't know much about that, but I did run into that issue with
> trying to install other packages (rgeos, sf). In any case, how can I prevent
> this error?
>
>  
>
> Thanks,
>
> Glenn
>
>  
>
>  
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error using spsample on SpatialLines in Linux OS

Glenn Stauffer
Do you mean the sp package? I should have mentioned that I already tried
that.

-----Original Message-----
From: R-sig-Geo [mailto:[hidden email]] On Behalf Of Edzer
Pebesma
Sent: Thursday, April 26, 2018 11:35 AM
To: [hidden email]
Subject: Re: [R-sig-Geo] Error using spsample on SpatialLines in Linux OS

I would try reinstalling the package.

On 04/26/2018 06:31 PM, Glenn Stauffer wrote:

> I ran across a problem when trying to use spsample to sample points
> along a line, while in a Linux OS (Mint 18.3). The following code
> (which works fine in Win 10):
>
>  
>
> pts <- matrix(c(c(6000,6015,6021,6035,6050),
> c(6000,5995,6000,6040,6095)),5,2,byrow=FALSE)
> L =
> SpatialLines(list(Lines(list(Line(coordinates(pts))),"X")),proj4string
> =
> CRS("+init=epsg:3071"))
> plot(L)
> Lsamp <- spsample(L,10,type="regular",offset=0.5) # this is the line
> that generates the error
>
>  
>
> produces the following error:
>
>  
>
> Error in .C("sp_lengths", x, y, n, lengths, lonlat, PACKAGE = "sp") :
>   "sp_lengths" not available for .C() for package "sp"
>
> Could this be related to some wrong versions of certain dependencies
> (e.g., GDAL)? I don't know much about that, but I did run into that
> issue with trying to install other packages (rgeos, sf). In any case,
> how can I prevent this error?
>
>  
>
> Thanks,
>
> Glenn
>
>  
>
>  
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error using spsample on SpatialLines in Linux OS

MacQueen, Don
The code also works fine on my Mac, and an RHEL (linux) machine to which I have access (though both are still at R 3.4.2 and sp_1.2-5).

You could focus in on the problem a bit by trying the following (I expect you will see the same error)

> sp::LineLength(pts)
[1] 123.0096

Starting with spsample(), and drilling down, eventually LineLength() calls the C function sp_lengths.  LineLength() is pretty simple, and I don't see any evidence that it depends on other packages. I'm not the expert that Edzer is, but it pretty much looks like an installation problem with sp, sorry to say. I can't think of anything else...

Sorry I'm not more helpful,
-Don


> sp::LineLength(pts, sum=FALSE)
[1] 15.81139  7.81025 42.37924 57.00877

> SpatialLinesLengths(L)
[1] 123.0096

> LinesLength(L@lines[[1]])
[1] 123.0096


> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] sp_1.2-5

loaded via a namespace (and not attached):
 [1] compiler_3.4.2     colorspace_1.3-2   scales_0.5.0.9000  lazyeval_0.2.1    
 [5] plyr_1.8.4         rgdal_1.2-13       tools_3.4.2        gtable_0.2.0      
 [9] tibble_1.3.4       Rcpp_0.12.14       ggplot2_2.2.1.9000 grid_3.4.2        
[13] rlang_0.1.2        munsell_0.4.3      lattice_0.20-35  

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 4/26/18, 9:52 AM, "R-sig-Geo on behalf of Glenn Stauffer" <[hidden email] on behalf of [hidden email]> wrote:

    Do you mean the sp package? I should have mentioned that I already tried
    that.
   
    -----Original Message-----
    From: R-sig-Geo [mailto:[hidden email]] On Behalf Of Edzer
    Pebesma
    Sent: Thursday, April 26, 2018 11:35 AM
    To: [hidden email]
    Subject: Re: [R-sig-Geo] Error using spsample on SpatialLines in Linux OS
   
    I would try reinstalling the package.
   
    On 04/26/2018 06:31 PM, Glenn Stauffer wrote:
    > I ran across a problem when trying to use spsample to sample points
    > along a line, while in a Linux OS (Mint 18.3). The following code
    > (which works fine in Win 10):
    >
    >  
    >
    > pts <- matrix(c(c(6000,6015,6021,6035,6050),
    > c(6000,5995,6000,6040,6095)),5,2,byrow=FALSE)
    > L =
    > SpatialLines(list(Lines(list(Line(coordinates(pts))),"X")),proj4string
    > =
    > CRS("+init=epsg:3071"))
    > plot(L)
    > Lsamp <- spsample(L,10,type="regular",offset=0.5) # this is the line
    > that generates the error
    >
    >  
    >
    > produces the following error:
    >
    >  
    >
    > Error in .C("sp_lengths", x, y, n, lengths, lonlat, PACKAGE = "sp") :
    >   "sp_lengths" not available for .C() for package "sp"
    >
    > Could this be related to some wrong versions of certain dependencies
    > (e.g., GDAL)? I don't know much about that, but I did run into that
    > issue with trying to install other packages (rgeos, sf). In any case,
    > how can I prevent this error?
    >
    >  
    >
    > Thanks,
    >
    > Glenn
    >
    >  
    >
    >  
    >
    >
    > [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-Geo mailing list
    > [hidden email]
    > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
    >
   
    --
    Edzer Pebesma
    Institute for Geoinformatics
    Heisenbergstrasse 2, 48151 Muenster, Germany
    Phone: +49 251 8333081
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
   

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error using spsample on SpatialLines in Linux OS

Glenn Stauffer
Thanks. I'm out of the office until Monday, but I'll try your suggestions next week. I do suspect that maybe there is some little piece missing in the installation (of sp or something else) that just didn't quite go right in Mint (I'm new to Mint).

Glenn

-----Original Message-----
From: MacQueen, Don [mailto:[hidden email]]
Sent: Friday, April 27, 2018 11:14 AM
To: Glenn Stauffer <[hidden email]>; [hidden email]
Cc: 'Edzer Pebesma' <[hidden email]>
Subject: Re: [R-sig-Geo] Error using spsample on SpatialLines in Linux OS

The code also works fine on my Mac, and an RHEL (linux) machine to which I have access (though both are still at R 3.4.2 and sp_1.2-5).

You could focus in on the problem a bit by trying the following (I expect you will see the same error)

> sp::LineLength(pts)
[1] 123.0096

Starting with spsample(), and drilling down, eventually LineLength() calls the C function sp_lengths.  LineLength() is pretty simple, and I don't see any evidence that it depends on other packages. I'm not the expert that Edzer is, but it pretty much looks like an installation problem with sp, sorry to say. I can't think of anything else...

Sorry I'm not more helpful,
-Don


> sp::LineLength(pts, sum=FALSE)
[1] 15.81139  7.81025 42.37924 57.00877

> SpatialLinesLengths(L)
[1] 123.0096

> LinesLength(L@lines[[1]])
[1] 123.0096


> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] sp_1.2-5

loaded via a namespace (and not attached):
 [1] compiler_3.4.2     colorspace_1.3-2   scales_0.5.0.9000  lazyeval_0.2.1    
 [5] plyr_1.8.4         rgdal_1.2-13       tools_3.4.2        gtable_0.2.0      
 [9] tibble_1.3.4       Rcpp_0.12.14       ggplot2_2.2.1.9000 grid_3.4.2        
[13] rlang_0.1.2        munsell_0.4.3      lattice_0.20-35  

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 4/26/18, 9:52 AM, "R-sig-Geo on behalf of Glenn Stauffer" <[hidden email] on behalf of [hidden email]> wrote:

    Do you mean the sp package? I should have mentioned that I already tried
    that.
   
    -----Original Message-----
    From: R-sig-Geo [mailto:[hidden email]] On Behalf Of Edzer
    Pebesma
    Sent: Thursday, April 26, 2018 11:35 AM
    To: [hidden email]
    Subject: Re: [R-sig-Geo] Error using spsample on SpatialLines in Linux OS
   
    I would try reinstalling the package.
   
    On 04/26/2018 06:31 PM, Glenn Stauffer wrote:
    > I ran across a problem when trying to use spsample to sample points
    > along a line, while in a Linux OS (Mint 18.3). The following code
    > (which works fine in Win 10):
    >
    >  
    >
    > pts <- matrix(c(c(6000,6015,6021,6035,6050),
    > c(6000,5995,6000,6040,6095)),5,2,byrow=FALSE)
    > L =
    > SpatialLines(list(Lines(list(Line(coordinates(pts))),"X")),proj4string
    > =
    > CRS("+init=epsg:3071"))
    > plot(L)
    > Lsamp <- spsample(L,10,type="regular",offset=0.5) # this is the line
    > that generates the error
    >
    >  
    >
    > produces the following error:
    >
    >  
    >
    > Error in .C("sp_lengths", x, y, n, lengths, lonlat, PACKAGE = "sp") :
    >   "sp_lengths" not available for .C() for package "sp"
    >
    > Could this be related to some wrong versions of certain dependencies
    > (e.g., GDAL)? I don't know much about that, but I did run into that
    > issue with trying to install other packages (rgeos, sf). In any case,
    > how can I prevent this error?
    >
    >  
    >
    > Thanks,
    >
    > Glenn
    >
    >  
    >
    >  
    >
    >
    > [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-Geo mailing list
    > [hidden email]
    > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
    >
   
    --
    Edzer Pebesma
    Institute for Geoinformatics
    Heisenbergstrasse 2, 48151 Muenster, Germany
    Phone: +49 251 8333081
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
   

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error using spsample on SpatialLines in Linux OS

Glenn Stauffer
In reply to this post by MacQueen, Don
Just to follow up. Reinstalling the sp package did not fix the problem. But, uninstalling, and then reinstalling did fix it. I don't get the error anymore.

-----Original Message-----
From: MacQueen, Don [mailto:[hidden email]]
Sent: Friday, April 27, 2018 11:14 AM
To: Glenn Stauffer <[hidden email]>; [hidden email]
Cc: 'Edzer Pebesma' <[hidden email]>
Subject: Re: [R-sig-Geo] Error using spsample on SpatialLines in Linux OS

The code also works fine on my Mac, and an RHEL (linux) machine to which I have access (though both are still at R 3.4.2 and sp_1.2-5).

You could focus in on the problem a bit by trying the following (I expect you will see the same error)

> sp::LineLength(pts)
[1] 123.0096

Starting with spsample(), and drilling down, eventually LineLength() calls the C function sp_lengths.  LineLength() is pretty simple, and I don't see any evidence that it depends on other packages. I'm not the expert that Edzer is, but it pretty much looks like an installation problem with sp, sorry to say. I can't think of anything else...

Sorry I'm not more helpful,
-Don


> sp::LineLength(pts, sum=FALSE)
[1] 15.81139  7.81025 42.37924 57.00877

> SpatialLinesLengths(L)
[1] 123.0096

> LinesLength(L@lines[[1]])
[1] 123.0096


> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] sp_1.2-5

loaded via a namespace (and not attached):
 [1] compiler_3.4.2     colorspace_1.3-2   scales_0.5.0.9000  lazyeval_0.2.1    
 [5] plyr_1.8.4         rgdal_1.2-13       tools_3.4.2        gtable_0.2.0      
 [9] tibble_1.3.4       Rcpp_0.12.14       ggplot2_2.2.1.9000 grid_3.4.2        
[13] rlang_0.1.2        munsell_0.4.3      lattice_0.20-35  

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 4/26/18, 9:52 AM, "R-sig-Geo on behalf of Glenn Stauffer" <[hidden email] on behalf of [hidden email]> wrote:

    Do you mean the sp package? I should have mentioned that I already tried
    that.
   
    -----Original Message-----
    From: R-sig-Geo [mailto:[hidden email]] On Behalf Of Edzer
    Pebesma
    Sent: Thursday, April 26, 2018 11:35 AM
    To: [hidden email]
    Subject: Re: [R-sig-Geo] Error using spsample on SpatialLines in Linux OS
   
    I would try reinstalling the package.
   
    On 04/26/2018 06:31 PM, Glenn Stauffer wrote:
    > I ran across a problem when trying to use spsample to sample points
    > along a line, while in a Linux OS (Mint 18.3). The following code
    > (which works fine in Win 10):
    >
    >  
    >
    > pts <- matrix(c(c(6000,6015,6021,6035,6050),
    > c(6000,5995,6000,6040,6095)),5,2,byrow=FALSE)
    > L =
    > SpatialLines(list(Lines(list(Line(coordinates(pts))),"X")),proj4string
    > =
    > CRS("+init=epsg:3071"))
    > plot(L)
    > Lsamp <- spsample(L,10,type="regular",offset=0.5) # this is the line
    > that generates the error
    >
    >  
    >
    > produces the following error:
    >
    >  
    >
    > Error in .C("sp_lengths", x, y, n, lengths, lonlat, PACKAGE = "sp") :
    >   "sp_lengths" not available for .C() for package "sp"
    >
    > Could this be related to some wrong versions of certain dependencies
    > (e.g., GDAL)? I don't know much about that, but I did run into that
    > issue with trying to install other packages (rgeos, sf). In any case,
    > how can I prevent this error?
    >
    >  
    >
    > Thanks,
    >
    > Glenn
    >
    >  
    >
    >  
    >
    >
    > [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-Geo mailing list
    > [hidden email]
    > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
    >
   
    --
    Edzer Pebesma
    Institute for Geoinformatics
    Heisenbergstrasse 2, 48151 Muenster, Germany
    Phone: +49 251 8333081
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
   

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo