<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="auto">Hello Roger,<div dir="auto"><br></div><div dir="auto">Thank you. I'll update the packages and try again.</div><div dir="auto"><br></div><div dir="auto">And about my doubts 2 and 3, you know If there is any problem?</div><div dir="auto"><br></div><div dir="auto">Thanks again.</div></div><div class="gmail_extra"><br><div class="gmail_quote">Em 16 de jun de 2021 04:18, Roger Bivand <Roger.Bivand@nhh.no> escreveu:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">On Tue, 15 Jun 2021, Pietro Andre Telatin Paschoalino wrote:
<br>
<br>
> 1- I tried to compare the CRS OGC with my raster (stack) and I couldn't:
<br>
>
<br>
> My raster data are CRU DATA TS 4.04 (EAST ANGLIA)
<br>
<br>
This is not a minimal reproducible example, perhaps
<br>
<br>
https://crudata.uea.ac.uk/cru/data/hrg/cru_ts_4.04/
<br>
<br>
is the source, but no specific (very small) file is indicated. Using the
<br>
224MB cru_ts4.04.2011.2019.pre.dat.nc on an updated system (rgdal, raster
<br>
and sp as CRAN, Linux, PROJ 8.0.1, GDAL 3.3.0) there is no problem.
<br>
<br>
You have rgdal 1.5-10 (CRAN has 1.5-23), sp 1.4-2 (CRAN has 1.4-5) and
<br>
raster 3.3-13 (CRAN has 3.4-10), which I will not re-install because they
<br>
are not the problem, and the current versions are available for R 3.6 on
<br>
Windows. All the debugging needed is in the output of sessionInfo().
<br>
<br>
Please report back after updating at least sp, rgdal and raster (your
<br>
raster version is also pretty outdated).
<br>
<br>
Roger Bivand
<br>
<br>
>
<br>
> rgdal::compare_CRS(CRS("OGC:CRS84"), slot(rasbrick, "crs"))
<br>
> Error in CRS("OGC:CRS84") :
<br>
> PROJ4 argument-value pairs must begin with +: OGC:CRS84
<br>
>
<br>
> I also tried it like this:
<br>
>
<br>
> rgdal::compare_CRS(CRS("+OGC:CRS84"), slot(rasbrick, "crs"))
<br>
> Error in showSRID(uprojargs, format = "PROJ", multiline = "NO") :
<br>
> Can't parse PROJ.4-style parameter string
<br>
> +OGC:CRS84
<br>
>
<br>
> could you answer me where am I wrong?
<br>
>
<br>
> When I compare a shapefile with my raster (stack) the function runs normally.
<br>
>
<br>
> 2- using:
<br>
>
<br>
> cat(wkt(shapebefore), "\n")
<br>
>
<br>
> cat(wkt(rasbrick), "\n")
<br>
>
<br>
> I saw that the order of the axis were different, but after the transformation they were the same.
<br>
>
<br>
> Any problem making shapeafter<- spTransform(shapebefore, crs(rasbrick))
<br>
>
<br>
> when are the axis different before the transformation?
<br>
>
<br>
> Ex:
<br>
>
<br>
> cat(wkt(shapebefore), "\n")
<br>
> GEOGCRS["WGS 84",
<br>
> DATUM["World Geodetic System 1984",
<br>
> ELLIPSOID["WGS 84",6378137,298.257223563,
<br>
> LENGTHUNIT["metre",1]]],
<br>
> PRIMEM["Greenwich",0,
<br>
> ANGLEUNIT["degree",0.0174532925199433]],
<br>
> CS[ellipsoidal,2],
<br>
> AXIS["latitude",north,
<br>
> ORDER[1],
<br>
> ANGLEUNIT["degree",0.0174532925199433]],
<br>
> AXIS["longitude",east,
<br>
> ORDER[2],
<br>
> ANGLEUNIT["degree",0.0174532925199433]],
<br>
> ID["EPSG",4326]]
<br>
>
<br>
>> cat(wkt(rasbrick), "\n")
<br>
> GEOGCRS["unknown",
<br>
> DATUM["World Geodetic System 1984",
<br>
> ELLIPSOID["WGS 84",6378137,298.257223563,
<br>
> LENGTHUNIT["metre",1]],
<br>
> ID["EPSG",6326]],
<br>
> PRIMEM["Greenwich",0,
<br>
> ANGLEUNIT["degree",0.0174532925199433],
<br>
> ID["EPSG",8901]],
<br>
> CS[ellipsoidal,2],
<br>
> AXIS["longitude",east,
<br>
> ORDER[1],
<br>
> ANGLEUNIT["degree",0.0174532925199433,
<br>
> ID["EPSG",9122]]],
<br>
> AXIS["latitude",north,
<br>
> ORDER[2],
<br>
> ANGLEUNIT["degree",0.0174532925199433,
<br>
> ID["EPSG",9122]]]]
<br>
>
<br>
> The order of the axis (and other parameters) of my new shape (shapeafter) is the same as the raster (rasbrick) after transformation.
<br>
>
<br>
> 3 - when I use:
<br>
>
<br>
> centroids = gCentroid(shapebefore, byid=TRUE)
<br>
>
<br>
> and
<br>
>
<br>
> centroids = gCentroid(shapeafter, byid=TRUE)
<br>
>
<br>
> why are the coordinates x and y values equal (and the values are exactly the same)?
<br>
>
<br>
> (It seems to me that both are longitude=x and latitude=y) but since the order is switched in cat(wkt(), shouldn't it be latitude=x and longitude=y in the shapebefore?
<br>
>
<br>
> if I use proj4string()
<br>
> both my shapebefore and my shapeafter are like:
<br>
>
<br>
> "+proj=longlat +datum=WGS84 +no_defs"
<br>
>
<br>
>> sessionInfo()
<br>
> R version 3.6.2 (2019-12-12)
<br>
> Platform: x86_64-w64-mingw32/x64 (64-bit)
<br>
> Running under: Windows 10 x64 (build 19042)
<br>
>
<br>
> Matrix products: default
<br>
>
<br>
> locale:
<br>
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
<br>
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
<br>
> [5] LC_TIME=English_United States.1252
<br>
>
<br>
> attached base packages:
<br>
> [1] stats graphics grDevices utils datasets methods base
<br>
>
<br>
> other attached packages:
<br>
> [1] spdep_1.1-5 sf_0.9-5 spData_0.3.8 maptools_1.0-1 xlsx_0.6.3 rgeos_0.5-3 raster_3.3-13
<br>
> [8] rgdal_1.5-10 sp_1.4-2
<br>
>
<br>
> loaded via a namespace (and not attached):
<br>
> [1] Rcpp_1.0.5 compiler_3.6.2 pillar_1.4.4 LearnBayes_2.15.1 class_7.3-15
<br>
> [6] tools_3.6.2 boot_1.3-23 nlme_3.1-142 lifecycle_0.2.0 tibble_3.0.1
<br>
> [11] lattice_0.20-41 pkgconfig_2.0.3 rlang_0.4.7 Matrix_1.2-18 DBI_1.1.0
<br>
> [16] rstudioapi_0.11 expm_0.999-5 coda_0.19-3 rJava_0.9-12 e1071_1.7-3
<br>
> [21] dplyr_1.0.0 gtools_3.8.2 generics_0.0.2 xlsxjars_0.6.1 vctrs_0.3.1
<br>
> [26] classInt_0.4-3 grid_3.6.2 tidyselect_1.1.0 glue_1.4.1 spDataLarge_0.4.1
<br>
> [31] R6_2.4.1 foreign_0.8-72 gdata_2.18.0 deldir_0.1-28 purrr_0.3.4
<br>
> [36] magrittr_1.5 gmodels_2.18.1 splines_3.6.2 MASS_7.3-51.4 codetools_0.2-16
<br>
> [41] ellipsis_0.3.1 units_0.6-7 KernSmooth_2.23-16 crayon_1.3.4
<br>
>
<br>
> Thanks.
<br>
>
<br>
> Pietro Andre Telatin Paschoalino
<br>
> Doutorando em Ci�ncias Econ�micas da Universidade Estadual de Maring� - PCE.
<br>
>
<br>
> ________________________________
<br>
> De: Roger Bivand <Roger.Bivand@nhh.no>
<br>
> Enviado: ter�a-feira, 15 de junho de 2021 15:18
<br>
> Para: Pietro Andre Telatin Paschoalino <Pietro_telato@hotmail.com>
<br>
> Assunto: Re: Doubt in function compare_CRS
<br>
>
<br>
> Please do not email me directly. For use questions, please subscribe to
<br>
> R-sig-geo
<br>
>
<br>
> https://stat.ethz.ch/mailman/listinfo/R-SIG-Geo
<br>
>
<br>
> and post there. Your problem cannot be reproduced by me (I do not know
<br>
> what your raster is) - when you post provide a minimal self-contained
<br>
> example. Do also provide the output of sessionInfo(), as you may not be
<br>
> using updated packages.
<br>
>
<br>
> Roger Bivand
<br>
>
<br>
>
<br>
> On Tue, 15 Jun 2021, Pietro Andre Telatin Paschoalino wrote:
<br>
>
<br>
>> Hello Bivand,
<br>
>>
<br>
>> How you create the function compare_CRS and it has already exemplified
<br>
>> several issues for me. I would like to know if you can help me with a
<br>
>> simple issue
<br>
>>
<br>
>> I tried to compare the CRS OGC with my raster (stack) and I couldn't:
<br>
>>
<br>
>> rgdal::compare_CRS(CRS("OGC:CRS84"), slot(rasbrick, "crs"))
<br>
>> Error in CRS("OGC:CRS84") :
<br>
>> PROJ4 argument-value pairs must begin with +: OGC:CRS84
<br>
>>
<br>
>> I also tried it like this:
<br>
>>
<br>
>> rgdal::compare_CRS(CRS("+OGC:CRS84"), slot(rasbrick, "crs"))
<br>
>> Error in showSRID(uprojargs, format = "PROJ", multiline = "NO") :
<br>
>> Can't parse PROJ.4-style parameter string
<br>
>> +OGC:CRS84
<br>
>>
<br>
>> could you answer me where am I wrong?
<br>
>>
<br>
>> When I compare a shapefile with my raster (stack) the function runs normally, for example:
<br>
>>
<br>
>> compare_CRS(slot(shape1, "proj4string"), slot(rasbrick, "crs"))
<br>
>> strict equivalent equivalent_except_axis_order
<br>
>> FALSE TRUE TRUE
<br>
>>
<br>
>> Thank you.
<br>
>>
<br>
>> Pietro Andre Telatin Paschoalino
<br>
>> Doutorando em Ci�ncias Econ�micas da Universidade Estadual de Maring� - PCE.
<br>
>>
<br>
>> [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<br>
>>
<br>
>
<br>
> --
<br>
> Roger Bivand
<br>
> Emeritus Professor
<br>
> Department of Economics, Norwegian School of Economics,
<br>
> Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
<br>
> e-mail: Roger.Bivand@nhh.no
<br>
> https://orcid.org/0000-0003-2392-6140
<br>
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
<br>
>
<br>
> [[alternative HTML version deleted]]
<br>
>
<br>
>
<br>
<br>
--
<br>
Roger Bivand
<br>
Emeritus Professor
<br>
Department of Economics, Norwegian School of Economics,
<br>
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
<br>
e-mail: Roger.Bivand@nhh.no
<br>
https://orcid.org/0000-0003-2392-6140
<br>
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
<br>
</p>
</blockquote></div><br></div>