Tony,

On Wed, Oct 19, 2011 at 1:13 PM, Anthony Fischbach <afischbach@usgs.gov>wrote:

> This works beautifully.
> Is there a trick to applying an intuitive color ramp to the png file


You can provide a list of colors such as that generated by
rainbow<http://127.0.0.1:14810/library/graphics/help/rainbow>
, heat.colors <http://127.0.0.1:14810/library/graphics/help/heat.colors>,
topo.colors <http://127.0.0.1:14810/library/graphics/help/topo.colors>,
terrain.colors <http://127.0.0.1:14810/library/graphics/help/terrain.colors> or
similar functions.
See ?image



> and
> setting the non-ice to null values?
>
> I have tried to assign all non ice and ice = 0 values to NA.
> This works down to the level of the extract function.
>
>
What you are doing is fine, except that here you mix up two scripts:

x[] <- extract(rr, xypole, method='bilinear')

You should be extracting from x, not rr, and assigning to the new lon/lat
raster which, obviously, cannot also be called x

Best, Robert



> ...
> fileName <-
> '
> ftp://sidads.colorado.edu/pub/DATASETS/nsidc0081_nrt_nasateam_seaice/north/nt_20110101_f17_nrt_n.bin
> '
> con <- file(filename, 'rb')
> x <- readBin(con, "raw", 300)
> x <- readBin(con,"int", size=1, signed=FALSE, 150000)
> close(con)
> # no need for newx
> x[x<251] <- (x[x<251])/250 #scale ice cover to 1
> x[x==251] <- NA # set all non-ice to NA
> x[x==0] <- NA    # set all 0 ice to NA
> x[x>251] <- NA # set all non-ice pixels to NA
>
> rr <- setValues(r, x) # place result in raster
> #plot(rr)
> rr <- writeRaster(rr, 'geoTiffFile.tif', overwrite=TRUE)
>
> x[] <- extract(rr, xypole, method='bilinear')
>
> Warning message:
> In x[] <- extract(rr, xypole, method = "bilinear") :
>  number of items to replace is not a multiple of replacement length
>
>
> -----
> Tony Fischbach, Wildlife Biologist
> Walrus Research Program
> Alaska Science Center
> U.S. Geological Survey
> 4210 University Drive
> Anchorage, AK 99508-4650
>
> AFischbach@usgs.gov
> http://alaska.usgs.gov/science/biology/walrus
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/Reading-National-Snow-and-Ice-Data-Center-binary-files-tp6882737p6910361.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

