[R-sig-Geo] creating polygons

Roger Bivand Roger.Bivand at nhh.no
Tue Apr 21 21:17:29 CEST 2009


On Tue, 21 Apr 2009, Alina Sheyman wrote:

> To rephrase my question and explain my problem further
> I have already created a map for revenue by zip code, in the state of
> Massachusetts. To accomplish that I used a shapefile for Massachusetts and a
> dataframe with my revenue/zip codes.
>
> What I am trying to do now is to have the same map done not by zip code, but
> rather by districts, as defined by zip codes.
>
> Basically what I've done was to introduce a new variable "district" into my
> dataset along with a zip code. At the same time my basic state map (by zip)
> still comes from a shape file and I can't introduce a new variable into the
> shape file.
>
>  Does anyone  know if there's any way I can accomplish what I'm trying to
> do or do I basically need to create a new shapefile with districts already
> in the file?

OK, that wasn't too clear before. Look at unionSpatialPolygons() in 
maptools - it will take a vector of districts matching all your zip codes, 
and join together the geometries belonging to each district, dropping 
internal boundaries. The district IDs become the Polygons object IDs. 
There is no data frame in the object, because it isn't obvious how you 
might want to aggregate it.

Hope this helps,

Roger

>
> On Mon, Apr 20, 2009 at 5:53 PM, Don MacQueen <macq at llnl.gov> wrote:
>
>> This is a pretty general question, and there are potentially many ways to
>> do it.
>>
>> One way to get started would be to follow the example(s) in the help page
>> for the overlay() function in the sp package.
>>
>> -Don
>>
>>
>> At 1:26 PM -0400 4/20/09, Alina Sheyman wrote:
>>
>>>  I have a list of made-up districts and corresponding zip codes. Based on
>>> that I want to define my own polygons (for each district) and then use
>>> them
>>> to create a map. Does anyone know how I would go about defining these?
>>>
>>> thank you
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https:// stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>>
>> --
>> --------------------------------------
>> Don MacQueen
>> Environmental Protection Department
>> Lawrence Livermore National Laboratory
>> Livermore, CA, USA
>> 925-423-1062
>> --------------------------------------
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list