[R-sig-Geo] Maptools, polylines to polygon and the .dwg format

FloydGlz mnoe at lcg.unam.mx
Mon Jul 5 23:41:11 CEST 2010


Let's see if i can explain myself properly...

Im doing some work on categorizing diseases per area, so i have a map (a
.dwg file) that has all the states and municipalities, and my end work has
to be the same map but with different colors depending on the number of
cases for each disease.

Now, for example, in this page, http://www.gadm.org/country, you can
download a map (i use Mexico for the example, and i download it as a shape
file), then, i load it to R with maptools and the readShapePoly function;
using this i can subset specific regions and colour it according to my
needs, pretty easy and useful. Another great thing, is that in the .dbf file
(im not 100% is that file but im guessing it is) contains all the ID's,
which i can access with the names() function of R, and i can search for a
specific name or state, BECAUSE IT EXISTS SUCH ID.

Now my problem is that i dont know how to manipulate this ID's, because in
the example they are already there, but with the data i have (the .dwg
file), is pretty much inexistent, how do i create/edit an attribute, so i
can add it to the .shp/.dbf file? if i want to create a category named
Municipalities, so each polygon (region of the map) has a unique name, how
do i do that?

For example, in the shp file of mexico listed in the example, one can create
a map with the following code

library(maptools)
mexmap <- readShapePoly("MEX_adm2.shp")
names(mexmap)
df <- which(mexmap[[5]] == "Distrito Federal")
plot(mexmap[df,])
library(gplots)
showpanel <- function(col){image(z=matrix(1:100, ncol=1), col=col, xaxt="n",
yaxt="n")}
showpanel(colorpanel(6,low="skyblue",high="darkblue")) #so i can see the
colors
colore <- colorpanel(6,low="skyblue",high="darkblue")
colore <- rep(colore,length.out=16)
plot(mexmap[df,],col=colore)

In the end is easier because i have the names i want, and i can manipulate
the regions needed. I want to do the same with my file.

I appreciate any suggestions, thank very much for your time.

------------------------------------
Melvin Jesus Noe Gonzalez
Undergraduate Genomics Student 
UNAM MEX
mnoe at lcg.unam.mx

-- 
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Maptools-polylines-to-polygon-and-the-dwg-format-tp5257809p5257809.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list