[R] Extracting Width and Length of Each Shape in EPS File

Paul Murrell paul at stat.auckland.ac.nz
Thu Apr 17 01:31:29 CEST 2014


Hi

Here is a demonstration that might give you some ideas ...

library(grImport)
PostScriptTrace("flower.ps", "flower.xml")
flower <- readPicture("flower.xml")

grid.newpage()
grid.picture(flower)

# Extract each path, then look at the 'summary' for the path
for (i in 1:flower at summary@numPaths) {
   bb <- flower[i]@summary
   # Draw the result as a check
   grid.polygon(c(bb at xscale[1], bb at xscale[2],
                  bb at xscale[2], bb at xscale[1]),
                c(bb at yscale[1], bb at yscale[1],
                  bb at yscale[2], bb at yscale[2]),
                default.units="native",
                gp=gpar(col=NA, fill=adjustcolor(i, alpha=.5)),
                vp="picture.shape::picture.scale")
}

The flower.ps file in that example is available here ...

https://www.stat.auckland.ac.nz/~paul/R/grImport/importFiles.tar.gz

Hope that helps.

Paul

On 04/17/14 10:56, Jeff Newmiller wrote:
> Have you read the vignettes that accompany that package?
>
> You should also read the Posting Guide for this mailing list, as HTML email is not in general a good idea on this list.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
>                                        Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> On April 16, 2014 6:35:55 AM PDT, Muhammad Abdur Rehman Khawaja <kh.m.a.rehman at gmail.com> wrote:
>> Respected Fellows,
>> I need little bit guidance regarding, how Can I
>> Extract/Calculate/Measure
>> width and length of each every shape in .eps file. EPS file is being
>> generated from Adobe Illustrator.
>> I have used grImport Library in R language to import eps file in R
>> environment, but I couldn't understand in which format the data is in
>> and
>> How can I manipulate it.
>> I'll shall be thankful for your cooperation
>> ------
>> Kind Regards
>> Khawaja Muhammad Abdur Rehman
>> Mechatronics Engineer NUST
>> Professional Profile:
>> http://pk.linkedin.com/in/khawajamechatronicscaps/<kh.m.a.rehman@gmail.com>
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list