My data consists of lat, long, and the number of customers associated with
each
How do I go about converting my data.frame to a spatial object?

On Tue, Mar 3, 2009 at 3:40 PM, Paul Hiemstra <p.hiems...@geo.uu.nl> wrote:

> Hi,
>
> You have to provide some more info in order for us to answer you question.
> How does 'your data' look like? A data.frame with x and y coordinates and
> more info? If this is correct, you need to convert the xy data.frame to a
> spatial object:
>
> library(sp)
> data(meuse) # data.frame
> # The columns with the x and y coordinates are called "x" and "y"
> coordinates(meuse) = ~x+y # SpatialPointsDataFrame
>
> Then you can use overlay() to find out in which customer is in which
> polygon. Then you can count the number of customers per zip code.
>
> cheers,
> Paul
>
> Alina Sheyman schreef:
>
>> I'm very new to creating maps using shapefiles, so this question might be
>> pretty basic.
>>
>> I'm trying to create a map of the US, divided up by zip codes, where i
>> then
>> map number of customers by zip code.
>> I located shapefiles for US with zip codes (although at this point only
>> for
>> individual states, and not the entire country) and read it into R using
>> maptools,
>> but now I need to apply my data (which I read into R as a separate data
>> frame and not a shapefile) to that map. Which is the part where I get
>> completely lost and not sure how to proceed. If anyone could give me any
>> pointers I'd really appreciate it.
>>
>> thank you
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>
>
> --
> Drs. Paul Hiemstra
> Department of Physical Geography
> Faculty of Geosciences
> University of Utrecht
> Heidelberglaan 2
> P.O. Box 80.115
> 3508 TC Utrecht
> Phone:  +3130 274 3113 Mon-Tue
> Phone:  +3130 253 5773 Wed-Fri
> http://intamap.geo.uu.nl/~paul <http://intamap.geo.uu.nl/%7Epaul>
>
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to