Hi Dave, I have done something similar, where I had 160+million points and 120,000 polygons and needed to find which polygons the points fell in.
I loaded an in-memory RTree index straight from my shapefile containing the 120,000 polygons, so that the index contained a NamedGeometry (the geometry of the polygon and the name I referenced the polygon as). Then I looped over the 162M point data and used the index to find candidate polygons (ones whose minimum bounding rectangle covered the point), and finally a geometry.contains(point) to check if the point fell in the polygon. This worked quite well for my needs. The index class is here: http://code.google.com/p/ibiodiversity/source/browse/trunk/index-hadoop/src/main/java/com/ibiodiversity/index/RTreePolygonIndex.java and with this you would be able to do something like: RTreePolygonIndex.initialise(new URL("file:///temp/fields.shp"), "FieldNameAttribute", 10000, 0); // limit to 10000 for (Address a : addresses) { List<String> fieldNames = RTreePolygonIndex.polygonsForPoint(a.getLatitude(), a.getLongitude()); } // FieldNameAttribute is the attribute of the feature in the shapefile you wish to use as the name of the polygon - could be FieldName or ID or something like this Cheers, Tim On Sat, Feb 7, 2009 at 4:24 AM, Jody Garnett <[email protected]> wrote: > Some good news; whatever platform you use you are going to end up coming > down to the same code. The JTS Topology Suite point-in-polygon code is > great; well tested etc. If you did you work in QGIS you would end up > using the GEOS implementation of this code (GEOS is a port of JTS to C++). > > Here is some writing on the topic: > - > http://lin-ear-th-inking.blogspot.com/2007/07/ultimate-point-in-polygon.html > > Have a look here at the PointInRing classes: > - > http://www.vividsolutions.com/Jts/javadoc/com/vividsolutions/jts/algorithm/package-summary.html > > In GeoTools I would go through your polygons and build up an > STRtreePointInRing for each one (keeping them in a > Map<String,STRtreePointInRing>) and then go through your points; testing > each point ... > > Cheers, > Jody > > Dave Everson wrote: >> >> Hello, >> >> I am very new to geocoding. My experience to date has been using >> algorithms to determine long/lat for an address and returning all >> addresses within a radius around a zip code. >> >> I am now working with a youth sports organization that is dealing with >> multiple city entities to allocate field space for participants. We >> are in the middle of a metropolitan area and the cities allocate field >> usage based on the percentage of participants living within their city >> limits. Zip code alone does not address this require because a zip >> code may fall into multiple cities and/or school districts. >> >> We have all our participants geocoded with long/lat. We can get >> shapefile from either our state government >> (http://www.gis.leg.mn/html/download.html) or from TIGER. I have used >> Quantam GIS to load the shapefile and then overlay with our >> participants. This looks cool, but we are dealing with 5000+ addresses. >> >> We would like to produce a report for our 5000+ addresses with the >> city limits and school district they fall within. This way we can >> summarize the information for the city administrators we are dealing >> with. >> >> I think the "point in polygon" algorithms is the approach we need to >> take (could be wrong). I have taken a look at some various APIs, but >> have been left confused and uncertain about the direction to go. >> Can anyone provide some direction on how we can get started with using >> the GeoTools API to load a shapefile form TIGER and then programically >> determine the city of residence and school district for each participant? >> >> Thanks! >> Dave >> >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------------ >> Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) >> software. With Adobe AIR, Ajax developers can use existing skills and code to >> build responsive, highly engaging applications that combine the power of >> local >> resources and data with the reach of the web. Download the Adobe AIR SDK and >> Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Geotools-gt2-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > > > ------------------------------------------------------------------------------ > Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) > software. With Adobe AIR, Ajax developers can use existing skills and code to > build responsive, highly engaging applications that combine the power of local > resources and data with the reach of the web. Download the Adobe AIR SDK and > Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
