Try explicitly defining the workspace:
arcpy.env.workspace = r'C:\path\to\your\ws'
rasl = arcpy.ListRasters()
The documentation shows that you cannot include the path of your workspace in the ListRaster function:
The workspace environment must be set first before using several of
the List functions, including ListDatasets, ...
You just need to include the root path with the shapefile "file" name. os.walk returns the root and then either the directory or file for every element in each folder - meaning that for each file variable in the loop, the name is only "somefile.shp" without any path information, which arcpy needs to process. So an additional line will get this to work as ...
This is because the Layer to KML tool takes either LAYERS (feature layers in a map for example), or LAYER FILES (.lyr files on disk pointing at featureclasses).
If you want to run this as a script outside of ArcMap you'll have to run MakeFeatureLayer on every shapefile, turning them into a layer first and pass that onto Layer to KML.
This is starter code......
So currently you're using the input of your shape file name but not indicating a directory. The full path is needed for the merge to work. Or you can set your environment's workspace each time you find a file. You're also not actually merging anything, since you have only a single input.
I'd populate a list of all the matches found, so that you can use it ...
From the ArcGIS help:
The Raster Calculator tool is intended for use in the ArcGIS Desktop application only as a GP tool dialog box or in ModelBuilder. It is not intended for use in scripting and is not available in the ArcPy Spatial Analyst module.
You need to use the Spatial Analyst module map algebra syntax instead.
My initial thought is that you must have assigned the variable pente_Rclass to a string representation of a raster instead of a raster object. This would cause your first error. See below:
pente_Rclass = "myRasterName"
represents a string... if you are using this in arcpy methods, it will automatically assume that this string is the name of a dataset in ...
Might as well makes this an answer.
The Project method/tool works with vector data only. To reproject a raster, you need to use the Project Raster tool. That is, the ProjectRaster_management method. The help topic for ArcGIS for Desktop 10.2 is here. Here's the arcpy sample from the help:
from arcpy import env
I was able to replicate your problem, but found a solution. You have to remove the datasets that are used by Terrain dataset first before you can delete it. A bit weird but that seems the way it must work...
So the following code completely removed the FeatureDataset containing the Terrain datasets and the FeatureClass used to construct it. The order that ...
Setting the output of a geoprocessing tool to an emtpy arcpy.geometry object is not the standard method for using in-memory workspaces. Instead, you want to set the output of the Union to a string variable that references the "file name" of the in-memory feature dataset, almost exactly as if you were using a shapefile. The only difference is that instead of ...
You cant create a feature layer on disk, it is stored in memory only.
sortedftr = 'C:/Users/srcha/Desktop/Cluster_Analysis/output/Ld_Play_extra_sort_ftr.shp'
sortedftr = 'sortedftr_lyr'
After the selection if you can use Copy features to convert the layer to a shapefile on disk.
You dont actually need Select by attributes, this can be done ...
I haven't had too much trouble using arcpy on linux so far.
I installed arcgis into the arc users home (this was the default location, and it was recommended one install as the arc user).
As mentioned above in .../arcgis/server/tools you will find a 'python' executable. If you look at that file, you'll see how to run arc's concept of python on linux.
The paths with a single backslash are no valid paths. Use:
one forward slash:
letter r before a string containing a backslash:
There's no "easy" way to do it that I can see unfortunately. I think you've got the right idea with stacking rasters with the correct focal distance and picking the answer. However Spatial Analyst seems a bit slow...
I wrote a quick script to test the times taken if I did the processing in scipy.ndimage (version 0.7 to be compatible with arcpy) to compare ...
It appears the error is encountered on the line for CreateFeatureclass, that the location is bad:
C:\Documents and Settings\benoyn\Desktop\DaS GISwork\data_extraction_test\pleasepleaseplease
And this should have been a string made of:
out_folder_path_gdb + "\" + out_name_gdb
Note that the end component of that string should have been a gdb and it appears ...
An alternative solution may be to use a cursor:
arcpy.UpdateCursor - (http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000064000000)
Calculate Field is nice for in-application use (i.e. changing field values in ArcMap/Catalog or model builder, but cursors are much more powerful (and easier to use) when accessing attribute data in code. Try ...
It works in the python window because JHJ is likely a layer in the map and therefore can be reference in your script as "JHJ". When run outside of Arcmap, you need to tell arcpy where to look. Here are just a few ways you can do this (untested, but it should give you a few ideas):
jhj = arcpy.CreateFeatureclass_management(r"C:\temp\TestArcGis\FraFil","...
As @MichaelMiles-Stimson has mentioned, you can get around this by removing the space in the group layer name.
However as you have mentioned that you have several MXDs and layers already set up, it is a relatively small change to your code (which doesn't seem to touch the space) that will get it working.
The fc from inFeatures is passing a string like "'...
To expand on @GetSpatial's comment, if your Contacts is a Table and not a Feature Class, you will get the 000732 error Contacts does not exist or is not supported Failed to execute (MakeFeatureLayer).
Try changing the arcpy.MakeFeatureLayer() for a arcpy.MakeTableView()
gdb = r"\\My Documents\ArcGIS\Projects\Contact_Table_CleanUp\Test.gdb"
Your model has a lot of what looks to be LAYER input parameters. Meaning the input to the tools have come from the ToC inside Pro. When you run the model outside of Pro (ie. using python at command line), those layers don't exist. Thats what your error screen shot is saying. I cant find the input data
While you aren't really exporting your model to a script,...
I would recommend that you copy the geodatabase first
and then upgrade the geodatabase
arcpy.UpgradeGDB_management("C:/Test/TestGDB2.gdb", "PREREQUISITE_CHECK", "UPGRADE")
ArcPy adds single quotes around parameters that contain spaces. You can use filename.strip("'") to get rid of them. This is safe to use even if there are no single quotes in the string:
>>> filename1=r"'Z:\DATA FOR 2009\Base.gdb\CREEKS_UTM'"
>>> print filename1.strip("'")
The following should work - just run each tool interactively to work out the parameter values, then Copy As Python Snippet each result from the Geoprocessing | Results window into a Python script and your done:
I've modified your code quite a lot below. It is untested but should work as long as your sites.shp has a field ...
I've not used JoinField_management. Every time I want to join I've used AddJoin_management. They appear to do very similar things, so it is possible that the Add Join would work for you.
I am thinking that the problem with your script is that the Join data is of type feature class, not that Python has strong types, but both tools specifically call for layer ...
The help state, regarding Make Feature Layer, that:
the layer that is created by the tool is temporary and will not
persist after the session ends
Simply change the following variables...
Pts_Lyr = scratchWorkspace + "/Pts_Lyr.lyr"
Map_Layer = scratchWorkspace + "/Map_Layer.lyr"
Prism_Lyr = scratchWorkspace + "/Prism_Lyr.lyr"
Pts_Lyr = "...
The attached (untested) script takes the name of a feature class, splits it by "_" and uses that as a basename for the join operations. The general idea is to use:
basename = fc.split("_")
which converts, for example, abc_clip_diss to abc
Then, you can use that basename to create new variables with os.path.join():
inFeatures = os.path.join(ws, ...