简体   繁体   English

从RData文件中提取特定数据

[英]Extracting specific data from an RData file

I ask to be excused for my ignorance of R which I have been learning for the past one month. 我因过去1个月以来对R的无知而感到宽恕。 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. 具体来说,我已经下载了许多感兴趣的国家/地区的xxx_adm-_RData文件(xxx为国家/地区,-为0、1或2)。 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. 我真正的兴趣只是每个国家的经/纬度坐标,我可以用它来覆盖诸如降雨,温度等气候领域的分析。在过去的两周中,我一直在SO帖子中探讨如何访问RData文件中的国家/地区坐标,并将其与其他数据一起使用,但没有成功。 My attempts to get google maps or readGR() or readBin() after a download have not been successful. 下载后,我尝试获取google maps或readGR()或readBin()的尝试未成功。 I wonder whether what am asking for is feasible. 我想知道所要求的是否可行。

after putting the rdata file in your working directory, do something like 将rdata文件放入您的工作目录后,执行以下操作

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. rdata将变量加载到您的工作空间中,以便该命令将向您显示变量名是什么,以便您可以使用它们。

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. 根据您的评论:好的,因此您加载的对象是SpatialPolygonsDataFrame类型的对象,并且具有一个名为Polygons的插槽/属性,而对象的类型为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  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM