I built a model to import table data, create xy event, kernel density and clip density raster. I would like to export the clipped raster as a JPEG but I am not sure how to write the ExportToJPEG code.

Below is the model exported as a Python script.

# Import arcpy module
import arcpy

# Check out any necessary licenses

# Local variables:
Input_Table = "C:\\Users\\cbriglia\\Desktop\\GIS\\Worksheets\\accidents_jan_2013.xls\\Layer1$"
state_border_shp = "C:\\Users\\cbriglia\\Desktop\\GIS\\Shapefiles\\state_border.shp"
Layer1_pytest4 = "Layer1_pytest4"
Ouput_Feature_Class = "C:\\Users\\cbriglia\\Desktop\\GIS\\Shapefiles\\layer1_pytest4.shp"
Hot_Spot_Output = "C:\\Users\\cbriglia\\Desktop\\GIS\\Shapefiles\\pytest5"
Clip_Output = "C:\\Users\\cbriglia\\Desktop\\GIS\\Shapefiles\\pytest6"

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(Input_Table, "longitude", "latitude", Layer1_pytest4, "GEOGCS['GCS_North_American_1983_CSRS',DATUM['D_North_American_1983_CSRS',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision", "")

# Process: Copy Features
arcpy.CopyFeatures_management(Layer1_pytest4, Ouput_Feature_Class, "", "0", "0", "0")

# Process: Kernel Density
arcpy.gp.KernelDensity_sa(Ouput_Feature_Class, "NONE", Hot_Spot_Output, "4.10886000000002E-03", "3.42405000000002E-02", "SQUARE_MAP_UNITS")

# Process: Clip
arcpy.Clip_management(Hot_Spot_Output, "-73.7275781441499 40.9867050023656 -71.7867901391991 42.0506901260974", Clip_Output, state_border_shp, "-3.402823e+038", "NONE")

you can use the copy raster tool to change the format of your raster. But you canalso write any raster output in jpeg by giving a name that ends with .jpg.

On the other hand, I can see from your NoData value that your data is in float. This format is not supported by jpg. So you should either use jp2000 (.jp2) or reclassify your image in 8 bit.

What we are doing here is exporting the data, not the layer that you view in you dataframe. If you want to export a part of your map in jpeg, see ExportToJPEG() arcpy script failure with arcpy.mapping

| improve this answer | |

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.