[R] Errors in Raster to Point

Michael Sumner mdsumner at gmail.com
Tue Sep 20 10:01:38 CEST 2016


On Tue, 20 Sep 2016, 15:55 GwanSeon Kim <tatekorea at gmail.com> wrote:

> Hi, all
> I am just beginner to use R.
> I am working with TIF image file, and the information about the raster is
> following:
>
> class       : RasterLayer
> dimensions  : 11150, 21808, 243159200  (nrow, ncol, ncell)
> resolution  : 30, 30  (x, y)
> extent      : 569685, 1223925, 1513995, 1848495  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0
> +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0
> data source :
>
> C:\Users\Gwan\AppData\Local\Temp\Rtmpg506Ee\raster\r_tmp_2016-09-14_122409_6260_09589.grd
> names       : test_map
> values      : 1, 225  (min, max)
> attributes  :
>        ID OBJECTID Value Red Green Blue   Count               Class_Name
> Opacity
>  from:  0        2     1   1     0    0 5982503                     Corn
>     1
>  to  : 48      255   254   0     0    0   10336 Dbl Crop Barley/Soybeans
>     1
>
>
>
> >From this Rasterlayer, I want to convert raster to point for each pixel
> based on "Value (one of column name)" and create a raster with
> georeferenced information.
> I used code as following: RP <- rasterToPoints(KY_raster)
> However, I could not get the points and have an error message "cannot
> allocate vector of size 5.4 Gb" and "Your computer is low on memory. Save
> your files and close these programs".
> Could someone please help me how I can convert to raster to points??
> Best,
>


The First question is why? The point (centre)coordinates of every pixel are
massively redundant since they are a simple function of cell index and the
raster's extent.

You might try as.data.frame with xy =TRUE to avoid any overhead in casting
to Spatial, but still it's very likely that this is just a step towards
your actual goal. Tell us what you want to do and I am sure there is a
better way.

Cheers, Mike

>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-help mailing list