<?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: JSON string input coordinate pairs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505215#M39688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is all Esri stack then you can publish a feature service of your polygons that you're testing for intersection and use the geocode JSON as input to a Query call and check for distance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Sep 2015 18:51:06 GMT</pubDate>
    <dc:creator>BruceHarold</dc:creator>
    <dc:date>2015-09-14T18:51:06Z</dc:date>
    <item>
      <title>JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505208#M39681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am unable to properly setup a Toolbox script with a single input parameter to parse a json string.&amp;nbsp; I will be receiving the JSON as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;"rings" : &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;[[-117,34],[-116,34],[-117,33],[-117,34]],&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;[[-115,44],[-114,43],[-115,43],[-115,44]]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp; },&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;"rings" : &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;[[32,17],[31,17],[30,17],[30,16],[32,17]]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 0.5in;"&gt;&lt;SPAN style="color: red;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far I have tried to setup the script/tool with a String parameter and attempted to pull in the coordinate pairs and create a polygon feature but it's treating the entire string as a single value and I'm not sure of the best way to parse it into float values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any input is appreciated&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 17:27:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505208#M39681</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-09-14T17:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505209#M39682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try importing the json module and use json.loads&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 17:46:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505209#M39682</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2015-09-14T17:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505210#M39683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Bruce!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've updated the input json string to incorporate a geoJSON format so that it's easier to just convert to polygons.&amp;nbsp; My task is to return a centroid xy for the input point features (which is why I am attempting to construct a polygon).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below is failing on the arcpy.AsShape()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;feature_info = '{"type": "polygon", "coordinates": [[-117.00,34.00],[-116.00,34.00],[-117.00,33.00],[-117.00,34.00]],"spatialReference" : {"wkid" : 4326}}'
jstr = json.loads(feature_info)
print jstr
inpoly = arcpy.AsShape(jstr) #fails with error: type object argument after * must be a sequence, not a float
pcent = arcpy.Point
pcent = inpoly.centroid
pcx = pcent.X
pcy = pcent.Y&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:09:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505210#M39683</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T22:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505211#M39684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did one using the following code(async)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import urllib
import json
URL&amp;nbsp; = 'your/url'
result = urllib.urlopen(URL).read()
addrData = json.loads(result)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:09:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505211#M39684</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T22:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505212#M39685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh!&amp;nbsp; I see my error!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This has the correct JSON format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;feature_info = '{"type": "polygon", "coordinates": [[[-117.00,34.00],[-116.00,34.00],[-117.00,33.00],[-117.00,34.00]]]}'
jstr = json.loads(feature_info)
print jstr
inpoly = arcpy.AsShape(jstr) #fails with error: type object argument after * must be a sequence, not a float
pcent = arcpy.Point
pcent = inpoly.centroid
pcx = pcent.X
pcy = pcent.Y
print str(pcx) + " / " + str(pcy)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:09:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505212#M39685</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T22:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505213#M39686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Wes!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still not entirely certain how this will all be integrated.&amp;nbsp; I've been asked to create a Geoprocessing Service and my original thought was the calling app would pass in a JSON string (as in my OP).&amp;nbsp; So at the moment I'm just trying to figure out how to just hardcode this as a python script and then eventually publish it as a service.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can you suggest the type of input parameter I should consider?&amp;nbsp; Per your sample, it'd be a "String" representation of the url, correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 18:12:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505213#M39686</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-09-14T18:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505214#M39687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you are correct. It is a string representation, in my case i'm passing 'url?'+'Street=' + address + '&amp;amp;outFields=&amp;amp;maxLocations=&amp;amp;outSR='+str(src)+'&amp;amp;searchExtent=&amp;amp;f=Json' to a published geocoder and getting the x,y to determine if the user is in or out of ball districts(soccer, baseball)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 18:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505214#M39687</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-09-14T18:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505215#M39688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is all Esri stack then you can publish a feature service of your polygons that you're testing for intersection and use the geocode JSON as input to a Query call and check for distance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 18:51:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505215#M39688</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2015-09-14T18:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: JSON string input coordinate pairs</title>
      <link>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505216#M39689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I successfully published the service and able to execute the task, pass in a well-formatted JSON string and return the centroid coordinates.&amp;nbsp; As the service publisher, I'm just going to place the requirements on the application developer to perform the necessary formatting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;note: oh how things have changed and now I'm the "configuration specialist" instead of the "app developer"! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 19:39:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/json-string-input-coordinate-pairs/m-p/505216#M39689</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-09-14T19:39:04Z</dc:date>
    </item>
  </channel>
</rss>

