[R-sig-Geo] Import a .svg map?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Jun 27 18:06:53 CEST 2014


Playing around with it a bit, you can right-click on a layer in the
legend and get an "Export" option which produces a file containing
some WKT:

ID    geom
background    GEOMETRYCOLLECTION (MULTIPOLYGON (((51146.64788209766
109166.87983294153, 51914.19041081249 114132.5781415662,
 53723.24910049731 114363.53122978129, 54578.8941572942
113080.1977245861, 54642.83015735373 115386.04719873359, 56598.1513751
7477 117295.63286451202, 56050.17479866443 117427.96707263529,
55095.97946977576 119916.59990695301, 58033.90139251192 121691.
4... etc.

By reading this into R and chopping out everything that isn't WKT
(which starts with GEOMETRYCOLLECTION) I can recover a polygon....

The Luxembourg example supplied with the s/w seems to be a bit
different to yours, but if you can see both of your iceland polygons
as layers in the legend you might be able to right-click and export as
WKT and get it into R that way.

For the Lux example, I save background.out.txt and read in:

txt = scan("~/background.out.txt",what="",sep="\t")

then the fourth item is the WKT, so I do:

require(rgeos)
p = readWKT(txt[4])


then I can plot p as a spatial object:

plot(p)

The SVG output does seem to be a representation of what's in the
current view window so not really meant for analysis...

Barry



On Fri, Jun 27, 2014 at 4:24 PM, Gilles Benjamin Leduc <gbl1 at hi.is> wrote:
> Hi again,
>
> The software is there http://spatial-modelling.info/Darcy-2-module-de-comparaison
>
> So indeed it is Iceland (Hi.is tells where I am)
> The blue is the "regular" shape with a strange projection… The green is an anamorphosis.
> Blue points are my actual gps data of sampling, green are "image points" when modifying the geographical position according to the genetical distance (Reynolds index)
>
> I made up some function to make up the image points (not sure If I pushed it yet)
>
> As the SVG output is ugly and not suitable for publication, I need to make it cute on R :p
>
> Benjamin
>
>
> Le Vendredi 27 Juin 2014 14:24 GMT, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> a écrit:
>
>> So I see a couple of distorted outlines of Iceland, both quite
>> flattened N-S (Mercator projection?), and a warped grid over the top,
>> with what I suppose are 5 control points with green and blue point
>> pairs...
>>
>> Is this the output from some kind of warping/registration procedure?
>
>> What are you trying to get out? Is your original shapefile in lat-long
>> and you want a map of Iceland in warped lat-long (ie in the wrong
>> place)?
>>
>> The coordinates of the lines in the SVG scale it nicely for putting on
>> an A4 page so it looks like this is designed for printing and not
>> further analysis....
>>
>>  Have you got a link to the software?
>>
>>
>> On Fri, Jun 27, 2014 at 2:53 PM, Gilles Benjamin Leduc <gbl1 at hi.is> wrote:
>> >
>> >
>> >  Hi Barry,
>> >
>> > Thanks for answering ;)
>> >
>> > So the svg is here https://www.dropbox.com/s/ggok7wijxk8hoat/ana-UPGMA.svg
>> > I can also provide the originel shp (the one coresponding to the blue stuff)
>> >
>> > It seems that Darcy is a dead-end software… French research… No global view… Public funding and no control… Very sad cus it could have been great, and I was about to add in my package a export function to it… anyway…
>> >
>> > Thanks a lot
>> >
>> > Benjamin
>> >
>> >
>> > Le Vendredi 27 Juin 2014 13:42 GMT, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> a écrit:
>> >
>> >> SVG is a general vector graphics format, which uses XML for its
>> >> structure. The coordinate numbers in the SVG could be anything now,
>> >> perhaps scaled from 0 to 1 on each axis or something. It might take
>> >> some custom processing to recover the SVG into a proper mappable
>> >> format.
>> >>
>> >> And if by "their perspective is horible" you mean their projection,
>> >> then you'll need the projection specification they are using in order
>> >> to back-project that.
>> >>
>> >> What's the nature of the output? Is it values in polygon areas
>> >> (shapefile features)? Can you not get Darcy to just output the values
>> >> to a text/csv/spreadsheet file, and then link them back to the
>> >> shapefile in R (it might be in the same order)?
>> >>
>> >> Any chance you can supply an exemplar SVG on a sharing site somewhere
>> >> (dont post it to the group)?
>> >>
>> >> Barry
>> >>
>> >>
>> >>
>> >> On Fri, Jun 27, 2014 at 11:30 AM, Gilles Benjamin Leduc <gbl1 at hi.is> wrote:
>> >> > Hi,
>> >> >
>> >> > For making a part of my work, I needed to use another software named Darcy, I fed it with .shp files ans R calculated values, but it gave me back some map with .svg format.
>> >> > As their perspective is horible, I need to get them back in R and make a correct graph… Any idea of the way for doing that? I cannot find a way of loading svg, or convert it to shp…
>> >> > Best Regards
>> >> >
>> >> > _______________________________________________
>> >> > 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