Re: [R-sig-Geo] Strange spatial reference system netCDF [stars and sf functions not working now]

2020-02-19 Thread Maurizio Marchi
I’m sorry for being the smoking gun but looking at the issue climatological 
data seems to be difficult to be handled in R...
Yes the issue is connected to the GDAL version. I can’t remember exactly but 
I’m sure it wasn’t the versions I have now and posted before...
I did a trick using proj4 package and some handmade stuff but not really GIS ;) 
However my code was not working on other systems so I’m far away from a real 
solution...
But the main question is Why RCM are delivered in this awful CRS!? 
All my bests 

-- 
Maurizio Marchi,
PhD Forest Science - Ecological Mathematics 
Researcher
CNR - Institute of Biosciences and BioResources (IBBR), Florence division 
(Italy)
SkypeID: maurizioxyz
http://www.ibbr.cnr.it/ibbr/info/people/maurizio-marchi
#--#
Annals of Silvicultural Research Associated Editor
EUFGIS National Focal Point for Italy (www.eufgis.org)
Scopus Author ID: 57188626512
ResearcherID: T-3813-2019
http://b4est.eu/ project
[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Strange spatial reference system netCDF [stars and sf functions not working now]

2020-02-18 Thread Roger Bivand

On Tue, 18 Feb 2020, maurizio marchi wrote:


Dear all,
Thanks for your time. Unfortunately the solution the community (i.e.
Edzer Pebesma, https://github.com/r-spatial/stars/issues/175) is not
working anymore. Does anyone knows why the code is now broken? Here the
output of the old R code...

/f<-"tasmax_rcp85_land-rcm_eur_12km_01_mon_198012-208011.nc"//
//library(stars)//
//  Loading required package: abind//
//  Loading required package: sf//
//  Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1//


This seems to be the "smoking gun" - when the code last ran without error, 
which versions of GDAL and PROJ were you using? See below for the 
PROJ-related error message.



//r<-read_ncdf(f, ncsub = cbind(start = c(1, 1, 1, 1), count = c(418,
406, 3, 1)), eps=1e-3)//
//  no 'var' specified, using tasmax//
//  other available variables://
//  rotated_latitude_longitude, ensemble_member, time, time_bnds,
grid_latitude, grid_latitude_bnds, grid_longitude, grid_longitude_bnds,
ensemble_member_id, month_number, year, mm//
//  Error in UseMethod("GPFN") : //
//  no applicable method for 'GPFN' applied to an object of class
"rotated_latitude_longitude"//
//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)//
//  Warning messages://
//  1: In CPL_crs_from_proj4string(x) ://
//    GDAL Error 1: PROJ: proj_as_wkt: DerivedGeographicCRS can only be
exported to WKT2//
//  2: In CPL_crs_from_proj4string(x) ://
//    GDAL Error 1: PROJ: proj_as_wkt: DerivedGeographicCRS can only be
exported to WKT2//


... here ... is the use of code that will vary by GDAL and PROJ versions.

Roger



//r0 = stars:::st_transform_proj.stars(r, 4326)//
//  Error: invalid crs: , reason: generic error of unknown origin//
//  proj_create: unrecognized format / unknown name//
//r0//
//Error: object 'r0' not found//
/
All my bests



--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no
https://orcid.org/-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0J=en___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Strange spatial reference system netCDF [stars and sf functions not working now]

2020-02-18 Thread maurizio marchi
Dear all,
Thanks for your time. Unfortunately the solution the community (i.e. 
Edzer Pebesma, https://github.com/r-spatial/stars/issues/175) is not 
working anymore. Does anyone knows why the code is now broken? Here the 
output of the old R code...

/f<-"tasmax_rcp85_land-rcm_eur_12km_01_mon_198012-208011.nc"//
//library(stars)//
//  Loading required package: abind//
//  Loading required package: sf//
//  Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1//
//r<-read_ncdf(f, ncsub = cbind(start = c(1, 1, 1, 1), count = c(418, 
406, 3, 1)), eps=1e-3)//
//  no 'var' specified, using tasmax//
//  other available variables://
//  rotated_latitude_longitude, ensemble_member, time, time_bnds, 
grid_latitude, grid_latitude_bnds, grid_longitude, grid_longitude_bnds, 
ensemble_member_id, month_number, year, mm//
//  Error in UseMethod("GPFN") : //
//  no applicable method for 'GPFN' applied to an object of class 
"rotated_latitude_longitude"//
//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)//
//  Warning messages://
//  1: In CPL_crs_from_proj4string(x) ://
//    GDAL Error 1: PROJ: proj_as_wkt: DerivedGeographicCRS can only be 
exported to WKT2//
//  2: In CPL_crs_from_proj4string(x) ://
//    GDAL Error 1: PROJ: proj_as_wkt: DerivedGeographicCRS can only be 
exported to WKT2//
//r0 = stars:::st_transform_proj.stars(r, 4326)//
//  Error: invalid crs: , reason: generic error of unknown origin//
//  proj_create: unrecognized format / unknown name//
//r0//
//Error: object 'r0' not found//
/
All my bests
-- 
*Maurizio Marchi,
PhD Forest Science - Ecological Mathematics*
Researcher
CNR - Institute of Biosciences and BioResources (IBBR), Florence 
division (Italy)
SkypeID: maurizioxyz
http://ibbr.cnr.it/ibbr/info/people/maurizio-marchi
#--#
EUFGIS National Focal Point for Italy (www.eufgis.org)
Scopus Author ID: 57188626512
ResearcherID: T-3813-2019
http://b4est.eu/ project
/...CPUs don't need to sleep.../

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Strange spatial reference system netCDF

2019-05-05 Thread Maurizio Marchi
Great, you were right. After adding the ubuntugis-unstable repository to my
system I got the same setup: Linking to GEOS 3.7.0, GDAL 2.4.0, PROJ 5.2.0
And now everithing is fine!
Thanks a lot
Now I'm working to save this new R object in a new netCDF file but I will
see it on my own, no problem

--
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=_2X6fu8J


[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Strange spatial reference system netCDF

2019-05-03 Thread Edzer Pebesma
Dear Maurizio,

an attempt to do something along this line is:

f = "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
> 
> 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=_2X6fu8J
> 
> 
>   [[alternative HTML version deleted]]
> 
> ___
> R-sig-Geo mailing list
> R-sig-Geo@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


pEpkey.asc
Description: application/pgp-keys
___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Strange spatial reference system netCDF

2019-05-02 Thread Maurizio Marchi
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

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=_2X6fu8J


[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo