Hi Akos,
Thanks for your answer. I tried your suggestion, and for:
proj4string(pln) <- proj4string(buff)
Warning messages:
1: In proj4string(buff) : CRS object has comment, which is lost in output
2: In proj4string(obj) : CRS object has comment, which is lost in output
pln <- spTransform(pln, proj4string(buff))
Warning message:
In proj4string(buff) : CRS object has comment, which is lost in output
proj4string(buff)
[1] "+proj=utm +zone=16 +datum=WGS84 +units=m +no_defs"
Warning message:
In proj4string(buff) : CRS object has comment, which is lost in output
I got these warnings, which again, i don't understand. I am trying to do an
R package that uses sp, and specifically gIntersection for my project and i
cannot leave it with those warnings.
But if after i have my two objects buff and pln and use these two
transforms you specified, where crs1 is my projection string "+proj=utm
+zone=16 +datum=WGS84
+units=m +no_defs" :
pln <- spTransform(x = pln, CRSobj=crs1)
Then, i get no warnings from the gIntersection function. I will test
further, but maybe this is the solution, although i still don't understand
why i need to transform my object with a projection when it already has
that projection.
Thanks again for your suggestion, it really helps ;-)
Take care,
Monica
##################################################################
Message: 2
Date: Wed, 21 Oct 2020 16:53:29 +0200
From: =?UTF-8?Q?Bede-Fazekas_=c3=81kos?= <bfalevlist at gmail.com>
To: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] sp:gIntersection warning message about
projection
Message-ID: <33da0968-ec27-89b3-6dc1-46d892309b93 at gmail.com>
Content-Type: text/plain; charset="iso-8859-2"; Format="flowed"
Hello Monica,
The format of CRS definition changed a lot in the last years. I saw
similar errors thrown by package sf, and transforming or CRS
modification solved the problem. Does rgeos::gIntersection() work if you
run one of the following lines before intersection?:
proj4string(pln) <- proj4string(buff)
pln <- spTransform(pln, proj4string(buff))
pln <- spTransform(x = pln, CRSobj = "+proj=utm +zone=16 +datum=WGS84
+units=m +no_defs"); buff<- spTransform(x = buff, CRSobj = "+proj=utm
+zone=16 +datum=WGS84 +units=m +no_defs")
Have a nice week,
?kos Bede-Fazekas
Hungarian Academy of Sciences
2020.10.21. 16:29 keltez?ssel, Monica Palaseanu-Lovejoy ?rta:
Hi,
I am using in my workflow gIntersection from sp package. Part of my
relevant sessionInfo is:
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] CircStats_0.2-6 boot_1.3-25 MASS_7.3-53 stringr_1.4.0
[5] rgeos_0.5-5 maptools_1.0-2 rgdal_1.5-18 raster_3.3-13
[9] sp_1.4-4
So i am using 2 SpatialLinesDataFrame that are results of previous
computation. I am not sure i can give a viable examples, but maybe this
can
be solved without. If not i will figure out how i can give you a workable
example. Or if you know if there are in R already loaded 2 different line
shapefiles with projection then i will see if i can replicate this
problem.
But the main point is that my workflow was fine in R 4.0.0 and the older
sp
version, and after i upgraded to the newest R and updated all packages i
am
getting the projection warning.
So, first file:
buff
class : SpatialLinesDataFrame
features : 1
extent : 560525.5, 561302.4, 4698908, 4701110 (xmin, xmax, ymin,
ymax)
crs : +proj=utm +zone=16 +datum=WGS84 +units=m +no_defs
variables : 2
names : ID, buff_dist
value : 2, 135
second file:
pln
class : SpatialLinesDataFrame
features : 1
extent : 560615.6, 560705.4, 4698905, 4699180 (xmin, xmax, ymin,
ymax)
crs : +proj=utm +zone=16 +datum=WGS84 +units=m +no_defs
variables : 2
names : x, y
value : 560615.564407584, 4698904.71208346
Please observe that both files have identical projections.
p1 <- gIntersection(buff, pln)
Warning message:
In RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td,
unaryUnion_if_byid_false, :
spgeom1 and spgeom2 have different proj4 strings
This warning is baffling since both files have same projection:
crs(buff)
CRS arguments:
+proj=utm +zone=16 +datum=WGS84 +units=m +no_defs
crs(pln)
CRS arguments:
+proj=utm +zone=16 +datum=WGS84 +units=m +no_defs
Probably i am doing something wrong but for the life of me i cannot see it
as yet.
Thanks so much for any help, take care,
Monica
[[alternative HTML version deleted]]