[R-sig-Geo] R-sig-Geo Digest, Vol 189, Issue 3
Edzer Pebesma
edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Sat May 4 18:40:44 CEST 2019
The problem might be in the PROJ version; PROJ has seen a lot of
development the last few years. I'm on
Linking to GEOS 3.7.0, GDAL 2.4.0, PROJ 5.2.0
Since you are on ubuntu, it should be pretty easy to get that too; see
sf github pages for installing from ppa:ubuntugis-unstable:
https://github.com/r-spatial/sf
On 5/4/19 5:19 PM, Maurizio Marchi wrote:
> Dear Prof.
> Many thanks for your quick reply. Anyway I still have some differences
> with your output, as well as some errors in the R console. Actually,
> practically speaking, in my .png plot (attached) the origin of the axes
> is still in Germany and the left and right borders of the image are
> still rectilinear.
>
> *Here my R output using your code with the sessionInfo() at the end. I
> hope it helps*
>
> R version 3.6.0 (2019-04-26) -- "Planting of a Tree" Copyright (C) 2019
> The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu
> (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You
> are welcome to redistribute it under certain conditions. Type
> 'license()' or 'licence()' for distribution details. Natural language
> support but running in an English locale R is a collaborative project
> with many contributors. Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications. Type
> 'demo()' for some demos, 'help()' for on-line help, or 'help.start()'
> for an HTML browser interface to help. Type 'q()' to quit R. > f =
> 'tas_rcp85_land-rcm_eur_12km_01_mon_198012-208011.nc
> <http://tas_rcp85_land-rcm_eur_12km_01_mon_198012-208011.nc>' >
> library(stars) Loading required package: abind Loading required package:
> sf Linking to GEOS 3.6.2, GDAL 2.2.3, PROJ 4.9.3 > r = read_ncdf(f,
> ncsub = cbind(start = c(1, 1, 1, 1), count = c(418, 406, 3, 1)),
> eps=1e-3) > rx = read_stars(f, proxy = TRUE) # only for the crs! Warning
> messages: 1: In CPL_read_gdal(as.character(x), as.character(options),
> as.character(driver), : GDAL Message 1: The dataset has several
> variables that could be identified as vector fields, but not all share
> the same primary dimension. Consequently they will be ignored. 2: In
> CPL_read_gdal(as.character(x), as.character(options),
> as.character(driver), : GDAL Message 1: dimension #1 (time) is not a
> Time dimension. 3: In CPL_read_gdal(as.character(x),
> as.character(options), as.character(driver), : GDAL Message 1: dimension
> #0 (ensemble_member) is not a Time dimension. > st_crs(r) = st_crs(rx) >
> r0 = stars:::st_transform_proj.stars(r, 4326) > plot(r0[,,,1], border =
> NA, axes = TRUE, reset = FALSE) Warning messages: 1: In
> classInt::classIntervals(na.omit(values), min(nbreaks - 1, n.unq), : N
> is large, and some styles will run very slowly; sampling imposed 2: In
> st_is_longlat(x) : bounding box has potentially an invalid value range
> for longlat data 3: In st_is_longlat(x) : bounding box has potentially
> an invalid value range for longlat data 4: In st_is_longlat(x) :
> bounding box has potentially an invalid value range for longlat data 5:
> In st_is_longlat(x) : bounding box has potentially an invalid value
> range for longlat data 6: In st_is_longlat(x) : bounding box has
> potentially an invalid value range for longlat data >
> library(rnaturalearth) > plot(ne_coastline(returnclass = "sf"), add =
> TRUE, col = 'orange') Warning message: In
> plot.sf(ne_coastline(returnclass = "sf"), add = TRUE, col = "orange") :
> ignoring all but the first attribute > sessionInfo() R version 3.6.0
> (2019-04-26) Platform: x86_64-pc-linux-gnu (64-bit) Running under:
> Ubuntu 18.04.2 LTS Matrix products: default BLAS:
> /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK:
> /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1 locale: [1]
> LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=it_IT.UTF-8
> LC_COLLATE=en_GB.UTF-8 LC_MONETARY=it_IT.UTF-8 LC_MESSAGES=en_GB.UTF-8
> [7] LC_PAPER=it_IT.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
> LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages:
> [1] stats graphics grDevices utils datasets methods base other attached
> packages: [1] rnaturalearth_0.1.0 stars_0.3-1 sf_0.7-4 abind_1.4-5
> loaded via a namespace (and not attached): [1] Rcpp_1.0.1 magrittr_1.5
> units_0.6-3 tidyselect_0.2.5 lattice_0.20-38 R6_2.4.0 rlang_0.3.4 [8]
> rnaturalearthdata_0.2.0 dplyr_0.8.0.1 tools_3.6.0 parallel_3.6.0
> grid_3.6.0 KernSmooth_2.23-15 ncmeta_0.0.4 [15] e1071_1.7-1 DBI_1.0.0
> class_7.3-15 assertthat_0.2.1 tibble_2.1.1 RNetCDF_1.9-1 crayon_1.3.4
> [22] tidyr_0.8.3 purrr_0.3.2 PCICt_0.5-4.1 glue_1.3.1 sp_1.3-1
> compiler_3.6.0 pillar_1.3.1 [29] classInt_0.3-3 pkgconfig_2.0.2
>
>
> --
> Maurizio Marchi,
> PhD Forest Science - Ecological Mathematics
> Skype ID: maurizioxyz
> linux user 552742
> #EUFGIS national Focal point for Italy
> #Annals of Silvicultural Research Associated Editor
> https://scholar.google.it/citations?hl=en&user=_2X6fu8AAAAJ
> <https://scholar.google.it/citations?hl=en&user=_2X6fu8AAAAJ*>
>
>
>
>
> Il giorno sab 4 mag 2019 alle ore 12:10 <r-sig-geo-request using r-project.org
> <mailto:r-sig-geo-request using r-project.org>> ha scritto:
>
> Send R-sig-Geo mailing list submissions to
> r-sig-geo using r-project.org <mailto:r-sig-geo using r-project.org>
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> or, via email, send a message with subject or body 'help' to
> r-sig-geo-request using r-project.org
> <mailto:r-sig-geo-request using r-project.org>
>
> You can reach the person managing the list at
> r-sig-geo-owner using r-project.org
> <mailto:r-sig-geo-owner using r-project.org>
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-Geo digest..."
>
>
> Today's Topics:
>
> 1. Re: Strange spatial reference system netCDF (Edzer Pebesma)
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 3 May 2019 16:58:01 +0200
> From: Edzer Pebesma <edzer.pebesma using uni-muenster.de
> <mailto:edzer.pebesma using uni-muenster.de>>
> To: r-sig-geo using r-project.org <mailto:r-sig-geo using r-project.org>
> Subject: Re: [R-sig-Geo] Strange spatial reference system netCDF
> Message-ID: <82193e8b-8fcc-3308-7874-a22ae6985c01 using uni-muenster.de
> <mailto:82193e8b-8fcc-3308-7874-a22ae6985c01 using uni-muenster.de>>
> Content-Type: text/plain; charset="utf-8"
>
> Dear Maurizio,
>
> an attempt to do something along this line is:
>
> f = "tas_rcp85_land-rcm_eur_12km_01_mon_198012-208011.nc
> <http://tas_rcp85_land-rcm_eur_12km_01_mon_198012-208011.nc>"
> library(stars)
> r = read_ncdf(f, ncsub = cbind(start = c(1, 1, 1, 1), count = c(418,
> 406, 3, 1)), eps=1e-3)
> rx = read_stars(f, proxy = TRUE) # only for the crs!
> st_crs(r) = st_crs(rx)
> r0 = stars:::st_transform_proj.stars(r, 4326)
> png("x.png")
> plot(r0[,,,1], border = NA, axes = TRUE, reset = FALSE)
> library(rnaturalearth)
> plot(ne_coastline(returnclass = "sf"), add = TRUE, col = 'orange')
>
> Note that the output object time stamps respect the 360-day calendar
> (using pkg PCICt).
>
> You'll find some discussion, and the output image, here:
> https://github.com/r-spatial/stars/issues/175
>
> Feel free to post follow-up questions here, or to github.
>
> On 5/2/19 6:49 PM, Maurizio Marchi wrote:
> > Dear list,
> > I'm working with large netCDF files from the UK Climate
> Projections portal (
> > https://www.metoffice.gov.uk/research/collaboration/ukcp). More in
> detail
> > I'm reading with the ncdf4 library this
> >
> <http://data.ceda.ac.uk/badc/ukcp18/data/land-rcm/eur/12km/rcp85/01/tas/mon/latest/>
> > file. Once loaded O can easily handle it but it is a strange reference
> > system as follow:
> > rotated_latitude_longitude[]
> > grid_mapping_name: rotated_latitude_longitude
> > longitude_of_prime_meridian: 0
> > earth_radius: *6371229*
> > grid_north_pole_latitude: 39.25
> > grid_north_pole_longitude: 198
> > north_pole_grid_longitude: 0
> > If I load the .nc file in QGIS I see that the SR is "+proj=longlat
> > +a=6371229 +b=6371229 +no_defs" where the values associated to *a* and
> > *b* variables
> > are the earth radius. Even if QGIS can read it, the raw file isn't
> > projected properly (it seems tha QGIS is not able to handle such
> > projection).
> > Finally, using the ncdf4+raster libraries, I can easily generate e
> raster
> > image but then I'm not able to understand I could I re project
> this raster
> > in WGS84 reference system.
> > Any helps?
> > Cheers
> >
> > --
> > Maurizio Marchi,
> > PhD Forest Science - Ecological Mathematics
> > Skype ID: maurizioxyz
> > linux user 552742
> > #EUFGIS national Focal point for Italy
> > #Annals of Silvicultural Research Associated Editor
> > https://scholar.google.it/citations?hl=en&user=_2X6fu8AAAAJ
> > <https://scholar.google.it/citations?hl=en&user=_2X6fu8AAAAJ*>
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org <mailto:R-sig-Geo using r-project.org>
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Edzer Pebesma
> Institute for Geoinformatics
> Heisenbergstrasse 2, 48151 Muenster, Germany
> Phone: +49 251 8333081
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: pEpkey.asc
> Type: application/pgp-keys
> Size: 2472 bytes
> Desc: not available
> URL:
> <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190503/34eee3d8/attachment-0001.bin>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org <mailto:R-sig-Geo using r-project.org>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> ------------------------------
>
> End of R-sig-Geo Digest, Vol 189, Issue 3
> *****************************************
>
--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2472 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190504/84a5b659/attachment.bin>
More information about the R-sig-Geo
mailing list