[R-sig-Geo] spatstat - affine a window - enlarging (with same center)

Rolf Turner r.turner at auckland.ac.nz
Wed Nov 23 04:52:58 CET 2011


Marcelino is clearly far cleverer than I, since I was at first unable
to figure out what the problem was that Mathieu was complaining
of.  As far as I can understand things, Marcelino's solution is correct.

I can suggest a slight simplification of the commands:

U <- shift(letterR,origin="centroid")
W <- affine(U,mat=2*diag(2),vec=unlist(centroid.owin(letterR)))

To check out that this appears as desired do:

plot(W,main="")
plot(letterR,add=TRUE,border="red")

     cheers,

             Rolf

On 23/11/11 07:27, marcelino.delacruz at upm.es wrote:
> Hi  Mathieu,
>
> Maybe Adrian or Rolf would give a more informated answer, but in the mean
> time,  my opinion is that you should compute the centroid of the affined
> window and apply a "counter"-shift equivalent to the  shift that
> experiments the affined window.
>
> Here's my example with the letterR window (I don't have the
> metropolitan France map at hand)
>
> data (letterR)
>
> ratio<- 2 # example "ratio"
>
> letterRa<- affine(letterR, mat=matrix(c(ratio,0,0,ratio), ncol=2))
>
> # centroids of the original and affined windows
> cLR<- centroid.owin(letterR)
> cLRa<- centroid.owin(letterRa)
>
> # this is the "counter"-shift
> LRshift<- c(cLR[[1]]-cLRa[[1]], cLR[[2]]-cLRa[[2]])
>
> # shift the affined window
> letterRas<-shift(letterRa, vec=LRshift)
>
> # see the results
> plot(letterRas)
> plot(letterR, add=T)
> points(centroid.owin(letterR))
> points(centroid.owin(letterRas), cex=2)
>
> HTH,
>
> Marcelino
>
>
>
>
> Con fecha 22/11/2011, "Mathieu Rajerison"<mathieu.rajerison at gmail.com>
> escribió:
>
>> Hi List,
>>
>>
>> I'd like to visually compare two spatial objects of France contour
>>
>> I have the population in France, the population in the 10 first major
>> cities and I want to enlarge France by a ratio defined by pop(10 major
>> cities)/pop(france), sort of a world cartogramwith the transformation of
>> one country.
>>
>> But I have problems using shear transformation.
>>
>> Here is the code for the moment:
>>
>> fr<- readOGR(".", "FRANCE_METRO")
>> fr.win<- as(fr, "owin")
>>
>> pop.fr<- 65447374
>> townpops<- sum(pop$population)
>> ratio<- townpops / pop.fr
>>
>> ## here is my problem...
>> fr.aff<- affine(fr.win,  mat=matrix(c(ratio,0,0,ratio), ncol=2));
>>
>> Any help would be greatly appreciated
>>
>>
>> Mathieu
>>
>> 	[[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list