Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

Why does R(gdal) mangle data when converting to geojson?

$
0
0

I’ve encountered issues with projections in .geojson files created by rgdal, but I never thought it would destroy my data, until I tried this (reproducible example):

downloader::download("http://census.edina.ac.uk/ukborders/easy_download/prebuilt/shape/England_lad_2011_gen_clipped.tar.gz", destfile = "cuas.zip")
untar("cuas.zip")
cuas_shp <- raster::shapefile("England_lad_2011_gen_clipped.shp")
tmap::qtm(cuas_shp)
rgdal::writeOGR(cuas_shp, "cuas-ogr", "OGRGeoJSON", "GeoJSON")
cuas_ogr <- rgdal::readOGR("cuas-ogr", "OGRGeoJSON")
tmap::qtm(cuas_ogr ) # fails - something wrong with the data
library(sp) # plot using normal methods
plot(cuas_shp)
plot(cuas_ogr)

There are more examples I can show. It seems the geojsonio package does not solve these issues either. Ask if you’d like more reproducible examples – want to check I’m not missing anything obvious first though.

(Also not the projection seems to be missing in the geojson example.)


Viewing all articles
Browse latest Browse all 397

Trending Articles