[R-sig-Geo] selecting a subset of a raster layer

Erin Hodgess er|nm@hodge@@ @end|ng |rom gm@||@com
Tue Aug 2 17:48:10 CEST 2022


Wow!  This is great!

Thank you so much.

Sincerely,
Erin

On Tue, Aug 2, 2022 at 11:47 AM Ahmadou Dicko <dicko.ahmadou using gmail.com>
wrote:

> Hi Erin,
>
> Not sure if understood well the problem, but it looks like a crop can do
> the job here.
> You'll need to build a rectangular polygon from the desired extent
> (sf::st_bbox -> SpatialPolygon), and crop your raster with it.
>
> Best,
> Ahmadou
>
>
>
>
>
> On Tue, Aug 2, 2022 at 3:37 PM Erin Hodgess <erinm.hodgess using gmail.com>
> wrote:
>
>> Hello!
>>
>> I have a raster with the following bbox:
>>
>> > bbox(import_raster)
>>           min       max
>> s1 -180.00417 180.00417
>> s2  -65.00417  75.00417
>>
>> I would like to create a subset of that raster layer with the following
>> dimensions:
>> > r
>> class      : RasterLayer
>> dimensions : 180, 360, 64800  (nrow, ncol, ncell)
>> resolution : 0.02222147, 0.003172611  (x, y)
>> extent     : -90.4184, -82.41867, 41.69613, 42.2672  (xmin, xmax, ymin,
>> ymax)
>> crs        : +proj=longlat +datum=WGS84 +no_defs
>>
>> Is there an easy way to do this, please?
>>
>> I did a "which" subset, but it produced an incredibly long vector.
>>
>> Any suggestions much appreciated.
>>
>> Sincerely,
>> Erin
>>
>>
>> Erin Hodgess, PhD
>> mailto: erinm.hodgess using gmail.com
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>>
>
> --
> Ahmadou H. DICKO, PhD
>
> Statistical consultant
> Mobile: (+221) 77 123 81 69
> Skype: dicko.ahmadou.h
> Twitter : @dickoah
> Gitlab: gitlab/dickoa
> Github: github/dickoa
>
-- 
Erin Hodgess, PhD
mailto: erinm.hodgess using gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list