[R-sig-Geo] problem with extract() raster package using weight=TRUE
up
u.p at operamail.com
Thu Sep 19 10:15:37 CEST 2013
Robert Hijmans wrote
> Umberto,
>
> The work-around is to assure that the CRS are the same:
>
> projection(regioni) <- projection(t500)
>
> You should of course only do that when the projections are in fact the
> same, as in this case. The problem is caused by sp::identicalCRS that
> compares the verbatim, but not the semantic representation of the CRS
> (and, therefore, perhaps should give a warning rather than an error?).
>
> Robert
Many thanks Robert for your suggestion! :-)
But I've already tried that, and did not work.
Yestarday I tried to use another shapefile, because I suspected something
wrong in my WGS84 shapefile.
And with another shapefile things gone well!
I've downloaded a shapefile of my country but in a different projection
("+proj=utm +zone=32 +ellps=intl +units=m +no_defs"), and then reprojected
in "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" with:
liguria<-spTransform(ligu_utm, CRS("+proj=longlat +datum=WGS84 +no_defs
+ellps=WGS84 +towgs84=0,0,0"))
Then I've extracted values with the same function:
estra_liguria<-extract(prec,liguria,weights=T,cellnumbers=T,df=T)
and that's the result:
ID cell totprec weight
1 1 10 0 0.12
2 1 18 0 0.34
3 1 19 0 0.33
4 1 20 0 0.42
5 1 25 1 0.57
6 1 26 0 0.60
7 1 27 0 0.84
8 1 28 0 0.96
9 1 29 0 0.91
10 1 30 0 1.00
11 1 34 10 0.06
12 1 35 5 0.84
13 1 36 0 1.00
14 1 37 0 1.00
I don't know why the first shapefile doesn't work (I've downloaded it from
http://www.gadm.org, lonlat WGS84), but the new one does the job! :-)
In any case, thanks very much!
Umberto
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/problem-with-extract-raster-package-using-weight-TRUE-tp7584665p7584673.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list