[R-sig-Geo] RES: Import Part of a GeoTiff using readGDAL{rgdal}
Michael Sumner
mdsumner at gmail.com
Fri Jul 23 15:52:52 CEST 2010
I don't know what you mean by "band data structure" and "original
colors". I just have the generic (ice/cell registered) Etopo1 which is
elevation values as 16-bit integers. Perhaps you could describe the
actual file you have more, where you got it, and how you have used it
before.
Cheers, Mike.
On Fri, Jul 23, 2010 at 8:43 PM, Rodrigo Aluizio <r.aluizio at gmail.com> wrote:
> Excellent suggestion, but I'm facing another little problem. When importing through raster{raster}, I lost the band data structure (but the data seems to still be there) which turns impossible to reproduce the original colors. Is there a way to bypass this?
>
> Thanks.
>
> Rodrigo.
>
> -----Mensagem original-----
> De: Michael Sumner [mailto:mdsumner at gmail.com]
> Enviada em: quinta-feira, 22 de julho de 2010 12:50
> Para: Rodrigo Aluizio
> Cc: R Help
> Assunto: Re: [R-sig-Geo] Import Part of a GeoTiff using readGDAL{rgdal}
>
> With readGDAL you must figure out the impled coordinates, referenced from the top left - it's confusing, but with some experimenting you will get it.
>
> But, far easier is to use the raster package, which will let you deal with the entire Etopo1 if you want by accessing the file as needed, and there are simpler methods to crop the big raster - and coerce to SpatialGridDataFrame if need be.
>
> E.g.
> ## all this works pretty fast as raster takes care of the memory
> library(raster)
> etopo1 <- raster("Etopo1.tif")
> e <- extent(-90, -32, -60, 15)
> r <- crop(etopo1, e)
> plot(r)
>
> ## if we want to enforce the full memory use as an sp object x <- as(r, "SpatialGridDataFrame")
> image(x)
> summary(x)
> Object of class SpatialGridDataFrame
> Coordinates:
> min max
> s1 -90 -32
> s2 -60 15
> Is projected: FALSE
> proj4string :
> [+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0] Number of points: 2 Grid attributes:
> cellcentre.offset cellsize cells.dim
> s1 -89.99167 0.01666667 3480
> s2 -59.99167 0.01666667 4500
> Data attributes:
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -8086 -4188 -2583 -2025 148 6494
>
>
>
> sessionInfo()
> R version 2.11.1 (2010-05-31)
> x86_64-pc-mingw32
>
> locale:
> [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C [5] LC_TIME=English_Australia.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] rgdal_0.6-27 raster_1.2-6 sp_0.9-65
>
> loaded via a namespace (and not attached):
> [1] grid_2.11.1 lattice_0.18-8 tools_2.11.1
>
> On Fri, Jul 23, 2010 at 1:14 AM, Rodrigo Aluizio <r.aluizio at gmail.com> wrote:
>> Hi List.
>>
>> I’m trying to import only a part of interest from a raster image map
>> (let say, ETOPO 1 Global Relief GeoTiff). I realize that, PROBABLY,
>> the readGDAL function can deal with my issue through the arguments:
>>
>>
>>
>> offset - Number of rows and columns from the origin (usually the upper
>> left
>> corner) to begin reading from; presently ordered (y,x) - this may
>> change
>>
>> region.dim - The number of rows and columns to read from the dataset;
>> presently ordered (y,x) - this may change
>>
>>
>>
>> But, I don’t know exactly how to specify that I want the rows (and
>> columns?) which show only South America, I do know the SA coordinate
>> limits, but not the corresponding rows.
>>
>> The real problem is that I don’t know how to use the function
>> resources properly. I’m trying to limit the region during import to
>> avoid memory limit issues, once importing the ETOPO 1 Geotiff tries to generate a huge vector.
>>
>> Really Sorry About It, Thanks for Your Patience and Attention.
>>
>>
>>
>> -------------------------------------------------------------
>>
>> MSc. <mailto:r.aluizio at gmail.com> Rodrigo Aluizio
>>
>> Centro de Estudos do Mar/UFPR
>> Laboratório de Micropaleontologia
>> Avenida Beira Mar s/n - CEP 83255-000
>> Pontal do Paraná - PR - Brasil
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>
>
>
> --
> Michael Sumner
> Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia
> e-mail: mdsumner at gmail.com
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com
More information about the R-sig-Geo
mailing list