-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requesting the Multi part to Single part support. #35
Comments
ST_Geometry for Hive in Spatial Framework is designed based on the OGC specification (GIS Simple feature access SQL option); this issue may effectively request extensions to ST_Geometry. Workaround 1 - ST_NumGeometries and ST_GeometryN: Store the intermediate results. For each multi-part geometry in the intermediate results: for 1 to ST_NumGeometries (perhaps with a generated script), call ST_GeometryN(index). Workaround 2 - ArcMap: for those who have ArcMap, store intermediate results in JSON, import the JSON to features in ArcMap (with Geoprocessing Tools for Hadoop), then perform further geoprocessing in ArcMap. Sample: Vehicle Trip Discovery with GIS Tools for Hadoop - Import into ArcMap and Visualize Workaround 3: custom MapReduce job: instead of using Hive, use a custom MapReduce job, and call Geometry-API-java directly. As an alternative to approaches specific to Spatial Framework for Hadoop, there may be an approach which is generic to hive - such as something like generate_series (as in PostgreSQL - for use with ST_GeometryN and ST_NumGeometries). As stated here on Github, pull requests are welcome, if someone would like to implement an enhancement to Spatial Framework for Hadoop. |
More on: Workaround 1 - ST_NumGeometries and ST_GeometryN: |
Question regarding work-around 1 :
|
The Array (or a general generate_series() function for hive) would make it more convenient (workaround 1), possibly a single SQL statement. However, I think it is possible with some resourcefulness to use some scripting and ST_NumGeometries and ST_GeometryN from current ST_Geometry for Hive, to achieve the desired result. Something like:
|
Lateral view can be used to select multiple columns when using a UDTF such as explode: select rn, ST_AsText(ST_GeometryN(shape,rn)) from test1 lateral view explode(array(1,2,3)) sub as rn; |
Is this something I can do using query or I have have implement respective to get one by one geometry from the MULTIPOLYGON geometry? |
The sample query posted this morning 2 comments above, if table test1 contains one row with a MultiPolygon of 3 parts in its "shape" column, will output 3 rows of index number and single-part polygon, like: |
Above example is useful, I am able to resolve half portion of my issue. select test_dissolve.id, rn, ST_AsText(ST_GeometryN(test_dissolve.shape)) from test_dissolve lateral view explode(array(1,2,3)) sub as rn; Issue in this query is array parameters are static which should be dynamic. In order to make it happen I think I need to write UDTF which have behave like for loop. |
Yes, exactly. Options include:
|
@randallwhitman : I would like to thank you for the nice idea of creating UDTF for generate_series I have implemented generate_series UDTF which can accepts 3 arguments star,stop and increment. here is the example query: SELECT test_dissolve.key, rn, ST_AsText(ST_GeometryN(test_dissolve.shape,rn)) FROM test_dissolve lateral view generate_series(1,ST_NumGeometries(test_dissolve.shape),1) sub as rn where ST_NumGeometries(test_dissolve.shape) is not null; |
Excellent Dharmesh, great to hear that generate_series is implemented. If you would like to contribute the enhancement to Hive at hive.apache.org, it will be useful to more people and in more situations. (Or if you prefer I guess you could just post it in your own Github repository. Either way, if you choose to, it would be great if you would like to post a link from here in this issue.) |
Yes, I would like to contribute the enchancement to Hive at Could you please give me how can to that? Regards, Dharmesh On Tue, Oct 8, 2013 at 11:49 AM, Randall Whitman
Regards, Dharmesh PurohitCell : +1-563-370-1367 |
Sounds great. Take a look at http://hive.apache.org/issue_tracking.html - that should help get you started - given that you've already implemented generate_series, you could file an enhancement and then immediately attach the source code as a patch. |
Great , I would do so. Thank you. On Tue, Oct 8, 2013 at 1:20 PM, Randall Whitman notifications@github.comwrote:
Regards, Dharmesh PurohitCell : +1-563-370-1367 |
@dharmeshpurohit - curious if you have had any success in offering |
I am planning to add it may be this weekend I will get chance to work on unit test for the generate_series. |
Sounds good :) |
Closing as it sounds like the request is resolved. @dharmeshpurohit: please go ahead and comment any updates on contributing the generate-series enhancement to Apache Hive, even though this issue is closed. |
I am working on dissolve functionality and I used ST_Aggr_Union to achieve the dissolve result. I am getting the result as multi-part result.
I am looking for some function which may provide single-part result or may convert into single-part polygon from multi-part polygon.
Please let me know if further information is needed.
The text was updated successfully, but these errors were encountered: