[R-sig-Geo] +AFs-R-sig-Geo+AF0- Represent data on map
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Sun Jan 5 19:32:58 CET 2014
On 01/04/2014 09:33 PM, Rolando Valdez wrote:
> It didn't work.
>
>> names(map)
> [1] "CVE_EDO" "NOMBRE_EDO"
>> names(unem)
> [1] "num_est" "est" "X2000" "X2005" "X2010" "X2013"
>> spplot(map, 'X2000')
> Error en `[.data.frame`(obj at data, zcol) : undefined columns selected
>
no, because X2000 will be sought in object 'map'. In case 'map' and
'unem' have exactly identical geometries (polygons?), and these
geometries occur in the same order, then
map$X2000 = unem$X2000
may suffice. If not, you might need to do a spatial match, e.g. by
library(sp)
data(meuse)
coordinates(meuse) = ~x+y
data(meuse.grid)
coordinates(meuse.grid) = ~x+y
gridded(meuse.grid) = TRUE
try(meuse$dist <- meuse.grid$dist) # fails, as geometries don't match
meuse$dist = over(meuse, meuse.grid)$dist # uses a spatial match
but still, if unem and map are both polygon geometries this may lead to
errors, as over() finds (first) intersecting polygons, and neighbouring
polygons touch each other, so intersect too.
> Is it a problema having separate shapefile information of statistic?, because there are two files, the .shp and csv, although these have the same identificator. I mean, the "CVE_EDO" = "num_est" and "NOMBRE_EDO" = "est" are the same value. I'm thinking if I have to paste the csv columns to the map object.
>
> Thanks,
>
> Rol~
>
> -----Mensaje original-----
> De: MacQueen, Don [mailto:macqueen1 at llnl.gov]
> Enviado el: sábado, 4 de enero de 2014 12:07 a. m.
> Para: Rolando Valdez; r-sig-geo at r-project.org
> Asunto: Re: [R-sig-Geo] Represent data on map
>
> Cannot help much without more information, but try:
>
> names(map)
>
> Then pick one of the column names. Apparently, "2000" is not the name of a column of data in the map object.
> If map is like unem, then perhaps
>
> spplot(map, 'X2000')
>
> is what you need.
>
> Note, the c() in
> c("2000")
> is not necessary. Simply
> "2000"
> would be sufficient.
>
> I am not familiar with the readShapeSpatial function; I always use
> readOGR() from the sp package.
>
> -Don
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 1/3/14 1:00 PM, "Rolando Valdez" <rvaldezr at gmail.com> wrote:
>
>> Hi,
>>
>> I'm trying to represent data (unemployment rate) on a map.
>>
>> This is what I have:
>>
>>> library(sp)
>>> library(maptools)
>> Checking rgeos availability: TRUE
>>> map <- readShapeSpatial("ESTADOS")
>>> read.csv("C:\\Users\\Rolando\\Documents\\Maestría en Economía\\3er
>>> Semestre\\AEMT\\desempleo_est.csv")
>>> spplot(map, c("2000"))
>> Error en `[.data.frame`(obj at data, zcol) : undefined columns selected
>>
>>> unem <- read.csv("C:\\Users\\Rolando\\Documents\\Maestría en
>>> Economía\\3er Semestre\\AEMT\\desempleo_est.csv")
>>> names(unem)
>> [1] "num_est" "est" "X2000" "X2005" "X2010" "X2013"
>>
>> I hope you can help me, this is my first time in R.
>>
>> Regards,
>>
>> Rol~
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140105/a514af13/attachment.bin>
More information about the R-sig-Geo
mailing list