Hot answers tagged

6 votes

Updating ArcPy feature classes

Have you actually profiled your script to be sure that your time issue really is related to the for ... in loops? I'm pretty confident that your timing issue is ...
  • 11.5k
5 votes
Accepted

Updating ArcPy feature classes

Don't repeat yourself First, and of the least significance, Python spend more time building a substring rather than a local variable lookup. Thus you could improve thing a bit by naming ...
4 votes
Accepted

Downloading 2 tables from db, does calculation and uploads resulting table

I know, that you know, that your code is messy, but I'm still going to give some tips on your coding style. Here are a few tips I have on what can be improved there. Don't use ...
4 votes
Accepted

Arcpy script to check for TIFF files and add them to different lists

You want to learn what a dictionary is, and store your rasters in it. With Python this is pretty simple, to make a dictionary that when you ask for an apple gives you a 'red apple' you could do: <...
  • 41.8k
4 votes
Accepted

File names to database table

folder = r'\\my\network\folder' subfolder_list = [r'\DRAWINGS', r'\DOCUMENTS', r'\VIDEOS'] Don't write the type into the variable name. The type should be able to ...
4 votes
Accepted

Reading from a database and comparing values

Assuming pathTwoList is listTwo, pathOneList is listOne.....
  • 17.1k
3 votes

Raster processing for climate change model

First, fix the bug! You're using sys.exc_info()[-1].tb_lineno but you're not importing the sys module anywhere, so do that ...
3 votes
Accepted

Python toolbox for OpenStreetMap data

Some minor stuff: I don't see where self.tools is used after initialization - can it be deleted? If you need to keep it, does it need to change? If it doesn't ...
  • 54.4k
2 votes
Accepted

ArcPy script to analyze land use in counties

Main Use an helper function to separate unit of work. Namely, I would use a function performing the required operations on a county and call it from main. ...
2 votes

Join ArcGIS tables in Python of plant greenness in response to prior month's rainfall

You should do a maintainability pass before you start optimizing. In that spirit: Imports from datetime import datetime import dateutil.relativedelta should be ...
  • 54.4k
2 votes

Python code for buffer creation and intersection

Don't confuse module and module symbol imports You wrote this: import datetime from datetime import datetime which is both confusing and unnecessary. It doesn't ...
  • 54.4k
1 vote

Python code for buffer creation and intersection

Reading this code, two immediate things came to mind: use multi-assignments. Instead of: ...
  • 2,296
1 vote
Accepted

Python code for buffer creation and intersection

Congratulations on the development. I have been able to verify some lines of code that can be better managed with the module "os" in order to take advantage of it more since you have it imported. I ...
1 vote
Accepted

Creating Access tables based on a comparison of tables from ArcMaps

There are a lot of debug prints in your code snippet. I will mark them with a D-> if I can't see any use for the end user. I would opt for removing them. ...

Only top scored, non community-wiki answers of a minimum length are eligible