Bug in raster::crop?

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

Bug in raster::crop?

Julian M. Burgos
Hello everyone,

I am getting this error when using the crop function in the raster
package.  Here is an example, sing the example in the help file:

> r <- raster(nrow=45, ncol=90)
> r[] <- 1:ncell(r)
> e <- extent(-160, 10, 30, 60)
> rc <- crop(r, e)

Error in extent(extent) : insufficient number of elements (should be 4)

I am using R version 3.4.4., and raster 2.6-7.

Many thanks,

Julian

--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
Skúlagata 4, 121 Reykjavík, Iceland
Sími/Telephone : +354-5752037
Bréfsími/Telefax:  +354-5752001
Netfang/Email: [hidden email]

_______________________________________________
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: Bug in raster::crop?

Barry Rowlingson
Works perfectly for me, with the same versions of everything:

>     r <- raster(nrow=45, ncol=90)
>      r[] <- 1:ncell(r)
>      e <- extent(-160, 10, 30, 60)
>      rc <- crop(r, e)
>
> packageVersion("raster")
[1] ‘2.6.7’
> version
               _
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          4.4

Can you get crop to work on anything?

Barry




On Tue, May 1, 2018 at 8:22 AM, Julian M. Burgos <[hidden email]
> wrote:

> Hello everyone,
>
> I am getting this error when using the crop function in the raster
> package.  Here is an example, sing the example in the help file:
>
> > r <- raster(nrow=45, ncol=90)
> > r[] <- 1:ncell(r)
> > e <- extent(-160, 10, 30, 60)
> > rc <- crop(r, e)
>
> Error in extent(extent) : insufficient number of elements (should be 4)
>
> I am using R version 3.4.4., and raster 2.6-7.
>
> Many thanks,
>
> Julian
>
> --
> Julian Mariano Burgos, PhD
> Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
> Marine and Freshwater Research Institute
> Botnsjávarsviðs / Demersal Division
> Skúlagata 4, 121 Reykjavík, Iceland
> Sími/Telephone : +354-5752037
> Bréfsími/Telefax:  +354-5752001
> Netfang/Email: [hidden email]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[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: Bug in raster::crop?

Vijay Lulla
Works for me too...with same versions of everything.  Maybe you can try e
<- extent(c(-160,10,30,60)) ?  Apparently, ?`extent` states that it needs
either a Raster, Extent, matrix, or vector of four numbers.  I don't
understand why extent(-160,10,30,60) worked for me though!

On Tue, May 1, 2018 at 3:44 AM, Barry Rowlingson <
[hidden email]> wrote:

> Works perfectly for me, with the same versions of everything:
>
> >     r <- raster(nrow=45, ncol=90)
> >      r[] <- 1:ncell(r)
> >      e <- extent(-160, 10, 30, 60)
> >      rc <- crop(r, e)
> >
> > packageVersion("raster")
> [1] ‘2.6.7’
> > version
>                _
> platform       x86_64-pc-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status
> major          3
> minor          4.4
>
> Can you get crop to work on anything?
>
> Barry
>
>
>
>
> On Tue, May 1, 2018 at 8:22 AM, Julian M. Burgos <
> [hidden email]
> > wrote:
>
> > Hello everyone,
> >
> > I am getting this error when using the crop function in the raster
> > package.  Here is an example, sing the example in the help file:
> >
> > > r <- raster(nrow=45, ncol=90)
> > > r[] <- 1:ncell(r)
> > > e <- extent(-160, 10, 30, 60)
> > > rc <- crop(r, e)
> >
> > Error in extent(extent) : insufficient number of elements (should be 4)
> >
> > I am using R version 3.4.4., and raster 2.6-7.
> >
> > Many thanks,
> >
> > Julian
> >
> > --
> > Julian Mariano Burgos, PhD
> > Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
> > Marine and Freshwater Research Institute
> > Botnsjávarsviðs / Demersal Division
> > Skúlagata 4, 121 Reykjavík, Iceland
> > Sími/Telephone : +354-5752037
> > Bréfsími/Telefax:  +354-5752001
> > Netfang/Email: [hidden email]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



--
Vijay Lulla, Ph.D.

Assistant Professor,
Dept. of Geography, IUPUI
425 University Blvd, CA-207C.
Indianapolis, IN-46202
[hidden email]

<http://vijaylulla.com>
http://vijaylulla.com

        [[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: Bug in raster::crop?

Julian M. Burgos
No, I am still getting the same error, either using
extent(c(-160,10,30,60)) or extent(-160,10,30,60).  I can crop polygons
with no problem.  The strange thing is that it was working fine until a
couple of days ago.  I am not sure what changed...


Vijay Lulla writes:

> Works for me too...with same versions of everything.  Maybe you can try e
> <- extent(c(-160,10,30,60)) ?  Apparently, ?`extent` states that it needs
> either a Raster, Extent, matrix, or vector of four numbers.  I don't
> understand why extent(-160,10,30,60) worked for me though!
>
> On Tue, May 1, 2018 at 3:44 AM, Barry Rowlingson <
> [hidden email]> wrote:
>
>> Works perfectly for me, with the same versions of everything:
>>
>> >     r <- raster(nrow=45, ncol=90)
>> >      r[] <- 1:ncell(r)
>> >      e <- extent(-160, 10, 30, 60)
>> >      rc <- crop(r, e)
>> >
>> > packageVersion("raster")
>> [1] ‘2.6.7’
>> > version
>>                _
>> platform       x86_64-pc-linux-gnu
>> arch           x86_64
>> os             linux-gnu
>> system         x86_64, linux-gnu
>> status
>> major          3
>> minor          4.4
>>
>> Can you get crop to work on anything?
>>
>> Barry
>>
>>
>>
>>
>> On Tue, May 1, 2018 at 8:22 AM, Julian M. Burgos <
>> [hidden email]
>> > wrote:
>>
>> > Hello everyone,
>> >
>> > I am getting this error when using the crop function in the raster
>> > package.  Here is an example, sing the example in the help file:
>> >
>> > > r <- raster(nrow=45, ncol=90)
>> > > r[] <- 1:ncell(r)
>> > > e <- extent(-160, 10, 30, 60)
>> > > rc <- crop(r, e)
>> >
>> > Error in extent(extent) : insufficient number of elements (should be 4)
>> >
>> > I am using R version 3.4.4., and raster 2.6-7.
>> >
>> > Many thanks,
>> >
>> > Julian
>> >
>> > --
>> > Julian Mariano Burgos, PhD
>> > Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
>> > Marine and Freshwater Research Institute
>> > Botnsjávarsviðs / Demersal Division
>> > Skúlagata 4, 121 Reykjavík, Iceland
>> > Sími/Telephone : +354-5752037
>> > Bréfsími/Telefax:  +354-5752001
>> > Netfang/Email: [hidden email]
>> >
>> > _______________________________________________
>> > R-sig-Geo mailing list
>> > [hidden email]
>> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=02%7C01%7C%7C68dbce3f524b40630f7308d5af779672%7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C636607850526029279&sdata=Zze9meBzzUJSW2sMf2Srzl4EvnNOxvntKG2X1N7WNoU%3D&reserved=0
>> >
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=02%7C01%7C%7C68dbce3f524b40630f7308d5af779672%7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C636607850526029279&sdata=Zze9meBzzUJSW2sMf2Srzl4EvnNOxvntKG2X1N7WNoU%3D&reserved=0
>>


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
Skúlagata 4, 121 Reykjavík, Iceland
Sími/Telephone : +354-5752037
Bréfsími/Telefax:  +354-5752001
Netfang/Email: [hidden email]

_______________________________________________
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: Bug in raster::crop?

Julian M. Burgos
I tried that too, but I am still getting the error.

Alzira Ramos writes:

> Maybe, you need to add raster::extent(c(-160,10,30,60))
>
> r <- raster(nrow=45, ncol=90)
> r[] <- 1:ncell(r)
> e <- raster::extent(-160, 10, 30, 60)
> rc <- crop(r, e)
>
>
> On 2 May 2018 at 10:58, Julian M. Burgos <[hidden email]> wrote:
>
>> No, I am still getting the same error, either using
>> extent(c(-160,10,30,60)) or extent(-160,10,30,60).  I can crop polygons
>> with no problem.  The strange thing is that it was working fine until a
>> couple of days ago.  I am not sure what changed...
>>
>>
>> Vijay Lulla writes:
>>
>> > Works for me too...with same versions of everything.  Maybe you can try e
>> > <- extent(c(-160,10,30,60)) ?  Apparently, ?`extent` states that it needs
>> > either a Raster, Extent, matrix, or vector of four numbers.  I don't
>> > understand why extent(-160,10,30,60) worked for me though!
>> >
>> > On Tue, May 1, 2018 at 3:44 AM, Barry Rowlingson <
>> > [hidden email]> wrote:
>> >
>> >> Works perfectly for me, with the same versions of everything:
>> >>
>> >> >     r <- raster(nrow=45, ncol=90)
>> >> >      r[] <- 1:ncell(r)
>> >> >      e <- extent(-160, 10, 30, 60)
>> >> >      rc <- crop(r, e)
>> >> >
>> >> > packageVersion("raster")
>> >> [1] ‘2.6.7’
>> >> > version
>> >>                _
>> >> platform       x86_64-pc-linux-gnu
>> >> arch           x86_64
>> >> os             linux-gnu
>> >> system         x86_64, linux-gnu
>> >> status
>> >> major          3
>> >> minor          4.4
>> >>
>> >> Can you get crop to work on anything?
>> >>
>> >> Barry
>> >>
>> >>
>> >>
>> >>
>> >> On Tue, May 1, 2018 at 8:22 AM, Julian M. Burgos <
>> >> [hidden email]
>> >> > wrote:
>> >>
>> >> > Hello everyone,
>> >> >
>> >> > I am getting this error when using the crop function in the raster
>> >> > package.  Here is an example, sing the example in the help file:
>> >> >
>> >> > > r <- raster(nrow=45, ncol=90)
>> >> > > r[] <- 1:ncell(r)
>> >> > > e <- extent(-160, 10, 30, 60)
>> >> > > rc <- crop(r, e)
>> >> >
>> >> > Error in extent(extent) : insufficient number of elements (should be
>> 4)
>> >> >
>> >> > I am using R version 3.4.4., and raster 2.6-7.
>> >> >
>> >> > Many thanks,
>> >> >
>> >> > Julian
>> >> >
>> >> > --
>> >> > Julian Mariano Burgos, PhD
>> >> > Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
>> >> > Marine and Freshwater Research Institute
>> >> > Botnsjávarsviðs / Demersal Division
>> >> > Skúlagata 4, 121 Reykjavík, Iceland
>> >> > Sími/Telephone : +354-5752037
>> >> > Bréfsími/Telefax:  +354-5752001
>> >> > Netfang/Email: [hidden email]
>> >> >
>> >> > _______________________________________________
>> >> > R-sig-Geo mailing list
>> >> > [hidden email]
>> >> > https://emea01.safelinks.protection.outlook.com/?url=
>> https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-
>> geo&data=02%7C01%7C%7C68dbce3f524b40630f7308d5af779672%
>> 7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C636607850526029279&sdata=
>> Zze9meBzzUJSW2sMf2Srzl4EvnNOxvntKG2X1N7WNoU%3D&reserved=0
>> >> >
>> >>
>> >>         [[alternative HTML version deleted]]
>> >>
>> >> _______________________________________________
>> >> R-sig-Geo mailing list
>> >> [hidden email]
>> >> https://emea01.safelinks.protection.outlook.com/?url=
>> https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-
>> geo&data=02%7C01%7C%7C68dbce3f524b40630f7308d5af779672%
>> 7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C636607850526029279&sdata=
>> Zze9meBzzUJSW2sMf2Srzl4EvnNOxvntKG2X1N7WNoU%3D&reserved=0
>> >>
>>
>>
>> --
>> Julian Mariano Burgos, PhD
>> Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
>> Marine and Freshwater Research Institute
>> Botnsjávarsviðs / Demersal Division
>> Skúlagata 4, 121 Reykjavík, Iceland
>> Sími/Telephone : +354-5752037
>> Bréfsími/Telefax:  +354-5752001
>> Netfang/Email: [hidden email]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=02%7C01%7C%7C85bc0da67b5348ac00d508d5b00bbcf1%7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C636608486825213487&sdata=9csG6vh5u1xmib0FepHuxBofg1wJLB0%2BehANGknX1VU%3D&reserved=0
>>


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
Skúlagata 4, 121 Reykjavík, Iceland
Sími/Telephone : +354-5752037
Bréfsími/Telefax:  +354-5752001
Netfang/Email: [hidden email]

_______________________________________________
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: Bug in raster::crop?

Julian M. Burgos
In reply to this post by Julian M. Burgos
I should add that I get this also when loading R with the --vanilla
flag.

Julian M. Burgos writes:

> Hello everyone,
>
> I am getting this error when using the crop function in the raster
> package.  Here is an example, sing the example in the help file:
>
>> r <- raster(nrow=45, ncol=90)
>> r[] <- 1:ncell(r)
>> e <- extent(-160, 10, 30, 60)
>> rc <- crop(r, e)
>
> Error in extent(extent) : insufficient number of elements (should be 4)
>
> I am using R version 3.4.4., and raster 2.6-7.
>
> Many thanks,
>
> Julian


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
Skúlagata 4, 121 Reykjavík, Iceland
Sími/Telephone : +354-5752037
Bréfsími/Telefax:  +354-5752001
Netfang/Email: [hidden email]

_______________________________________________
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: Bug in raster::crop? - solved

Julian M. Burgos
Ok, I removed and re-installed the raster package, and now everything
works.

Julian M. Burgos writes:

> I should add that I get this also when loading R with the --vanilla
> flag.
>
> Julian M. Burgos writes:
>
>> Hello everyone,
>>
>> I am getting this error when using the crop function in the raster
>> package.  Here is an example, sing the example in the help file:
>>
>>> r <- raster(nrow=45, ncol=90)
>>> r[] <- 1:ncell(r)
>>> e <- extent(-160, 10, 30, 60)
>>> rc <- crop(r, e)
>>
>> Error in extent(extent) : insufficient number of elements (should be 4)
>>
>> I am using R version 3.4.4., and raster 2.6-7.
>>
>> Many thanks,
>>
>> Julian


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
Skúlagata 4, 121 Reykjavík, Iceland
Sími/Telephone : +354-5752037
Bréfsími/Telefax:  +354-5752001
Netfang/Email: [hidden email]

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