Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aniquetahir/7cf09b31aa6906b2e80b139510dc55eb to your computer and use it in GitHub Desktop.
Save aniquetahir/7cf09b31aa6906b2e80b139510dc55eb to your computer and use it in GitHub Desktop.
/*---------------------------- Start an example Spatial Join Query using Cartesian Product algorithm ----------------------------*/
/* Please see http://www.public.asu.edu/~jiayu2/geospark/javadoc/latest/ for function documentation */
val objectRDD = new PointRDD(sc, "/home/SparkUser/Downloads/GeoSpark/src/test/resources/arealm.csv", 0, FileDataSplitter.CSV, false, 10); /* The O means spatial attribute starts at Column 0 and the 10 means 10 RDD partitions */
val rectangleRDD = new RectangleRDD(sc, "/home/SparkUser/Downloads/GeoSpark/src/test/resources/zcta510.csv", 0, FileDataSplitter.CSV, false); /* The O means spatial attribute starts at Column 0. You might need to "collect" all rectangles into a list and do the Carteian Product join. */
val resultSize = JoinQuery.SpatialJoinQuery(objectRDD, rectangleRDD, true).count();
/*---------------------------- End an example Spatial Join Query using Cartesian Product algorithm ----------------------------*/
CSE 512 Naive Spatial Join Query (Should be written in Java)
1.Create a PointRDD objectRDD;
2.Create a RectangleRDD queryWindowRDD;
3.Collect rectangles from queryWindowRDD to one Java List L;
4. For each rectangle R in L
do RangeQuery.SpatialRangeQuery(objectRDD, queryEnvelope, 0, true);
End;
5.Collect all results;
6.Parallelize the results to generate a RDD in this format: JavaPairRDD<Envelope, HashSet<Point>>.;
7.Return the result RDD;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment