Skip to main content
added 230 characters in body
Source Link
  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.

You can try this:

for fc in fclist:
    cell = 5
    months =["January","February","March","April","May","June","July","August","September","October","November","December"]
    for month in months:
        output = os.path.join(Dir, ("r_" + fc.rstrip(".shp") + "_" + month + ".tif"))
        arcpy.PolygonToRaster_conversion(fc, month, output, "CELL_CENTER", "", cell)

And if you want to take unique values from field you can try this (field - it's your field from shape file, "MONTH" maybe):

rawValues = [row[0] for row in arcpy.da.SearchCursor(fc, (field))]
months = set(rawValues)
  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.

You can try this:

for fc in fclist:
    cell = 5
    months =["January","February","March","April","May","June","July","August","September","October","November","December"]
    for month in months:
        output = os.path.join(Dir, ("r_" + fc.rstrip(".shp") + "_" + month + ".tif"))
        arcpy.PolygonToRaster_conversion(fc, month, output, "CELL_CENTER", "", cell)
  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.

You can try this:

for fc in fclist:
    cell = 5
    months =["January","February","March","April","May","June","July","August","September","October","November","December"]
    for month in months:
        output = os.path.join(Dir, ("r_" + fc.rstrip(".shp") + "_" + month + ".tif"))
        arcpy.PolygonToRaster_conversion(fc, month, output, "CELL_CENTER", "", cell)

And if you want to take unique values from field you can try this (field - it's your field from shape file, "MONTH" maybe):

rawValues = [row[0] for row in arcpy.da.SearchCursor(fc, (field))]
months = set(rawValues)
Added example code
Source Link
  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.

You can try this:

for fc in fclist:
    cell = 5
    months =["January","February","March","April","May","June","July","August","September","October","November","December"]
    for month in months:
        output = os.path.join(Dir, ("r_" + fc.rstrip(".shp") + "_" + month + ".tif"))
        arcpy.PolygonToRaster_conversion(fc, month, output, "CELL_CENTER", "", cell)
  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.
  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.

You can try this:

for fc in fclist:
    cell = 5
    months =["January","February","March","April","May","June","July","August","September","October","November","December"]
    for month in months:
        output = os.path.join(Dir, ("r_" + fc.rstrip(".shp") + "_" + month + ".tif"))
        arcpy.PolygonToRaster_conversion(fc, month, output, "CELL_CENTER", "", cell)
Source Link

  1. Try not to use concatenation for path. Use os.path.
  2. You are trying to create 12 rasters with the same name. Specify different names for rasters.
  3. Do you iterate shape files in folder? If you do, your output path contains "." in name.