AnsweredAssumed Answered

Create multiple Mxd and export it to JPEG using ArcPy

Question asked by india123 on Jul 1, 2017
Latest reply on Jul 3, 2017 by india123

Hi All, 


I am working on daily rainfall data. I have multiple rasters map for different dates. I want to convert those map into JPEG format along with all layouts (Title, Legend, North arrow, scalebar etc). Already i made a map by manually which i attached below with my sample datasets.

I have numbers of datasets for different dates, therefore, i want to do it using Arcpy to create the different date wise map and export it to JPEG format. How to do it in ArcPy environment. 


I have one script but that is for converting multiple mxd to JPEG, but to create automatically mxd files along with all layouts based on multiple date wise rasters and then export it to JPEG, I am getting trouble to make it. 


I have attached below my sample datasets which I am working. One output map also attached with the sample data sets, which I made by manually. But instead of manually i just take the whole part in ArcPy. 


Thank you in advance. 


import arcpy, os

folderPath = r"D:\data\sample_data" 
for filename in os.listdir(folderPath): 
fullpath = os.path.join(folderPath, filename) 
if os.path.isfile(fullpath): 
    basename, extension = os.path.splitext(fullpath) 
    if extension.lower() == ".mxd": 
        mxd = arcpy.mapping.MapDocument(fullpath) 
        arcpy.mapping.ExportToJPEG(mxd, basename + '.jpg', resolution = 300)