Reading India_pc_2014 shapefiles in R

48 views
Skip to first unread message

Ashutosh Kumar

unread,
Jun 30, 2014, 2:47:22 AM6/30/14
to data...@googlegroups.com
Hi everyone,

I am having some trouble in reading the Indian Parliamentary Constituency shapefiles (https://github.com/datameet/maps/tree/master/parliamentary-constituencies) in R. I am able to read shapefiles from other sources from all over the internet, but not the shapefiles on the datameet repository on Github (India_pc_2014 and 2011_dist). Also, I am getting an error while opening these files on QGIS shapeviewer. 

Can anyone help me in figuring out how to read them into R? I primarily use R for these analysis and my understanding of python is very limited, so will appreciate the help. I got some help from Devdatta but it hasn't solved the problem of not reading these specific files into R

Here are the details and error:

R:
> library(maptools)

> shape<-readShapeSpatial("india_pc_2014.shp")
Error in getinfo.shape(fn) : Error opening SHP file

I have downloaded 5 files (india_pc_2014.shx, shp, qpj, prj, dbf); All are in the same folder.

Any help will be appreciated.

THanks

Devdatta Tengshe

unread,
Jul 1, 2014, 6:56:45 AM7/1/14
to data...@googlegroups.com
Hi Ashutosh,

I'll suggest that you go through this pdf: http://cran.r-project.org/doc/contrib/intro-spatial-rl.pdf

It extensively deals with working with Spatial Data in R.

I'll also suggest that you access the files without the extension. You should use:
shape<-readShapeSpatial("india_pc_2014")
& Not: shape<-readShapeSpatial("india_pc_2014.shp")

I'll also suggest that you use readOGR from the rgdal library.

I could successfully run all these commands on shapefiles from a fresh clone of the repository. If even after this you can't access these files in R, then I'm afraid that it is a a system specific issue, and I don't have any advice on how to solve that.

Regards,
Devdatta
Reply all
Reply to author
Forward
0 new messages