A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/python/latest/api-reference/arcgis.map.html below:

Working with 2D Maps | ArcGIS API for Python

OfflineMapAreaManager
class arcgis.map.OfflineMapAreaManager(item: Item, gis: GIS)

Bases: object

The OfflineMapAreaManager is a helper class to manage offline map areas for a Web Map Item. Objects of this class should not be initialized directly, but rather accessed using the offline_areas property on a Map object.

>>> from arcgis.gis import GIS
>>> from arcgis.map import Map

>>> gis = GIS(profile="your_Web_GIS_profile")

>>> wm_item = gis.content.get("<web map id>")
>>> wm_obj = Map(wm_item)

>>> oma_mgr = wm_obj.offline_areas
<arcgis.map.OfflineMapAreaManager at <memory_addr>>

Note

There are important concepts to understand about offline mapping before the properties and methods of this class will function properly. Both reference basemap and operational layers contained in a Web Map must be configured very specifically before they can be taken offline. See the documentation below for full details:

create(area: str | list | dict[str, Any], item_properties: dict[str, Any] | None = None, folder: str | None = None, min_scale: int | None = None, max_scale: int | None = None, layers_to_ignore: list[str] | None = None, refresh_schedule: str = 'Never', refresh_rates: dict[str, int] | None = None, enable_updates: bool = False, ignore_layers: list[str] | None = None, tile_services: list[dict[str, str]] | None = None, future: bool = False) → Item | PackagingJob

This method creates offline map area items and packages for ArcGIS Runtime powered applications to use. The method creates two different types of Items

  • Map Area items for the specified extent, bookmark, or polygon

  • Map Area Packages corresponding to the operational layer(s) and basemap layer(s) within the extent, bookmark or polygon area

Note

Packaging will fail if the size of the offline map area, when packaged, is larger than 4 GB.

  • If packaging fails, try using a smaller bookmark, extent or geometry for the area argument.

  • If the map contains feature layers that have attachments, you can exclude attachments from the offline package to decrease the package size.

  • If the map includes tile layers, use the tile_services argument to constrain the number of levels included in the resulting packages. This is typically required to reduce the tile package size for the basemap layer(s) in ArcGIS Enterprise.

Note

Only the owner of the Web Map item can create offline map areas.

Parameter

Description

area

Required bookmark, extent, or Polygon object. Specify as either:

  • bookmark name

    >>> wm_item = gis.content.get("<web map id>")
    >>> wm_obj = Map(wm_item)
    
    >>> wm_bookmarks = wm_obj.bookmarks
    >>> area = wm_bookmarks[0]
    
  • extent: as a list of coordinate pairs:

    >>> area = [['xmin', 'ymin'], ['xmax', 'ymax']]
    
  • extent: as a dictionary:

    >>> area = {
                'xmin': <value>,
                'ymin': <value>,
                'xmax': <value>,
                'ymax': <value>,
                'spatialReference' : {'wkid' : <value>}
               }
    
  • polygon: as a Polygon object

Note

If spatial reference is not specified, it is assumed {‘wkid’: 4326}. Make sure this is the same as the spatial reference of the web map, otherwise the creation will fail.

item_properties

Required dictionary. See table below for the keys and values.

folder

Optional string. Specify a folder name if you want the offline map area item and the packages to be created inside a folder.

Note

These items will not display when viewing the content folder in a web browser. They will display in the Portal tab of the Content Pane in ArcGIS Pro.

min_scale

Optional integer. Specify the minimum scale to cache tile and vector tile layers. When zoomed out beyond this scale, cached layers would not display.

Note

The min_scale value is always larger than the max_scale.

max_scale

Optional integer. Specify the maximum scale to cache tile and vector tile layers. When zoomed in beyond this scale, cached layers would not display.

layers_to_ignore

Optional List of layer objects to exclude when creating offline packages. You can get the list of layers in a web map by calling the layers property on the MapContent object.

refresh_schedule

Optional string. Allows for the scheduling of refreshes at given times.

The following are valid variables:

  • Never - never refreshes the offline package (default)

  • Daily - refreshes everyday

  • Weekly - refreshes once a week

  • Monthly - refreshes once a month

refresh_rates

Optional dict. This parameter allows for the customization of the scheduler. The dictionary accepts the following:

{
 "hour" : 1
 "minute" = 0
 "nthday" = 3
 "day_of_week" = 0
}
  • hour - a value between 0-23 (integers)

  • minute - a value between 0-60 (integers)

  • nthday - this is used for monthly only. Thw refresh will occur on the ‘n’ day of the month.

  • day_of_week - a value between 0-6 where 0 is Sunday and 6 is Saturday.

# Example **Daily**: every day at 10:30 AM UTC

 >>> refresh_rates = {
                      "hour": 10,
                      "minute" : 30
                     }

# Example **Weekly**: every Wednesday at 11:59 PM UTC

 >>> refresh_rates = {
                      "hour" : 23,
                      "minute" : 59,
                      "day_of_week" : 4
                     }

enable_updates

Optional Boolean. Allows for the updating of the layers.

ignore_layers

Optional List. A list of individual layers, specified with their service URLs, in the map to ignore. The task generates packages for all map layers by default.

Note

Deprecated, use layers_to_ignore instead.

tile_services

Optional List. An list of Python dictionary objects that contains information about the export tiles-enabled services for which tile packages (.tpk or .vtpk) need to be created. Each tile service is specified with its url and desired level of details.

>>> tile_services = [
                     {
                      "url": "https://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Imagery/MapServer",
                      "levels": "17,18,19"
                     }

Note

This argument should be specified when using ArcGIS Enterprise items. The number of levels included greatly impacts the overall size of the resulting packages to keep them under the 2.5 GB limit.

future

Optional boolean. If True, a future object will be returned and the process will return control to the user before the task completes. If False, control returns once the operation completes. The default is False.

Key:Value Dictionary options for argument item_properties

Key

Value

description

Optional string. Description of the item.

title

Optional string. Name label of the item.

tags

Optional string of comma-separated values, or a list of strings for each tag.

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

Returns:

Map Area Item, or if future=True, a PackagingJob object to further query for results.

# USAGE EXAMPLE #1: Creating offline map areas using *scale* argument

>>> from arcgis.gis import GIS
>>> from arcgis.map import Map

>>> gis = GIS(profile="your_online_organization_profile")

>>> wm_item = gis.content.get("<web_map_id>")
>>> wm_obj = Map(wm_item)

>>> item_prop = {"title": "Clear lake hyperspectral field campaign",
                 "snippet": "Offline package for field data collection using spectro-radiometer",
                 "tags": ["python api", "in-situ data", "field data collection"]}

>>> aviris_layer = wm_item.content.layers[-1]

>>> north_bed = wm_obj.bookmarks.list[-1].name
>>> wm.offline_areas.create(area=north_bed,
                            item_properties=item_prop,
                            folder="clear_lake",
                            min_scale=9000,
                            max_scale=4500,
                            layers_to_ignore=[aviris_layer])

# USAGE Example #2: ArcGIS Enterprise web map specifying *tile_services*

>>> gis = GIS(profile="your_enterprise_profile")

>>> wm_item = gis.content.get("<item_id>")
>>> wm_obj = Map(wm_item)

# Enterprise: Get the url for tile services from basemap
>>> basemap_lyrs = wm_obj.basemap.basemap["baseMapLayers"]
>>> basemap_lyrs

    [
     {'id': '18d9e5e151c-layer-2',
      'title': 'Light_Gray_Export_AGOL_Group',
      'itemId': '042f5e5aadcb8dbd910ae310b1f26d18',
      'layerType': 'VectorTileLayer',
      'styleUrl': 'https:/example.com/portal/sharing/servers/042f5e5aadcb8dbd910ae310b1f26d1/rest/services/World_Basemap_Export_v2/VectorTileServer/resources/styles/root.json'}
    ]

# Get the specific Tile Layer item to see options for levels
>>> vtl_item = gis.content.get(basemap_lyrs[0]["itemId"])
>>> vtl_lyr = vtl_item.layers[0]
>>> print(f"min levels: {vtl_lyr.properties['minLOD']}")
>>> print(f"max levels: {vtl_lyr.properties['maxLOD']}")

    min levels: 0
    max levels: 16

>>> vtl_svc_url = vtl_item.layers[0].url
>>> vtl_svc_url
https:/example.com/portal/sharing/servers/042f5e5aadcb8dbd910ae310b1f26d1/rest/services/World_Basemap_Export_v2/VectorTileServer

# Get a list of bookmark names to iterate through
>>> bookmarks = wm_obj.bookmarks.list()
>>> bkmrk_names = [bookmark.name for bookmark in bookmarks]
>>> bname = bkmrk_names[1]

>>> oma = offline_mgr.create(area=bname,
                             item_properties={"title": bname + "_OMA",
                                              "tags": "offline_mapping,administrative boundaries,parks",
                                              "snippet": bname + " in County",
                                              "description": "Offline mapping area in " + bname + " for sync"},
                             tile_services=[{"url": vtl_svc_url,
                                             "levels": "6,7,8,9,10,11,12,13"}])
>>> oma
<Item title:"County_OMA" type:Map Area owner:gis_user>

>>> # List packages created:
>>> for oma_pkg in oma.related_items("Area2Package", "forward"):
>>>     print(f"{oma_pkg.title:60}{oma_pkg.type}")

<County_Layer-<id_string>                SQLite Geodatabase
<VectorTileServe-<id_string>             Vector Tile Package

Note

This method executes silently. To view informative status messages, set the verbosity environment variable as shown below prior to running the method:

# USAGE EXAMPLE: setting verbosity

>>> from arcgis import env
>>> env.verbose = True
list() → list

Retrieves a list of all Map Area items for the Map object.

Note

Map Area items and the corresponding offline packages share a relationship of type Area2Package. You can use this relationship to get the list of package items cached for each map area item. Refer to the Python snippet below for the steps:

# USAGE EXAMPLE: Listing Map Area Items

>>> from arcgis.gis import GIS
>>> from arcgis.map import Map

>>> wm_item = gis.content.search("*", "Web Map")[0]
>>> wm_obj = Map(wm_item)

>>> all_map_areas = wm.offline_areas.list()
>>> all_map_areas

[<Item title:"Ballerup_OMA", type:Map Area owner:gis_user1>,
 <Item title:"Viborg_OMA", type:Map Area owner:gis_user1>]

# USAGE Example: Inspecting Map Area packages

>>> area1 = all_map_areas[0]
>>> area1_packages = area1.related_items("Area2Package","forward")

>>> for pkg in area1_packages:
>>>     print(f"{pkg.title}")
<<<     print(f"{' ' * 2}{pkg.type}")
>>>     print(f"{' ' * 2}{pkg.homepage}")

VectorTileServe-<value_string>
  Vector Tile Package
  https://<organziation_url>/home/item.html?id=<item_id>


DK_lau_data-<value_string>
  SQLite Geodatabase
  https://organization_url/home/item.html?id=<item_id>
Returns:

A List of Map Area :class`items <arcgis.gis.Item>` related to the Web Map item.

modify_refresh_schedule(item: Item, refresh_schedule: str | None = None, refresh_rates: dict[str, int] | None = None)

The modify_refresh_schedule method modifies an existing offline package’s refresh schedule.

Parameter

Description

item

Required Item object. This is the Offline Package to update the refresh schedule.

refresh_schedule

Optional String. This is the rate of refreshing.

The following are valid variables:

  • Never - never refreshes the offline package (default)

  • Daily - refreshes everyday

  • Weekly - refreshes once a week

  • Monthly - refreshes once a month

refresh_rates

Optional dict. This parameter allows for the customization of the scheduler. Note all time is in UTC.

The dictionary accepts the following:

{ “hour” : 1 “minute” = 0 “nthday” = 3 “day_of_week” = 0 }

  • hour - a value between 0-23 (integers)

  • minute a value between 0-60 (integers)

  • nthday - this is used for monthly only. This say the refresh will occur on the ‘x’ day of the month.

  • day_of_week - a value between 0-6 where 0 is Sunday and 6 is Saturday.

Example Daily:

{ “hour”: 10, “minute” : 30 }

This means every day at 10:30 AM UTC

Example Weekly:

{ “hour” : 23, “minute” : 59, “day_of_week” : 4 }

This means every Wednesday at 11:59 PM UTC

Returns:

A boolean indicating success (True), or failure (False)

## Updates Offline Package Building Everyday at 10:30 AM UTC

gis = GIS(profile='owner_profile')
item = gis.content.get('9b93887c640a4c278765982aa2ec999c')
oa = wm.offline_areas.modify_refresh_schedule(item.id, 'daily', {'hour' : 10, 'minute' : 30})
property offline_properties: dict

This property allows users to configure the offline properties for a webmap. The offline_properties allows for defining how available offline editing, basemap, and read-only layers behave in the web map application. For further reading about concepts for working with web maps offline, see Configure the map to work offline. Also, see the applicationProperties object in the Web Map specification.

Parameter

Description

values

Required Dict. The key/value pairs that define the offline application properties.

The dictionary supports the following keys:

Key

Values

download

Optional string. Possible values:

  • None

  • features

  • features_and_attachments

When editing layers, the edits are always sent to the server. This string argument indicates which data is retrieved from the server.

  • If argument is None - only the schema is written since neither features nor attachments are retrieved

  • If argument is features - a full sync without downloading attachments occurs

  • If argument is features_and_attachments, which is the Default - both features and attachments are retrieved

sync

sync applies to editing layers only. This string value indicates how the data is synced:

  • sync_features_and_attachments - bidirectional sync

  • sync_features_upload_attachments - bidirectional sync for features but upload only for attachments

  • upload_features_and_attachments - upload only for both features and attachments (initial replica is just a schema)

reference_basemap

The filename of a basemap that has been copied to a mobile device. This can be used instead of the default basemap for the map to reduce downloads.

get_attachments

Boolean value that indicates whether to include attachments with the read-only data.

Returns:

Dictionary

# USAGE EXAMPLE

>>> from arcgis.gis import GIS
>>> from arcgis.map import Map

>>> wm_item = gis.content.get("<web_map_id>")
>>> wm_obj = Map(wm_item)

>>> offline_mgr = wm_obj.offline_areas
>>> offline_mgr.offline_properties = {"download": "features",
                                      "sync": "sync_features_upload_attachments"}
update(offline_map_area_items: list | None = None, future: bool = False) → dict | PackagingJob | None

The update method refreshes existing map area packages associated with each of the Map Area items specified. This process updates the packages with changes made on the source data since the last time those packages were created or refreshed. See Refresh Map Area Package for more information.

Parameter

Description

offline_map_area_items

Optional list. Specify one or more Map Area items for which the packages need to be refreshed. If not specified, this method updates all the packages associated with all the map area items of the web map.

Note

To get the list of Map Area items related to the Map object, call the list() method on the OfflineMapAreaManager for the Map.

future

Optional Boolean.

Returns:

Dictionary containing update status.

Note

This method executes silently. To view informative status messages, set the verbosity environment variable as shown below before running the code:

USAGE EXAMPLE: setting verbosity

from arcgis import env
env.verbose = True
PackagingJob
class arcgis.map.offline_mapping.PackagingJob(future, notify=False)

Bases: object

The PackagingJob class represents a Single Packaging Job.

Parameter

Description

future

Required Future object. The async object created by the geoprocessing GPTask.

notify

Optional Boolean. When set to True, a message will inform the user that the geoprocessing task has completed. The default is False.

cancel() → bool

The cancel method attempts to cancel the job.

Note

If the call is currently being executed or finished running and cannot be cancelled then the method will return False, otherwise the call will be cancelled and the method will return True.

Returns:

A boolean indicating the call will be cancelled (True), or cannot be cancelled (False)

cancelled() → bool

The cancelled method retrieves whether the call was successfully cancelled.

Returns:

A boolean indicating success (True), or failure (False)

done() → bool

The done method retrieves whether the call was successfully cancelled or finished running.

Returns:

A boolean indicating success (True), or failure (False)

property elapse_time: timedelta | str

Reports the total amount of time that passed while the PackagingJob ran.

Returns:

The elapsed time

result() → Any

The result method retrieves the value returned by the call.

Note

If the call hasn’t yet completed then this method will wait.

Returns:

An Object

running() → bool

The running method retrieves whether the call is currently being executed and cannot be cancelled.

Returns:

A boolean indicating success (True), or failure (False)

property status: str

Get the GP status of the call.

Returns:

A String


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4