I am an absolute beginner with GIS data. I am attempting to write a tool to determine if a lat/long point resides within a polygon within a shapefile provided by SABS (https://nces.ed.gov/programs/sabs/). Basically, I am trying to write something that will tell me the primary school for a given address when internet is not available (no Google Maps, GreatSchools, etc.).
Anyway, I am using GeoTools with modified PointInPolygon code from https://github.com/ianturton/geotools-cookbook/blob/master/modules/filters/src/main/java/org/ianturton/cookbook/filters/PointInPolygon.java to search for lat/long points in polygons.
With that, I can see that there are lat/long points within the GeoTools suggested datafile (http://www.naturalearthdata.com/downloads/50m-cultural-vectors/). However, the SABS data does not report any points in polygons.
When I look at the polygon data for the two files, the points for the suggested data file are in the lat/long ranges I expect (+/-90, +/-180). The point data in the SABS file has values many magnitudes larger.
My guess is that the SABS data is in a projection that doesn't play well with querying if a point is inside the polygon. I don't know how to transform the data so that I can perform lat/long queries.
Can someone explain what I need to do to be able to perform a lat/long search with the SABS data?
SABS prj: PROJCS["USA_Contiguous_Albers_Equal_Area_Conic_USGS_version",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["Latitude_Of_Origin",23.0],UNIT["Meter",1.0]]
Natural Earth prj:
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
Code added to PointInPolygon to test data files:
for (double lat = -90.; lat < 90.; lat += 0.01) {
for (double lon = -180; lon < 180; lon += 0.01) {
final Point p = fac.createPoint(new Coordinate(lat, lon));
final boolean flag = tester.isInShape(p);
if (flag) {
System.out.println(p + " is inside");
}
}
}