> Hi Lyndon,

>

> I really apreciate you help. Your function was very helpfull. However, in

> this case polygons are block (block where many homes are). The avenue and

> street aren't assigned at any polygon, so if a point is out of a polygon is

> there any way to get it inside the nearest polygon?. For example, any point

> near (50 meters) the polygon should correspond to that polygon. So, it this

> way I could change the precision of the estimation, don't you?

>

> Than you in advance!

> José

>

> ------------------------------

> *De:* Lyndon Estes <

[hidden email]>

> *Para:* Jose Bustos Melo <

[hidden email]>

> *CC:* "

[hidden email]" <

[hidden email]>

> *Enviado:* martes 10 de enero de 2012 15:21

> *Asunto:* Re: [R-sig-Geo] Spatial join using shapefiles with R

>

> Hi Jose,

>

> This function might help with what you want to do.

>

> Cheers, Lyndon

>

> IntersectPtWithPoly <- function(x, y) {

> # Extracts values from a SpatialPolygonDataFrame with

> SpatialPointsDataFrame, and appends table (similar to

> # ArcGIS intersect)

> # Args:

> # x: SpatialPoints*Frame

> # y: SpatialPolygonsDataFrame

> # Returns:

> # SpatialPointsDataFrame with appended table of polygon attributes

>

> # Set up overlay with new column of join IDs in x

> z <- overlay(y, x)

>

> # Bind captured data to points dataframe

> x2 <- cbind(x, z)

>

> # Make it back into a SpatialPointsDataFrame

> # Account for different coordinate variable names

> if(("coords.x1" %in% colnames(x2)) & ("coords.x2" %in% colnames(x2))) {

> coordinates(x2) <- ~coords.x1 + coords.x2

> } else if(("x" %in% colnames(x2)) & ("x" %in% colnames(x2))) {

> coordinates(x2) <- ~x + y

> }

>

> # Reassign its projection if it has one

> if(is.na(CRSargs(x@proj4string)) == "FALSE") {

> x2@proj4string <- x@proj4string

> }

> return(x2)

> }

>

>

>

>

> On Tue, Jan 10, 2012 at 1:06 PM, Jose Bustos Melo <

[hidden email]>wrote:

>

> Hi everyone,

>

> Its have been very difficult to do an spatial join with R and I couldn't

> find any good manual about it. So, I will explain it if someone is willing

> to help.

>

> I have one Shapefile with poligons (with its number) and another Shapefile

> with xy points. My idea is to obtain the number of the polygons where the

> points are found, in order to obtain their social data of those polygons.

>

> How can I do it? Is there any good way to do it? Where can I find

> informationa bout it? Any function?

>

> Thanks in advance

> José

>

> [[alternative HTML version deleted]]

>

>

> _______________________________________________

> R-sig-Geo mailing list

>

[hidden email]
>

https://stat.ethz.ch/mailman/listinfo/r-sig-geo>

>

>

>

>