Hi:
Check out the FindPolys method in the PBSMapping package. here is a code
snippet from a larger example:
(I will be extracting a simpler use case for distribution soon, but this
will give you the general idea....
HucPolys = readShapePoly("AllHucsMerged")
DamPoints = readShapePoints("Part1Dams")
#
NumHucs = length([EMAIL PROTECTED],1])
NumDams = length([EMAIL PROTECTED],1])
#
# promote points to EventData for compatability with FindPolys
#
DamEvents <- as.EventData(data.frame(EID=1:NumDams ,[EMAIL PROTECTED],1],
[EMAIL PROTECTED],2]),projection = "LL")
#
ValidHucsSP = SpatialPolygons2PolySet(HucPolys)
#
# Prepend (add to front) column to DamPoints data frame for HUC assignment
#
Huc8ID = as.numeric(c(1:NumDams))
dim(Huc8ID) = c(NumDams,1)
[EMAIL PROTECTED] = cbind(Huc8ID,[EMAIL PROTECTED])
#
# convert factors to strings in Data Frames and Lists.
#
print(sprintf("about to assign.."))
browser()
#
# note: it is possible for a PointPolyFlags entry to be NA, if
# no polygon was found for a specific point.
#
PointPolyFlags = findPolys(DamEvents,ValidHucsSP)
OR, check out this example, which is more compete:
http://nceas.ucsb.edu/scicomp/GISSeminar/UseCases/PointInPolygonAnalysis/point_in_poly.html
Hope this helps!
[EMAIL PROTECTED] wrote:
Good Afternoon
I searched the archives but could not find the answer to my question.
I have shapefiles for various geographic regions such as states, counties,
zipcode areas, townships, etc. I also have long-lat coordinates for 12000
plus weather stations. I am able to use maptools to plot the maps and am
able to plot the points on the polygon maps with appropriate text. However,
I also need to be able to identify which shapefile polygon each weather
station (or pobbibly other long-lat points) lies within.
Does any package have a function similar to the "maps" packages'
"map.where" function that would work with more general shapefile polygons?
I am new to this list so please excuse me if this question has been
previously addressed. I will appreciate any help or suggestions.
--------------------------------------------------------------------
mail2web.com – Enhanced email for the mobile individual based on Microsoft®
Exchange - http://link.mail2web.com/Personal/EnhancedEmail
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
begin:vcard
fn:Rick Reeves
n:Reeves;Rick
org:UC Santa Barbara;National Center For Ecological Analysis and Synthesis
adr:Suite 300;;735 State Street;Santa Barbara;CA;93101;USA
email;internet:[EMAIL PROTECTED]
title:Rick Reeves, Scientific Programmer/Analyst
tel;work:805 892 2533
url:http://www.nceas.ucsb.edu
version:2.1
end:vcard
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo