I agree with @Paul above - the best way to optimise this code is to ensure that it never runs. If you're happy to install third party packages I'd also take a look at the the formic package, which is a
... Python implementation of Apache Ant FileSet and Globs including the directory wildcard **
(Credit to this answer on SO for pointing me at the library)
Given your parameters, remember that The fastest code is the code that never runs!
Unless your folder hierarchy is very complex, chances are there are some directories you know you can skip. For example, my D: drive, which houses quite a bit of data (~40k files, 1.3k folders, 240GB), contains mostly file geodatabases. We don't need to search those ...
First go to your point layer and click the drop down arrow > perform analysis
Then go to Use Proximity and Create Drivetime Areas, change the measure to Walking Time
Seperate the parameters you need with commas and select overlap to create the rings as in your screenshot.
You can then open this feature layer in desktop for further tweeking such as better ...
The following is an example of how you can use a list comprehension, fnmatch and walk to get at specific files within multiple geodatabases. In this example I specified that I wanted all polygon feature classes with a "poly" prefix. As an added bonus, list comprehensions are blazingly fast compared to stand alone nested for loops.
import arcpy, os, ...
This is how your script should look like. Make sure you understand the 3 items in the tuple returned by the Walk function:
dirpath is the path to the workspace as a string.
dirnames is a list of names of subdirectories and other workspaces in dirpath.
filenames is a list of names of nonworkspace contents (i.e., files) in dirpath.
import arcpy, os, calendar
The usability of the arcpy walk function could definitely be tweaked. It is efficient for listing, but that's it. Any filters massively hamstring it
I like the way you've built a list and then fed it into your GP tool, building a list is fast. As I indicated in my comment you need to have the FULL path to the raster in your list for it to be useful, your mosaic to new dataset can't find each input raster (the list will look like ['woody13','woody13','woody13'..]) which doesn't help. Try it this way:
Some of these points have already been mentioned by others in comments (and you have subsequently fixed some of them already in your updates):
your indenting needs fixing (fixed)
make sure that your splitext does not have a double 't' (fixed)
ensure that your feature dataset ('Brute' or 'Brute_fd'?) exists and has the same coordinate system as the ...
as you can see in the print of your path, you have a missing \ in your path. Instead of using "D:" as input, you should use "D:\\"
also, as mentioned in the comment, you should modify your loop. First, opening the csv could be done only once, so put it outside of the loops.
with open("ListOfDataSources.csv", 'wb') as csvfile:
csvwriter = csv.writer(...
It looks like the error stems from the order of your arguments in the MosaicToNewRaster_management() function. The 3rd argument is "1" which is not a valid coordinate system parameter. Try the following code:
arcpy.MosaicToNewRaster_management (list_raster, output_location, "merged_woody_2013.tif", "","", "", "1", "FIRST", "")
The Project OSRM demo server only provides car directions.
If you want walking directions, you can either use a third-party hosted service (such as that provided by Mapbox, who develop OSRM), or run your own server with the OSRM software and OpenStreetMap data.
Basic but important question: Are you running this python script within ArcMap? Using arcpy.mapping.MapDocument(“CURRENT”) requires to be run within the MXD. It can't be run "outside" of MXD environment.
I agree with reevesii's comment. Try making all caps on “”subject” so it looks like this:
if “SUBJECT” in dataset:
The line Before says the dataset is ...
I believe the string in your if statement needs to be capitalized. The upper() method returns a copy of the string where all case-based characters are uppercased. In order to match the characters in dataset with those in your string, they may need to be capitalized. See string in if statement below.
mxd = arcpy.mapping.MapDocument("CURRENT")
This is the travelling salesman problem, although I'm not sure that you care about returning to the same place as you began. The TSP is NP-Hard: for even a small number of destinations to be visited, there is an incredibly large number of possibilities for an algorithm to consider before it can tell you what the optimal path is. I haven't tried with every ...
As indicated in a comment by @Mike on his question, there has been code provided by @JasonScheirer at GeoNet that will do this:
for dirname, subdirs, items in walk:
new_items = 
for item in items:
description = arcpy.Describe(os.path.join(dirname, item))
Wikipedia also has a Comparison of agent-based modeling software article.
Idrisi is very capable of this, it is less expensive than Arc stuff. You can even use python.
If you are just using python, perhaps a basic distance assigned to each site can be added to the data frame and used for the proximity value in Tobler's law.
I think using the spatial application of Tobler's law, where likelihood of visiting a site based on ...