I cannot run a weighted sum or overlay because I get the message that I don't have the cell size set--but I do in fact have it set. Here's the python for my entire process (copied from a model)--and you can see that I set it. Anyone else having this issue?
... # Import arcpy module
... import arcpy
...
...
... # Local variables:
... PolytoPointCensus = "PolytoPointCensus"
... ZCrimeCalls = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZCrimeCalls"
... PolytoPointCensus__3_ = "PolytoPointCensus"
... ZPoverty_Rate = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPovertyRate"
... PolytoPointCensus__2_ = "PolytoPointCensus"
... ZPublic_Housing = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPublicHousing"
... Weighte_ZCri1 = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\Weighte_ZCri1"
...
... # Process: Crime calls Kernel Density
... arcpy.gp.KernelDensity_sa(PolytoPointCensus, "ZCrimeCalls", ZCrimeCalls, "50", "5280", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
...
... # Process: Poverty Kernel Density
... arcpy.gp.KernelDensity_sa(PolytoPointCensus__3_, "ZPovRate", ZPoverty_Rate, "50", "5280", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
...
... # Process: Public Housing Kernel Density
... arcpy.gp.KernelDensity_sa(PolytoPointCensus__2_, "ZPublicHousing", ZPublic_Housing, "50", "5280", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
...
... # Process: Weighted Sum
... tempEnvironment0 = arcpy.env.cellSize
... arcpy.env.cellSize = "50"
... tempEnvironment1 = arcpy.env.mask
... arcpy.env.mask = "Little Rock Municipal Boundary"
... arcpy.gp.WeightedSum_sa("C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZCrimeCalls VALUE 0.33;C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPovertyRate VALUE 0.33;C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPublicHousing VALUE 0.33", Weighte_ZCri1)
... arcpy.env.cellSize = tempEnvironment0
... arcpy.env.mask = tempEnvironment1
...
...
Runtime error Traceback (most recent call last): File "<string>", line 36, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) ExecuteError: ERROR 010050: Cell size is not set. Failed to execute (WeightedSum).
The model is a tad out of order, which happens when you export a model to a script without rearranging the parameters and functions. I think that the problem resides towards the bottom of the script. I would comment out these lines near the bottom
tempEnvironment0 = arcpy.env.cellSize
arcpy.env.cellSize = tempEnvironment0
and move this near the top under ... import arcpy ... arcpy.env.cellSize = "50"
I'm not so great at python...but like this? If so, it still failed. It fails when I run the stand alone tools, too. And thank you for your reply!
... import arcpy
... arcpy.env.cellSize = "50"
...
... # Local variables:
... PolytoPointCensus = "PolytoPointCensus"
... ZCrimeCalls = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZCrimeCalls"
... PolytoPointCensus__3_ = "PolytoPointCensus"
... ZPoverty_Rate = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPovertyRate"
... PolytoPointCensus__2_ = "PolytoPointCensus"
... ZPublic_Housing = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPublicHousing"
... Weighte_ZCri1 = "C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\Weighte_ZCri1"
...
... # Process: Crime calls Kernel Density
... arcpy.gp.KernelDensity_sa(PolytoPointCensus, "ZCrimeCalls", ZCrimeCalls, "50", "5280", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
...
... # Process: Poverty Kernel Density
... arcpy.gp.KernelDensity_sa(PolytoPointCensus__3_, "ZPovRate", ZPoverty_Rate, "50", "5280", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
...
... # Process: Public Housing Kernel Density
... arcpy.gp.KernelDensity_sa(PolytoPointCensus__2_, "ZPublicHousing", ZPublic_Housing, "50", "5280", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
...
... # Process: Weighted Sum
... # tempEnvironment0 = arcpy.env.cellSize
... tempEnvironment1 = arcpy.env.mask
... arcpy.env.mask = "Little Rock Municipal Boundary"
... arcpy.gp.WeightedSum_sa("C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZCrimeCalls VALUE 0.33;C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPovertyRate VALUE 0.33;C:\\SpatialAnalysisClassProject\\LR911Calls.gdb\\ZPublicHousing VALUE 0.33", Weighte_ZCri1)
... # arcpy.env.cellSize = tempEnvironment0
... arcpy.env.mask = tempEnvironment1
...
...
Runtime error Traceback (most recent call last): File "<string>", line 35, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) ExecuteError: ERROR 010050: Cell size is not set. Failed to execute (WeightedSum).
kernel density needs numbers ie KernelDensity("rec_sites.shp", "NONE", 45, 1200, "SQUARE_KILOMETERS")
weighted sum syntax seems off
What version of arcmap? compare your syntax with that of the help file. I would start with your arcpy syntax found in the help files and skip the model output.
I used the syntax from the help file and pretty much got the same thing. I wonder if anyone else is having problems running the weighted sum tool. Can you try? I am using 10.4
>>> # Import system modules
... import arcpy
... from arcpy import env
... from arcpy.sa import *
...
... # Set environment settings
... env.workspace = "C:/SpatialAnalysisClassProject/LR911Calls.gdb"
...
... # Set local variables
... inRaster1 = "ZPublicHousing"
... inRaster2 = "ZCrimeCalls"
... inRaster3 = "ZPovertyRate"
... WSumTableObj = WSTable([[inRaster1, "VALUE", 0.33], [inRaster2, "VALUE", 0.33],
... [inRaster3, "VALUE", 0.33]])
...
... # Check out the ArcGIS Spatial Analyst extension license
... arcpy.CheckOutExtension("Spatial")
...
... # Execute WeightedSum
... outWeightedSum = WeightedSum(WSumTableObj)
...
... # Save the output
... outWeightedSum.save("C:/SpatialAnalysisClassProject/LR911Calls.gdb/weightsumout")
...
Runtime error Traceback (most recent call last): File "<string>", line 20, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Functions.py", line 6787, in WeightedSum in_weighted_sum_table) File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Utils.py", line 53, in swapper result = wrapper(*args, **kwargs) File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Functions.py", line 6784, in Wrapper out_raster) File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) ExecuteError: ERROR 010050: Cell size is not set. Failed to execute (WeightedSum).
I got it to work by changing the workspace environments to the default gdb. I ran the tool and didn't select any options for cell size and it ran using MAXOF which I guess is the default. Oddly enough, when I ran it again, I selected a cell size of 50 and it failed with the error that I didn't set the size. I'm pretty sure something is up with it and I think it may be related to this thread.
python - Multiprocessing issues with ArcPy - Geographic Information Systems Stack Exchange
another reason that it may have failed is that you were using data in a geographic coordinate system and specifying a cell size in planar units... 50 may be interpreted as 50 degrees in that case .. and there would be no reason to set background or multiprocessing in any event.