<?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 mobile map package for an arbitrary area of interest in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1525072#M71295</link>
    <description>&lt;P&gt;Hi, we are trying to export a part of a map to a mobile map package. My approach looks like that:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import arcpy
from arcgis.geometry import Polygon

root_dir = "C:\\Users\\mobile\\Alex\\Projects\\ArcGIS\\Mist1"
in_aprx = "Mist1.aprx"
map_name = "Map"

project = arcpy.mp.ArcGISProject(os.path.join(root_dir, in_aprx))
world_map = project.listMaps(map_name)[0]

aoi_def = {
"paths" : [[[-97.06138],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]],
[[-97.06326,32.759],[-97.06298,32.755]]],
"spatialReference" : {"wkid" : 4326}
}

aoi = Polygon(aoi_def)

arcpy.management.CreateMobileMapPackage(
in_map = world_map,
output_file = r"c:\\Users\\mobile\\MobileMapPackage1.mmpk",
in_locator = None,
area_of_interest = aoi
)&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately, CreateMobileMapPackage does not accept a polygon as area of interest but requires a full blown feature layer. My question is: How do I programmatically create such a feature layer consisting of 4 pairs or longitude and latitude?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 14:05:35 GMT</pubDate>
    <dc:creator>padmalcom</dc:creator>
    <dc:date>2024-08-21T14:05:35Z</dc:date>
    <item>
      <title>Creating a mobile map package for an arbitrary area of interest</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1525072#M71295</link>
      <description>&lt;P&gt;Hi, we are trying to export a part of a map to a mobile map package. My approach looks like that:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import arcpy
from arcgis.geometry import Polygon

root_dir = "C:\\Users\\mobile\\Alex\\Projects\\ArcGIS\\Mist1"
in_aprx = "Mist1.aprx"
map_name = "Map"

project = arcpy.mp.ArcGISProject(os.path.join(root_dir, in_aprx))
world_map = project.listMaps(map_name)[0]

aoi_def = {
"paths" : [[[-97.06138],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]],
[[-97.06326,32.759],[-97.06298,32.755]]],
"spatialReference" : {"wkid" : 4326}
}

aoi = Polygon(aoi_def)

arcpy.management.CreateMobileMapPackage(
in_map = world_map,
output_file = r"c:\\Users\\mobile\\MobileMapPackage1.mmpk",
in_locator = None,
area_of_interest = aoi
)&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately, CreateMobileMapPackage does not accept a polygon as area of interest but requires a full blown feature layer. My question is: How do I programmatically create such a feature layer consisting of 4 pairs or longitude and latitude?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 14:05:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1525072#M71295</guid>
      <dc:creator>padmalcom</dc:creator>
      <dc:date>2024-08-21T14:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a mobile map package for an arbitrary area of interest</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1525334#M71296</link>
      <description>&lt;P&gt;paths" : [[[-97.06138],[-97.06133,32.8 ....&lt;/P&gt;&lt;P&gt;missing something in the first pair ... is it a copy/paste error or did your code throw and error message&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 19:03:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1525334#M71296</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-08-21T19:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a mobile map package for an arbitrary area of interest</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1527789#M71315</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;,&amp;nbsp;unfortunately the missing value was not the issue, the error remains the same.&lt;/P&gt;&lt;P&gt;I manually created a feature layer in ArcGIS Pro with one single polygon. When I then call the following function, the export seems to start (at least I don't get an error and the process runs for a while now):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.CreateMobileMapPackage(
  in_map = self.world_map,
  output_file = r"c:\\Users\\mobile\\MobileMapPackage1.mmpk",
  in_locator = None,
  area_of_interest = "NameOfMyManuallyCreatedFeatureLayerWithOnePolygon"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;But there MUST be a way to create the area_of_interest programatically, right?&lt;/P&gt;&lt;P&gt;And even when I can't create one, I must be able to edit the existing layer somehow. I tried that using these two functions. First, I get my feature layer using get_layers() which works fine.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;  def get_layers(self):
    layers = self.world_map.listLayers()
    fl = None
    for l in layers:
      print(l.name)
      if (l.isFeatureLayer):
        self.fl = l
        print("Found layer, exiting...")
        break
        
  def get_feature_layer(self):
    print("Feature url:", self.fl.URI)
    rfl = FeatureLayer(self.fl.URI)
    #print("RFL features:", rfl.query())&lt;/LI-CODE&gt;&lt;P&gt;Then I try to convert the Layer instance to a FeatureLayer instance which seems to work fine, but I can not access the features using e.g. featureLayer.query() which fails with an invalid URL. But I don't expect to work with any only map since my map is a local file?&lt;/P&gt;&lt;P&gt;So my goal still is to create a FeatureLayer programatically in python OR edit an existing FeatureLayer. Hope anybody can help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 11:13:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-mobile-map-package-for-an-arbitrary/m-p/1527789#M71315</guid>
      <dc:creator>padmalcom</dc:creator>
      <dc:date>2024-08-27T11:13:11Z</dc:date>
    </item>
  </channel>
</rss>

