Question

I ask to be excused for my ignorance of R which I have been learning for the past one month. Specifically I have downloaded xxx_adm-_RData files (xxx for the country and - being 0, 1 or 2) for a number of countries of interest. My real interest are just the long/lat coordinates of each country, which I can use to overlay on analyses of climate fields like rainfall, temperature, etc. For the past two weeks I have been going through SO posts on how I can access a country's coordinates in an RData file and use them with other data, without any success. My attempts to get google maps or readGR() or readBin() after a download have not been successful. I wonder whether what am asking for is feasible.

Was it helpful?

Solution

after putting the rdata file in your working directory, do something like

load("C:/Users/1_adm.RData", ex <- new.env())
ls.str(ex)

The rdata loads variable into your workspace so that command will show you what the variable names are, so you can then use them.

I don't have the file you're talking about so I can't tell you how to access the specific fields you need.

edit

Based on your comment: Ok so the object you load is an object of type SpatialPolygonsDataFrame, and that has a Slot/property called Polygons, with objects of type Polygon. Those polygons I assume are the lat lng coordinates around the country. Accessing the coordinates should look something like

ps <- gadm@polygons[1]   

then something like

ps@coords  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top