<?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: How to get attributes using GPS coordinate from webmap in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344374#M9220</link>
    <description>&lt;P&gt;Hey, I get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Location: Jalan Jabatan Perhutanan, Keningau, Bahagian Keningau, 89000, Sabah, MYS
KODDUN: N.40, NAMADUN: BINGKOR, PARLIMEN: KENINGAU
KODDUN: N.40, NAMADUN: BINGKOR, PARLIMEN: KENING&amp;nbsp;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Nov 2023 13:47:38 GMT</pubDate>
    <dc:creator>EarlMedina</dc:creator>
    <dc:date>2023-11-01T13:47:38Z</dc:date>
    <item>
      <title>How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1343647#M9209</link>
      <description>&lt;P&gt;Hi, currently i'm working with webmap and i want to find an attributes in the webmap by using GPS coordinate&lt;/P&gt;&lt;P&gt;output expected&amp;nbsp; :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Location: Jalan Jabatan Perhutanan, Keningau, Bahagian Keningau, 89000, Sabah, MYS
KODDUN: N.04, NAMADUN: TANJONG KAPOR&lt;/PRE&gt;&lt;P&gt;output that i obtaint :&lt;/P&gt;&lt;P&gt;it print out all the attributes instead of the one that match with coordinate.&lt;/P&gt;&lt;PRE&gt;Location: Jalan Jabatan Perhutanan, Keningau, Bahagian Keningau, 89000, Sabah, MYS
KODDUN: N.04, NAMADUN: TANJONG KAPOR
KODDUN: N.03, NAMADUN: PITAS
KODDUN: N.05, NAMADUN: MATUNGGONG
KODDUN: N.06, NAMADUN: BANDAU
KODDUN: N.09, NAMADUN: TEMPASUK&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code :&amp;nbsp;&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;import arcgis&lt;BR /&gt;from arcgis.geometry import Geometry&lt;BR /&gt;from arcgis.geocoding import reverse_geocode&lt;/P&gt;&lt;P&gt;gis = GIS()&lt;/P&gt;&lt;P&gt;webmap_item_id = "0c7d9a944a5a476694a2f998d53e3e1e"&lt;BR /&gt;webmap_item = gis.content.get(webmap_item_id)&lt;BR /&gt;webmap_data = webmap_item.get_data()&lt;/P&gt;&lt;P&gt;longitude = 116.157966&lt;BR /&gt;latitude = 5.341622&lt;BR /&gt;given_coord = {'x': longitude, 'y': latitude, "spatialReference": {"wkid": 4326}}&lt;BR /&gt;point_geom = Geometry(given_coord)&lt;/P&gt;&lt;P&gt;location_details = reverse_geocode([longitude, latitude])&lt;BR /&gt;place_name = location_details.get('address', {}).get('LongLabel', 'Unknown Location')&lt;BR /&gt;print(f"Location: {place_name}")&lt;/P&gt;&lt;P&gt;if 'operationalLayers' in webmap_data:&lt;BR /&gt;for layer in webmap_data['operationalLayers']:&lt;BR /&gt;if 'featureCollection' in layer:&lt;BR /&gt;for layer_collection in layer['featureCollection']['layers']:&lt;BR /&gt;for feature in layer_collection['featureSet']['features']:&lt;BR /&gt;attributes = feature['attributes']&lt;BR /&gt;geometry = feature['geometry']&lt;BR /&gt;koddun = attributes.get("KODDUN")&lt;BR /&gt;namadun = attributes.get("NAMADUN")&lt;BR /&gt;parlimen = attributes.get("PARLIMEN")&lt;BR /&gt;&lt;BR /&gt;# Fetch GPS coordinates&lt;BR /&gt;if 'x' in geometry and 'y' in geometry:&lt;BR /&gt;longitude = geometry['x']&lt;BR /&gt;latitude = geometry['y']&lt;BR /&gt;print(f"KODDUN: {koddun}, NAMADUN: {namadun}, PARLIMEN: {parlimen}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"KODDUN: {koddun}, NAMADUN: {namadun}")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope someone can help me because this is my first time using API&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 03:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1343647#M9209</guid>
      <dc:creator>AENA</dc:creator>
      <dc:date>2023-11-07T03:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344153#M9213</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;If I understand what you are trying to do correctly, you are quite close and just need to add a geometry function to figure out if the input point is within the geometry. You may use Geometry (which will parse the type for you), but I will use Polygon and Point so it is more explicit what is going on. I'm not sure what the intention was with the else statement, so you may need to adjust further:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcgis
from arcgis.geometry import Point, Polygon
from arcgis.geocoding import reverse_geocode

gis = GIS()

webmap_item_id = "0c7d9a944a5a476694a2f998d53e3e1e"
webmap_item = gis.content.get(webmap_item_id)
webmap_data = webmap_item.get_data()

longitude = 116.157966
latitude = 5.341622
given_coord = {"x": longitude, "y": latitude, "spatialReference": {"wkid": 4326}}
point_geom = Point(given_coord)

location_details = reverse_geocode([longitude, latitude])
place_name = location_details.get("address", {}).get("LongLabel", "Unknown Location")
print(f"Location: {place_name}")

if 'operationalLayers' in webmap_data:
    for layer in webmap_data['operationalLayers']:
        if 'featureCollection' in layer:
            for layer_collection in layer['featureCollection']['layers']:
                for feature in layer_collection['featureSet']['features']:
                    attributes = feature['attributes']
                    geometry = feature['geometry']
                    koddun = attributes.get("KODDUN")
                    namadun = attributes.get("NAMADUN")
                    parlimen = attributes.get("PARLIMEN")
                    # Fetch GPS coordinates
                    if "rings" in geometry:
                        poly_geom = Polygon(geometry)
                        if point_geom.within(poly_geom):
                            print(f"KODDUN: {koddun}, NAMADUN: {namadun}, PARLIMEN: {parlimen}")
                    else:
                        print(f"KODDUN: {koddun}, NAMADUN: {namadun}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 18:22:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344153#M9213</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-11-06T18:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344271#M9216</link>
      <description>&lt;P&gt;Hello, thankyou for the replied.&lt;/P&gt;&lt;P&gt;may I know if you get the expected output?&lt;/P&gt;&lt;P&gt;I've tried to run the code, but seems like it's not working correctly because I only get the location name but not the attributes(KODDUN, NAMADUN).&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 06:49:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344271#M9216</guid>
      <dc:creator>AENA</dc:creator>
      <dc:date>2023-11-01T06:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344374#M9220</link>
      <description>&lt;P&gt;Hey, I get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Location: Jalan Jabatan Perhutanan, Keningau, Bahagian Keningau, 89000, Sabah, MYS
KODDUN: N.40, NAMADUN: BINGKOR, PARLIMEN: KENINGAU
KODDUN: N.40, NAMADUN: BINGKOR, PARLIMEN: KENING&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Nov 2023 13:47:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344374#M9220</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-11-01T13:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344797#M9227</link>
      <description>&lt;P&gt;Hai, I'm sorry if I ask you a lot of question because this is my first time using python API.&lt;/P&gt;&lt;P&gt;I've tried to run the code that you share, but I only get the location name. may I know why?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 05:29:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1344797#M9227</guid>
      <dc:creator>AENA</dc:creator>
      <dc:date>2023-11-06T05:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1345941#M9240</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1060"&gt;@VinceAngelo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you help me with this one.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 04:00:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1345941#M9240</guid>
      <dc:creator>AENA</dc:creator>
      <dc:date>2023-11-06T04:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1346249#M9242</link>
      <description>&lt;P&gt;The only thing that comes to mind is you may be on a differen version of the API? I re-ran the code and came out with the exact same output.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 18:23:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1346249#M9242</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-11-06T18:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1346463#M9246</link>
      <description>&lt;P&gt;may i know what version and platform to run the code that you use ?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 02:33:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1346463#M9246</guid>
      <dc:creator>AENA</dc:creator>
      <dc:date>2023-11-07T02:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1346498#M9247</link>
      <description>&lt;P&gt;btw, I'm using google colaboratory to run the code.&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 00:37:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1346498#M9247</guid>
      <dc:creator>AENA</dc:creator>
      <dc:date>2023-11-08T00:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get attributes using GPS coordinate from webmap</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1347332#M9267</link>
      <description>&lt;P&gt;2.1.0 is the version, I believe.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 19:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-attributes-using-gps-coordinate-from/m-p/1347332#M9267</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-11-08T19:03:50Z</dc:date>
    </item>
  </channel>
</rss>

