Skip to main content
expanded the raster information
Source Link
la_leche
  • 433
  • 3
  • 12
Formal class 'RasterLayer' [package "raster"] with 12 slots
  ..@ file    :Formal RasterLayerclass '.RasterFile' [package "raster"] with 13 slots
band  .. .. ..@ name        : 1chr "C:\\Users\\me\\Documents\\traffic\\bing\\images\\mymap.png"
  (of.. .. ..@ datanotation: chr "INT1U"
  .. .. ..@ byteorder   : chr "little"
  .. .. ..@ nodatavalue : num -Inf
  .. .. ..@ NAchanged   : logi FALSE
  .. .. ..@ nbands      : int 3 
  bands).. .. ..@ bandorder   : chr "BIL"
dimensions  .. .. ..@ offset      : 1280,int 0
  .. .. ..@ toptobottom : logi TRUE
  .. .. ..@ blockrows   : int 1
  .. .. ..@ blockcols   : int 2560, 
 3276800 .. .. (nrow,..@ ncol,driver ncell     : chr "gdal"
  .. .. ..@ open        : logi FALSE
  ..@ data    :Formal class '.SingleLayerData' [package "raster"] with 13 slots
  .. .. ..@ values    : logi(0) 
resolution  .. .. ..@ offset    : num 0
  .. .. ..@ gain      : num 1,
  .. .. ..@ inmemory  : logi FALSE
  .. .. ..@ fromdisk  : logi TRUE
  .. .. ..@ isfactor  : logi FALSE
  .. .. ..@ attributes: list()
  .. .. ..@ haveminmax: logi TRUE
  .. .. ..@ min       : num 0
  .. .. ..@ max       : num 255
  .. .. ..@ band      : int 1
  .. .. ..@ unit      : chr ""
  .. .. ..@ names     : chr "mymap"
  ..@ legend  :Formal class '.RasterLegend' [package "raster"] with 5 slots
  .. .. ..@ type      : chr(x,0) y
  .. .. ..@ values    : logi(0) 
extent  .. .. ..@ color     : logi(0,) 2560,
  .. .. ..@ names     : logi(0,) 1280
  .. .. ..@ colortable: logi(0) 
  ..@ title   : chr(0) 
  ..@ extent  :Formal class 'Extent' [package "raster"] with 4 slots
  .. .. ..@ xmin,: num 0
  .. .. ..@ xmax,: num 2560
  .. .. ..@ ymin,: num 0
  .. .. ..@ ymax): num 1280
coord  ..@ refrotated : logi FALSE
  ..@ rotation:Formal +proj=mercclass +a=6378137'.Rotation' +b=6378137[package +lat_ts=0"raster"] +lon_0=0with +x_0=02 +y_0=0slots
 +k=1 +units=m.. +nadgrids=@null.. +no_defs..@ geotrans: num(0) 
data source .. .. ..@ transfun:function C()  
  ..@ ncols   :\Users\me\Documents\traffic\bing\images\mymap int 2560
  .png.@ nrows   : int 1280
names  ..@ crs     :Formal mymap
valuesclass 'CRS' [package "sp"] with 1 slot
  .. .. ..@ projargs: 0,chr 255"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs"
  ..@ history : list(min,)
 max ..@ z       : list()
class       : RasterLayer 
band        : 1  (of  3  bands)
dimensions  : 1280, 2560, 3276800  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 2560, 0, 1280  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs 
data source : C:\Users\me\Documents\traffic\bing\images\mymap.png 
names       : mymap
values      : 0, 255  (min, max)
Formal class 'RasterLayer' [package "raster"] with 12 slots
  ..@ file    :Formal class '.RasterFile' [package "raster"] with 13 slots
  .. .. ..@ name        : chr "C:\\Users\\me\\Documents\\traffic\\bing\\images\\mymap.png"
  .. .. ..@ datanotation: chr "INT1U"
  .. .. ..@ byteorder   : chr "little"
  .. .. ..@ nodatavalue : num -Inf
  .. .. ..@ NAchanged   : logi FALSE
  .. .. ..@ nbands      : int 3 
  .. .. ..@ bandorder   : chr "BIL"
  .. .. ..@ offset      : int 0
  .. .. ..@ toptobottom : logi TRUE
  .. .. ..@ blockrows   : int 1
  .. .. ..@ blockcols   : int 2560 
  .. .. ..@ driver      : chr "gdal"
  .. .. ..@ open        : logi FALSE
  ..@ data    :Formal class '.SingleLayerData' [package "raster"] with 13 slots
  .. .. ..@ values    : logi(0) 
  .. .. ..@ offset    : num 0
  .. .. ..@ gain      : num 1
  .. .. ..@ inmemory  : logi FALSE
  .. .. ..@ fromdisk  : logi TRUE
  .. .. ..@ isfactor  : logi FALSE
  .. .. ..@ attributes: list()
  .. .. ..@ haveminmax: logi TRUE
  .. .. ..@ min       : num 0
  .. .. ..@ max       : num 255
  .. .. ..@ band      : int 1
  .. .. ..@ unit      : chr ""
  .. .. ..@ names     : chr "mymap"
  ..@ legend  :Formal class '.RasterLegend' [package "raster"] with 5 slots
  .. .. ..@ type      : chr(0) 
  .. .. ..@ values    : logi(0) 
  .. .. ..@ color     : logi(0) 
  .. .. ..@ names     : logi(0) 
  .. .. ..@ colortable: logi(0) 
  ..@ title   : chr(0) 
  ..@ extent  :Formal class 'Extent' [package "raster"] with 4 slots
  .. .. ..@ xmin: num 0
  .. .. ..@ xmax: num 2560
  .. .. ..@ ymin: num 0
  .. .. ..@ ymax: num 1280
  ..@ rotated : logi FALSE
  ..@ rotation:Formal class '.Rotation' [package "raster"] with 2 slots
  .. .. ..@ geotrans: num(0) 
  .. .. ..@ transfun:function ()  
  ..@ ncols   : int 2560
  ..@ nrows   : int 1280
  ..@ crs     :Formal class 'CRS' [package "sp"] with 1 slot
  .. .. ..@ projargs: chr "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs"
  ..@ history : list()
  ..@ z       : list()
added pictures and code as requested in comments
Source Link
la_leche
  • 433
  • 3
  • 12

I have a screenshotstatic image of mapa Bing maps tile (Mercator EPSG: 3857) with satellite overlay in PNG format. I read the PNG as a raster and georeferenced it in R by setting the corner coordinates using the raster package.

HoweverHere is the original PNG. enter image description here

r <- raster("mymap.png")
# add coordinate system
crs(r) <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
# plot raster
plot(r)
# try some different colors, not true color though
colortable(r) <- rainbow(256)
plot(r)

enter image description here However, when I try to plot the raster, I get some kooky colors. And when I export the raster as a GeoTIFFcan change the raster is in grayscale.

How do I displaycolortable, but it doesn't match the true colorscolor of the original PNG? And what. What is happening to the "color values" when I read a PNG with the raster package?

Here is the raster:

class       : RasterLayer 
band        : 1  (of  3  bands)
dimensions  : 1280, 2560, 3276800  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 2560, 0, 1280  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs 
data source : C:\Users\me\Documents\traffic\bing\images\mymap.png 
names       : mymap
values      : 0, 255  (min, max)

I'm not entirely sure why it says there are 3 bands when this is just a single band PNG image.

I have a screenshot of map tile (Mercator EPSG: 3857) with satellite overlay in PNG format. I read the PNG as a raster and georeferenced it in R by setting the corner coordinates using the raster package.

However, when I try to plot the raster, I get some kooky colors. And when I export the raster as a GeoTIFF the raster is in grayscale.

How do I display the true colors of the original PNG? And what is happening to the "color values" when I read a PNG with the raster package?

Here is the raster:

class       : RasterLayer 
band        : 1  (of  3  bands)
dimensions  : 1280, 2560, 3276800  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 2560, 0, 1280  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs 
data source : C:\Users\me\Documents\traffic\bing\images\mymap.png 
names       : mymap
values      : 0, 255  (min, max)

I have a static image of a Bing maps tile (Mercator EPSG: 3857) with satellite overlay in PNG format. I read the PNG as a raster and georeferenced it in R by setting the corner coordinates using the raster package.

Here is the original PNG. enter image description here

r <- raster("mymap.png")
# add coordinate system
crs(r) <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
# plot raster
plot(r)
# try some different colors, not true color though
colortable(r) <- rainbow(256)
plot(r)

enter image description here However, when I try to plot the raster, I get some kooky colors. I can change the colortable, but it doesn't match the true color of the PNG. What is happening to the "color values" when I read a PNG with the raster package?

Here is the raster:

class       : RasterLayer 
band        : 1  (of  3  bands)
dimensions  : 1280, 2560, 3276800  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 2560, 0, 1280  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs 
data source : C:\Users\me\Documents\traffic\bing\images\mymap.png 
names       : mymap
values      : 0, 255  (min, max)

I'm not entirely sure why it says there are 3 bands when this is just a single band PNG image.

made title more specific
Link
la_leche
  • 433
  • 3
  • 12

Displaying PNG as R: Display single band raster in Rtrue color

Source Link
la_leche
  • 433
  • 3
  • 12
Loading