On 16 Dec 2013 18:44, "Ahmadou Dicko" <dicko.ahmadou@gmail.com> wrote:
>
> I didn't try a topojson but you can read geojson file using OGR through
> rgdal

Yes, and as I said before, once ogr/gdal reaches version 2 everywhere then
this should work with topojson too. Topojson is such a new format that
support is a bit thin on the ground.

I might try and bash out a converter based on RJSONIO if I get a spare hour
tomorrow or if anyone wants to pledge some cold hard cash!

> require(rgdal)
> any(grepl("GeoJSON", ogrDrivers()$name)) ### TRUE
>
>
> url <- "
> https://raw.github.com/johan/world.geo.json/master/countries.geo.json"
> world <- readOGR(dsn = url, layer = "OGRGeoJSON")
> plot(world)
>
> sessionInfo()
> ## R version 3.0.2 Patched (2013-12-15 r64463)
> ## Platform: x86_64-unknown-linux-gnu (64-bit)
>
> ## locale:
> ##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> ##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
> ##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
> ##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
> ##  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> ## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> ## attached base packages:
> ## [1] stats     graphics  grDevices utils     datasets  methods
> ## [7] base
>
> ## other attached packages:
> ## [1] rgdal_0.8-14 sp_1.0-14
>
> ## loaded via a namespace (and not attached):
> ## [1] compiler_3.0.2  grid_3.0.2      lattice_0.20-24
> ## [4] tools_3.0.2
>
>
> system("ogrinfo --version")
> ## GDAL 1.10.0, released 2013/04/24
>
>
>
>
>
> On Mon, Dec 16, 2013 at 6:31 PM, Miguel Fiandor Gutiérrez <
> mfiandor@gmail.com> wrote:
>
> > HI, thanks Barry, I am also one of those converters, I started with an
shp
> > file, and optimized it into topojson, what I mean is that i also have
that
> > shp file. The problem is that it is huge.
> >
> > Right, as a json, I could use a json r library, so then my question is
> > more: *does exists a r library that understands geojson or topojson and
> > prints maps in these formats?*
> > As d3.js does. Probably I could try with shiny, as I've read a few times
> > some shiny+d3.js examples, but I was looking for a one library
solution, or
> > the fewer code lines as possible.
> >
> > BR,
> >
> > Miguel
> >
> >
> > Saludos,
> >
> >                 Miguel Fiandor
> >
> >
> > 2013/12/16 Barry Rowlingson <b.rowlingson@lancaster.ac.uk>
> >
> > > On a more positive note, topojson, like geojson, is just a JSON file,
> > > so you can read it with any of the R JSON interface packages (I've
> > > just read a us.json file using package:RJSONIO).
> > >
> > >  The job is then to unweave the structure into something plottable.
> > > topojson works by defining features as sequences of arcs, and arcs as
> > > sequences of coordinates. The arcs are actually defined as a start
> > > point and x-y offsets.
> > >
> > >  With a whole load of array lookups (remembering that arc -342 is arc
> > > 342 in the reverse direction) you could write some R code to go from
> > > topojson to SpatialPolygons.
> > >
> > >  I'm loathe to do this at the moment since I suspect the functionality
> > > to convert from topojson to shapefiles/geojson/some other standard
> > > exists (apart from in ogr 2.0) and it would be easier to re-use that.
> > >
> > >  Ooh, it takes me back to my reverse-engineering Arc/Info .e00
files...
> > >
> > > Barry
> > >
> > >
> > > On Mon, Dec 16, 2013 at 10:31 AM, Barry Rowlingson
> > > <b.rowlingson@lancaster.ac.uk> wrote:
> > > > The geoJSON driver in gdal/ogr will read it from version 2 of OGR:
> > > >
> > > > http://www.gdal.org/ogr/drv_geojson.html
> > > >
> > > > but I think that's very leading-edge (I seem to have v 1.10  on my
> > > system).
> > > >
> > > > So the solution would seem to be to convert your topojson to
something
> > > > that your gdal/ogr can handle, and then read it into R using the
rgdal
> > > > package readOGR function. I'm having trouble finding a utility that
> > > > will do the conversion that way, since most people start from
> > > > something and convert it _to_ topojson for fast rendering! I think
it
> > > > might be necessary to cruft something  together from various python
or
> > > > javascript modules lying around the web,
> > > >
> > > > From there its straightforward SpatialPolygonsDataFrame stuff.
> > > >
> > > > Barry
> > > >
> > > > On Sun, Dec 15, 2013 at 10:49 PM, Miguel Fiandor Gutiérrez
> > > > <mfiandor@gmail.com> wrote:
> > > >> Hi,
> > > >>
> > > >> I do have some maps in topojson format, and I would like to display
> > > data on
> > > >> them that i have in .CSVs and access database. So far I play with
them
> > > with
> > > >> d3.js,<
> > > http://transparenciadecuentaspublicas.es/2012/madrid/gastos-personales
> > >but
> > > >> i'd like to learn too with R.
> > > >> My question is not about the csv or db to data frame or similar, is
> > how
> > > to
> > > >> display any data variable with this kind of map files, I have not
> > found
> > > >> literature about it. Yes, each region of the map has its own id
code.
> > > >>
> > > >> The output will end on a pdf file or website, but as soon as I can
> > print
> > > >> the map or export it it would be enough.
> > > >>
> > > >> Thanks
> > > >>
> > > >> Miguel Fiandor
> > > >>
> > > >>         [[alternative HTML version deleted]]
> > > >>
> > > >> _______________________________________________
> > > >> R-sig-Geo mailing list
> > > >> R-sig-Geo@r-project.org
> > > >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > >
> >
> >         [[alternative HTML version deleted]]
> >
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> >
>
>
> --
> Ahmadou H. DICKO
> statistician economist (Ingénieur Statisticien Économiste)
> PhD candidate in Climate change economics
> Faculty of economics and managment - Cheikh Anta Diop University
> West African Science Service Center on Climate Change and Adaptated Land
> Use (WASCAL)
> Center for Development Research (ZEF) - University of Bonn
> email : ahmadou.dicko@ucad.edu.sn
> twitter : @dickoah
> github : github/dickoa <https://github.com/dickoa>
> tel : +221 33 827 55 16
> portable: +221 77 123 81 69
>
>         [[alternative HTML version deleted]]
>

	[[alternative HTML version deleted]]

