<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Multipoint to Point in GeoAnalytics Engine Questions</title>
    <link>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1398839#M3</link>
    <description>&lt;P&gt;Thank you loads Sarah, this works great&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 04:33:23 GMT</pubDate>
    <dc:creator>SimonGIS</dc:creator>
    <dc:date>2024-03-21T04:33:23Z</dc:date>
    <item>
      <title>Multipoint to Point</title>
      <link>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1383835#M1</link>
      <description>&lt;P&gt;Pretty sure this is going to be an easy one, but looking for the most efficient way to take a multipoint layer from a&lt;A href="https://services6.arcgis.com/GB33F62SbDxJjwEL/arcgis/rest/services/Vicmap_Features_of_Interest/FeatureServer/1#:~:text=esriGeometryMultipoint" target="_self"&gt; public feature service&lt;/A&gt;&amp;nbsp;where there is ever only one point in each feature, and convert it to point when loading a dataframe.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;url = "https://services6.arcgis.com/GB33F62SbDxJjwEL/arcgis/rest/services/Vicmap_Features_of_Interest/FeatureServer/1"
query = "feature_subtype = 'aged care'"

aged_care_df = spark.read.format("feature-service").load(url)\
    .withColumn("shape", ST.transform("shape", 4326)) \
    .filter(query)&lt;/LI-CODE&gt;&lt;P&gt;This returns a points geometry object:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_0-1708215991606.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/95109i73ACE915A035A87D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_0-1708215991606.png" alt="SimonGIS_0-1708215991606.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have tried using &lt;A href="https://developers.arcgis.com/geoanalytics/sql-functions/st_geometry_n/" target="_self"&gt;ST_GeometryN&lt;/A&gt; to then convert this to a point geometry type.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;attempt1 = aged_care_df.select(ST.geometry_n("shape", 1))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;But this returns a series of nulls:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_1-1708216124126.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/95110i17DBF6FB8FF481A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_1-1708216124126.png" alt="SimonGIS_1-1708216124126.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would like to avoid doing any string manipulation in python, and looking for the best way to convert these into point geometry types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Longer term goal is to end up with a dataframe with an array of points for the &lt;A href="https://developers.arcgis.com/geoanalytics/tools/network-tools/create-routes/#:~:text=A%20DataFrame%20column%20containing%20arrays%20of%20points%20that%20will%20be%20used%20to%20create%20the%20route." target="_self"&gt;setStops&lt;/A&gt; parameter in the Create Routes tool.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2024 00:32:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1383835#M1</guid>
      <dc:creator>SimonGIS</dc:creator>
      <dc:date>2024-02-18T00:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Multipoint to Point</title>
      <link>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1386495#M2</link>
      <description>&lt;P&gt;I'm not sure if this is the most efficient, but it works...&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first thing I noticed was the the feature service you pointed to did actually have some true multipoint features.&amp;nbsp; I checked like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# count number of points
aged_care_df\
    .select(ST.num_geometries("shape").alias("point_count"))\
    .sort("point_count", ascending=False)\
    .show()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;+-----------+
|point_count|
+-----------+
|          2|
|          2|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
|          1|
+-----------+
only showing top 20 rows&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And see there are two records that have 2 points each.&amp;nbsp; It's sort of interesting that the points in each have the same coordinates when I filter and print out just these two records...but, still, they are actually multipoint, so we'll have to deal with that to do the conversion&lt;/P&gt;&lt;LI-CODE lang="c"&gt;+-----------+--------------------------------------------------------------------------------------------+--------+
|point_count|shape                                                                                       |OBJECTID|
+-----------+--------------------------------------------------------------------------------------------+--------+
|2          |{"points":[[145.01641305966146,-36.58713183554724],[145.01641305966146,-36.58713183554724]]}|46169   |
|2          |{"points":[[147.59699327673584,-37.09840182302235],[147.59699327673584,-37.09840182302235]]}|46566   |
+-----------+--------------------------------------------------------------------------------------------+--------+&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the multipoint geometries need to be exploded to convert to points (you can't just cast a multipoint to a point), I used ST_Points to create an array of points for each multipoint, then exploded those, and used ST_Point to turn the coordinates back into point geometries.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All in all, it looked like this - note that I drop the &lt;FONT face="courier new,courier"&gt;point_array&lt;/FONT&gt; that I created as an intermediate step, since I don't need that once I create the point geometry.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aged_care_df2 = aged_care_df.select("*",
 F.explode(ST.points("shape")).alias("point_array"), 
 ST.point(ST.x("point_array"), ST.y("point_array")).alias("geom_point"))\
    .drop("point_array")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That gives me individual records with the original Shape (multipoint) and the new &lt;FONT face="courier new,courier"&gt;geom_point&lt;/FONT&gt; (point).&amp;nbsp; There will be two records with the same OBJECTID and other attributes since those records happened to really have a multipoint feature.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example of one record:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;-RECORD 0----------------------------------------------------------------------
 OBJECTID                | 1519                                                
 ufi                     | 67865934                                            
 pfi                     | 1271613                                             
 feature_id              | 1271613                                             
 parent_feature_id       | null                                                
 feature_type            | care facility                                       
 feature_subtype         | aged care                                           
 feature_status          | null                                                
 name                    | YALLAMBEE LODGE COOMA                               
 name_label              | Yallambee Lodge Cooma                               
 parent_name             | null                                                
 child_exists            | null                                                
 auth_org_code           | 110                                                 
 auth_org_id             | null                                                
 auth_org_verified       | 2023-05-31 17:00:00                                 
 vmadd_pfi               | null                                                
 vicnames_id             | -1959170                                            
 vicnames_status_code    | 11                                                  
 theme1                  | null                                                
 theme2                  | null                                                
 state                   | NSW                                                 
 create_date_pfi         | 2021-06-15 04:20:27                                 
 superceded_pfi          | null                                                
 feature_ufi             | 67865934                                            
 feature_create_date_ufi | 2023-06-27 00:37:13                                 
 create_date_ufi         | 2023-06-27 00:37:13                                 
 shape                   | {"points":[[149.130545553053,-36.220029363958275]]} 
 geom_point              | {"x":149.130545553053,"y":-36.220029363958275}      
only showing top 1 row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps with some ideas on how to move forward with your project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Sarah.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 22:25:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1386495#M2</guid>
      <dc:creator>SBattersby</dc:creator>
      <dc:date>2024-02-24T22:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multipoint to Point</title>
      <link>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1398839#M3</link>
      <description>&lt;P&gt;Thank you loads Sarah, this works great&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 04:33:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoanalytics-engine-questions/multipoint-to-point/m-p/1398839#M3</guid>
      <dc:creator>SimonGIS</dc:creator>
      <dc:date>2024-03-21T04:33:23Z</dc:date>
    </item>
  </channel>
</rss>

