Determining whether a point is within a region

edited January 2015 in How To...

I have a shp file (also have a bunch of other files given to me: *.dbf, *.kml, *.prj, *.sbn, *.sbx, *.xml, *.shx. But the shp file looks the most useful) which maps out all the counties in a state. In Processing I want to be able to determine which county a latitude and longitude point resides within.

Comments

  • Or use the classical "draw each region in one distinct color on an off-line graphics and check the color at the position in this graphics to see which region is touched" trick...

  • So how would I read a *.shp file in Processing? I want to be able to do something as following:

      HashMap<String, Integer> countyCount = new HashMap<String, Integer>();
      for (Coordinate co : dataset) {
        String county = getCounty(co.lat, co.lon);
        countyCount.put(line, countyCount.get(county) + 1);
      }
    

    I want to be able to go through a dataset of coordinates and determine in which region they lie, and see how many coordinates lie in each county.

  • That's a quite different question! Have you tried to search the site (from Processing.org, not from this forum)?

Sign In or Register to comment.