I have been using the code below to import shapefiles to ArcGIS Online. It was taken from an ArcGIS tutorial linked here: https://developers.arcgis.com/labs/python/import-data/

from arcgis.gis import GIS

# Log into your ArcGIS Online account
gis = GIS("https://www.arcgis.com", username="your_username", password="your_password")

# Make a dictionary to store metadata for the shapefile
shp_properties = {
    'title': 'Los Angeles Hub Datasets',
    'tags': 'testing, this, with, python, code',
    'type': 'Shapefile'

# Load the data as a feature layer with a ContentManager by calling gis.content.add which returns an Item object.
data_file_location = '/path/to/Parks_and_Open_Space.zip'
shp_file = gis.content.add(shp_properties, data=data_file_location)

# Call the publish method to publihs the Shapefile, which returns another arcgis.gis.Item instance for the feature layer.
shp_feature_layer_item = shp_file.publish()

# Identify the URL

But the tutorial states it can only import CSVs, XLS, GPX, GeoJSON, and shapefiles. Is it not possible to use Python to upload raster data to ArcGIS Online?

1 Answer 1


You can upload hosted tiled layers to AGOL which consist of images in a tile package. The process for doing this is different than uploading content such as the formats you mentioned.

This documentation shows several methods; there are equivalent methods to perform this tile package upload to AGOL using the python API. I recommend that you get familiar with the processes of tile package creation and manually uploading it to AGOL before attempting to script these processes.

Here is the reference documentation for tile package creation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.