HOW TO

Import SVG files into a style file using Python in ArcGIS Pro

Last Published: November 24, 2025

Summary

Scalable Vector Graphics (SVG) is a vector-based image format designed for two-dimensional graphics. SVG files provide several advantages, including resolution-independent scalability, ease of editing, and smaller file sizes compared to raster formats. In ArcGIS Pro, SVG files can be imported and managed within a style file (.stylx) for custom symbol creation. This article provides the workflow to import SVG files into a style file using Python in ArcGIS Pro. Using Python enables quick, scalable batch imports of SVGs with consistent metadata, producing reusable Cartographic Information Model (CIM) style items and offering greater efficiency than manually uploading symbols one at a time.

Procedure

  1. Create folders to store the project and SVG files.
    1. Create a main project folder on the local drive, and within it, create a subfolder. In this example, the subfolder is named 'Symbols'.
    2. Place all SVG files into the 'Symbols' subfolder and ensure each filename has the .svg extension.
Image of file
  1. Open the ArcGIS Pro project.
  2. Create an empty style in the project. Refer to ArcGIS Pro: Create a style in the project for instructions. Save the style in the main project folder alongside the 'Symbols' subfolder.
Image of file
  1. Open the Python window and import the necessary modules.
import os
import sqlite3
import requests
  1. Specify the input folder path, the REST endpoint URL, and the style file path. Replace <folder_path_containing_SVG_files> with the path to the 'Symbols' subfolder, and <style_path> with the path to the style file.
# Path to the folder containing SVG files
folder_path = r"<folder_path_containing_SVG_files>" 

# Generate Symbol URL
url = "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/Symbols/SymbolServer/generateSymbol"

# Connect to the .stylx file as a SQLite database
stylx_path = r"<style_path>"
  1. Establish a database connection to the style file.
conn = sqlite3.connect(stylx_path, timeout=60)    
cursor = conn.cursor() 
print("Connected.") 
  1. Upload the SVG files to the REST endpoint and convert them into the CIM symbol format. Save the converted symbols into the style file.
for filename in os.listdir(folder_path):
  if filename.lower().endswith(".svg"):
    svg_path = os.path.join(folder_path, filename)
    print(f"Found SVG: 	{svg_path}")
    with open(svg_path, "rb") as f:
      files = {
            "svgImage": (filename, f, "image/svg+xml"),
      }
      data = {
            "f": "json"
      }
      resp = requests.post(url, files=files, data=data)
      print("status:", resp.status_code)
      print("body:", resp.content)

new_row = ( 3, # CLASS (symbol class - 3 = Point Symbol) "", # CATEGORY filename, # NAME "Custom Symbol", # TAGS resp.content, # CONTENT (CIM symbol JSON) filename, # KEY ) cursor.execute( "INSERT INTO ITEMS(CLASS, CATEGORY, NAME, TAGS, CONTENT, KEY) VALUES(?,?,?,?,?,?)", new_row, ) print(f"Inserted symbol: {filename}") conn.commit() conn.close() print("All symbols have been added to the .stylx file.")
  1. Run the script.

The following shows the sample script running in ArcGIS Pro.

Image of file

The image below illustrates the SVG files displayed as symbols in the Symbology pane.

Image of file

Article ID: 000038814

Software:
  • ArcGIS Pro

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options