<?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 Creating a formatted JSON feed in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779990#M1146</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am trying to create a JSON feed from a layer stored in AGO however the coordinates come in as Web Mercator and I need them as WGS84. Using the project function works but is excruciatingly slow&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any other way to achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import json
import time
from arcgis.gis import GIS
from arcgis.geometry import project
gis = GIS(
 profile = "AGOL")#credentials stored in windows identity manager
fc = gis.content.get('LayerID')#layer ID
flayer = fc.layers[0]
fset = flayer.query()

for f in fset.features:
    if f.attributes['GPS_Time'] != None:
        geom=f.geometry['paths'][0] 
        geomarray = []
        for coord in geom:
            geomarray.append({'x':coord[0],'y':coord[1]})
            projectgeom = project(geometries=geomarray, in_sr=3857, out_sr=4326) 
            data={"UploadRequest": {"Projection": 1, "DataLayer": 4, "Issues": [{"Locations": [{"Geometry": projectgeom,"Description": f.attributes['Condition']}],
 "Type": 1,
 "Priority": 3,
 "SourceId": "API-TEST:1",
 "StartTime": f.attributes['GPS_Time'],
 "Url": "https://www.google.com",
 "Description": "This is a test"
 }
 ]
 }
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:54:33 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-12T16:54:33Z</dc:date>
    <item>
      <title>Creating a formatted JSON feed</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779990#M1146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am trying to create a JSON feed from a layer stored in AGO however the coordinates come in as Web Mercator and I need them as WGS84. Using the project function works but is excruciatingly slow&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any other way to achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import json
import time
from arcgis.gis import GIS
from arcgis.geometry import project
gis = GIS(
 profile = "AGOL")#credentials stored in windows identity manager
fc = gis.content.get('LayerID')#layer ID
flayer = fc.layers[0]
fset = flayer.query()

for f in fset.features:
    if f.attributes['GPS_Time'] != None:
        geom=f.geometry['paths'][0] 
        geomarray = []
        for coord in geom:
            geomarray.append({'x':coord[0],'y':coord[1]})
            projectgeom = project(geometries=geomarray, in_sr=3857, out_sr=4326) 
            data={"UploadRequest": {"Projection": 1, "DataLayer": 4, "Issues": [{"Locations": [{"Geometry": projectgeom,"Description": f.attributes['Condition']}],
 "Type": 1,
 "Priority": 3,
 "SourceId": "API-TEST:1",
 "StartTime": f.attributes['GPS_Time'],
 "Url": "https://www.google.com",
 "Description": "This is a test"
 }
 ]
 }
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779990#M1146</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T16:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formatted JSON feed</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779991#M1147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joel,&lt;/P&gt;&lt;P&gt;You don't have to explicitly project all the coordinates. the &lt;STRONG&gt;&lt;EM&gt;query&lt;/EM&gt; &lt;/STRONG&gt;function can do it for you when you specify &lt;STRONG&gt;&lt;EM&gt;out_sr&lt;/EM&gt; &lt;/STRONG&gt;parameter.&lt;/P&gt;&lt;P&gt;Are you trying to get a JSON representation of the layer? I am asking because you didn't specify the &lt;EM&gt;&lt;STRONG&gt;out_fields&lt;/STRONG&gt;&lt;/EM&gt;, the default value is "*" which returns all fields. if this is what you want, it's straightforward to get the JSON representation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fset &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;query&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;out_sr&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4326&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
josn_fset &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fset&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;tojson‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you only want to cherry-pick some information from features in the layer, then get the dict representation&amp;nbsp;and manipulate the dict before converting it to the json format&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; json
dict_fset &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fset&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;to_dict&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# do something on the dict_fset&lt;/SPAN&gt;
josn&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dumps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dict_fset&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Also,&amp;nbsp;you can format the code in your post and make it easy to read, that will increase the change for you to get a correct answer. As we all know, indentation in Python is like { and } in some other languages like Javascript, C/C#, Java etc, formatting (white spaces) is actually essential.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In you code, it seems you performing a projection for every coordinates (you can have tens of thousands of coordinates if polygon or polylines are involved), that's why it's excruciatingly slow.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779991#M1147</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2021-12-12T08:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formatted JSON feed</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779992#M1148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, that is exactly the answer I was looking for. I knew re-projecting each feature was a slow was of doing it but I didn't see another way. I'm just getting started with the API so it's great to know I can bring it in differently.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Mar 2019 19:13:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779992#M1148</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-03-07T19:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formatted JSON feed</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779993#M1149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No worries Joel, I am glad it helped.&lt;/P&gt;&lt;P&gt;could you please promote the answer by marking it as the correct answer so that it might also help others with the same question.Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Mar 2019 00:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/creating-a-formatted-json-feed/m-p/779993#M1149</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2019-03-08T00:42:39Z</dc:date>
    </item>
  </channel>
</rss>

