<?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 How to add Spatial reference to feature service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559156#M73197</link>
    <description>&lt;P&gt;How can i add a spatial reference to a feature service?&lt;BR /&gt;my feature service is not showing&amp;nbsp; a spatial reference when querying the extent&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_0-1731680091546.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119642i21BA422BE36DD0B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_0-1731680091546.png" alt="StuartMoore_0-1731680091546.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if i check another feature service it shows one&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_1-1731680168202.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119643i2B46E59833560D65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_1-1731680168202.png" alt="StuartMoore_1-1731680168202.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think this is the cause of why my intersection or select by location in pro returns 0 results or just fails&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_2-1731680271421.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119645i74F732A04D7591A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_2-1731680271421.png" alt="StuartMoore_2-1731680271421.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2024 14:18:34 GMT</pubDate>
    <dc:creator>StuartMoore</dc:creator>
    <dc:date>2024-11-15T14:18:34Z</dc:date>
    <item>
      <title>How to add Spatial reference to feature service</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559156#M73197</link>
      <description>&lt;P&gt;How can i add a spatial reference to a feature service?&lt;BR /&gt;my feature service is not showing&amp;nbsp; a spatial reference when querying the extent&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_0-1731680091546.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119642i21BA422BE36DD0B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_0-1731680091546.png" alt="StuartMoore_0-1731680091546.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if i check another feature service it shows one&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_1-1731680168202.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119643i2B46E59833560D65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_1-1731680168202.png" alt="StuartMoore_1-1731680168202.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think this is the cause of why my intersection or select by location in pro returns 0 results or just fails&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StuartMoore_2-1731680271421.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119645i74F732A04D7591A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StuartMoore_2-1731680271421.png" alt="StuartMoore_2-1731680271421.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 14:18:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559156#M73197</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2024-11-15T14:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Spatial reference to feature service</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559199#M73198</link>
      <description>&lt;P&gt;I believe you would have to overwrite the service. Try this,&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;import arcpy

#  Your portal connection
arcpy.SignInToPortal("https://www.yourportal.com", "your_username", "your_password")

# URL to the feature service
feature_service_url = "https://services.yourportal.com/your_org/arcgis/rest/services/your_service/FeatureServer/0"

# output location
local_feature_class = r"C:\workspace_path\temp_feature_class.gdb\your_feature_class"

# Define the desired spatial reference spatial reference
desired_spatial_ref = arcpy.SpatialReference(4326)  # WGS 1984

Download the feature service soyou can update
arcpy.FeatureClassToFeatureClass_conversion(
    in_features=feature_service_url,
    out_path="C:\\workspace_path\\temp_feature_class.gdb",
    out_name="your_feature_class"
)

Update spatial reference
arcpy.DefineProjection_management(local_feature_class, desired_spatial_ref)

Overwrite the feature service
arcpy.UploadServiceDefinition_management(
    in_sd_file=r"C:\path_to_your_service_definition.sd",
    in_server="My Hosted Services",
    in_portal_folder="TargetFolder"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 15:35:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559199#M73198</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-11-15T15:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to add Spatial reference to feature service</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559591#M73202</link>
      <description>&lt;P&gt;this for some reason the feature layers are all now showing with a wkid and select by location now works...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;very odd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stu&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 11:15:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-spatial-reference-to-feature-service/m-p/1559591#M73202</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2024-11-18T11:15:53Z</dc:date>
    </item>
  </channel>
</rss>

