Comments (11)
Thanks for the great tool.
I am trying to find intersection area between each polygon in RDD1 and each polygon in RDD2.
I just want know if this function is working. I check the SpatialJoinShp.scala file and see some comments .
//val query = JoinQuery.SpatialJoinQuery(wdpa, species, false, false) // val join_result = query.rdd.map((tuple: (Polygon, util.HashSet[Polygon])) => (tuple._1, tuple._2.asScala.map(tuple._1.intersection(_).getArea)) ) // val intersections = join_result.collect()
I try to compile and run them but get errors. If possible, could you provide a sample code ? Thank you so much.
from sedona.
I suggest you use JoinQuery.SpatialJoinQueryFlat() API. This is a flatMap version of SpatialJoinQuery API. This will make it easier for you to return all intersection.
It will return a <Polygon, Polygon> pair RDD. The two polygons intersect each other.
The following sentence is the correct code to return the intersection of each <Polygon,Polygon> pair. I have tested it.
val resultSize = JoinQuery.SpatialJoinQueryFlat(objectRDD,queryWindowRDD,true,false).rdd.map[Double](f =>f._1.intersection(f._2).getArea)
from sedona.
@jiayuasu
Thanks for your help. It works well.
Could you tell me where to define the "getArea“ function? I look through the code but get nothing. (It is my first time to use Geospark library, please forgive me if the question is stupid)
Next step, I plan to find the intersection polygon between any two polygons in RDD1 and RDD2. Many thanks if you have any suggestions.
from sedona.
Hi @MikeChenfu ,
To get the intersection polygon, you just don't call getArea.
The code is something like this:
val result = JoinQuery.SpatialJoinQueryFlat(objectRDD,queryWindowRDD,true,false).rdd.map[Geometry](f =>f._1.intersection(f._2))
getArea code is in JTSplus, a customized JTS library for GeoSpark. It is not GeoSpark repository. Its own repo is here:
https://github.com/jiayuasu/JTSplus
Original JTS repo is here:
https://github.com/locationtech/jts
from sedona.
@jiayuasu
JoinQuery.SpatialJoinQueryFlat returns nothing when I use csv File instead of Shapefile. I may make something wrong.
The code is to get data from CSV file(WKT format).
val objectRDD = new PolygonRDD(sc, PolygonRDDInputLocation, PolygonRDDStartOffset, PolygonRDDEndOffset, PolygonRDDSplitter, true) val queryWindowRDD = new PolygonRDD(sc, PolygonRDDInputLocationT, PolygonRDDStartOffset, PolygonRDDEndOffset, PolygonRDDSplitter, true)
And I analyze them according to the mention of compiler.
objectRDD.analyze(); queryWindowRDD.analyze(); objectRDD.spatialPartitioning(GridType.QUADTREE) queryWindowRDD.spatialPartitioning(wdpa.partitionTree)
The return value is NULL when I use JoinQuery.SpatialJoinQueryFlat. I think it should be return a <Polygon, Polygon> pair RDD.
val result1 = JoinQuery.SpatialJoinQueryFlat(objectRDD,queryWindowRDD,false,false) result1.take(1).foreach(line => println(line))
from sedona.
@MikeChenfu
Why did you partition your queryWindowRDD using wdpa.partitionTree instead of objectDD.getPartitioner?
from sedona.
@jiayuasu
It is a typo. "wapa" is the used name of objectDD. I am so sorry for that.
objectRDD.spatialPartitioning(GridType.QUADTREE) queryWindowRDD.spatialPartitioning(objectRDD.getPartitioner)
objectDD contains 6 polygons and queryWindowRDD also contains 6 polygons. I am trying to find the problems. I really appreciate it if you have any suggestions.
from sedona.
@MikeChenfu Are you sure your polygons have intersection? We can chat over GeoSpark GitterChat for a faster communication.
from sedona.
@jiayuasu
Thanks for your kind help. I am still working on it and may find the problems.
When JoinQuery.SpatialJoinQueryFlat(objectRDD,queryWindowRDD,true,true) is used, I will get correct result.
from sedona.
Ohhhh! I forgot to tell you, the last parameter in SpatialJoinQueryFlat is ConsiderBoundaryIntersection.
You must set it as "true" in order to find intersected polygon. Otherwise it will only return polygon that are full contained by the other one.
The API explanation is here: http://www.public.asu.edu/~jiayu2/geospark/javadoc/0.9.1/
from sedona.
@jiayuasu
Got it. Many thanks for your kind help.
from sedona.
Related Issues (20)
- Write a geotiff raster , but just found _SUCCESS file in output HDFS dir HOT 3
- Noisy warnings on optional imports
- Map RDD and GeometryType (not an instance of type GeometryType()) HOT 2
- When I resample a raster to very width*height raster , Serde.serialize is limited in 2GB HOT 2
- When I use Bicubic alg to resample a raster with no data pixel , the output raster would be filled unexpected data in no data pixel HOT 3
- fieldNames - AttributeError: Not available before 1.0.0 sedona version HOT 4
- Undeclared IPython dependency HOT 1
- GeometryType(geom) triggered an exception HOT 6
- ST_Difference function crashes while working on some geometries HOT 3
- executor logs : WARN factory: Can't load a service for category "Operation"
- Preserve Spatial Partitioning From RDD to Dataframe HOT 2
- issue about function RS_SetBandNoDataValue HOT 1
- ST_Pixelize small polygon error HOT 6
- ST_Pixelize drawing polygon perimeter rather than all pixels in polygon HOT 3
- try 1-N-N performance tuning with LATERAL subquery HOT 2
- ST_SubDivide (Snowflake) fails even on documentation example HOT 8
- create or replace function sedona.* duplication
- Unknown user-defined function SEDONASNOW.SEDONA.ST_DUMP HOT 1
- confuse about ST_DistanceSphere and ST_DistanceSpheroid HOT 1
- Writing to multiple GeoParquet files will not output _metadata HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sedona.