|
POST
|
Your expression is correct (StreetSuffix(!FacilityAddress!)), but nothing in the code block should have '!'s. def StreetSuffix(FacilityAddress):
newString = FacilityAddress.replace('ALLEY','AL')
newString = newString.replace('AL.', 'AL')
newString = newString.replace('AVENUE', 'AV')
....and so on
return newString I made some slight changes to the logic - I think it should work. You need to return the variable, not the function. And no need to import a library unless you use it. There are no calls to anything like re.someFunction(), so you know you don't need to import the re library. EDIT 1: yes, this type of code will replace the 'ST' in 'SHASTA'. Instead, you could include the spaces in the replace call, like: newString = FacilityAddress.replace(' ST ', ' STREET ') This will only replace 'ST' between two spaces. You could do something like this to get at ' ST' at the end of the string: if FacilityAddress[3:] == ' ST':
FacilityAddress.replace(' ST', ' STREET') Note that this will trip up in cases like "JOHN STEINBECK ST" -> "JOHN STREETEINBECK STREET" There are probably a multitude of other gotchas, so unfortunately you'll have to fine-tune along the way. EDIT 2: Now that I think of it, you're probably better off splitting the string (and later, joining back together) into a list and inspecting them individually: def StreetSuffix(FacilityAddress)
list = FacilityAddress.split()
for item in list:
item.replace('ALLEY', 'AL')
item.replace('AL.', 'AL')
return " ".join(list)
... View more
01-29-2015
09:04 AM
|
1
|
8
|
5124
|
|
POST
|
I don't think you can determine the unit by the magnitude of the coordinates. They are just numbers - you could make a custom coordinate system with the origin 1,000,000 times the circumference of the Earth away from your data. How did you decide that your unit is cm, other than they are large numbers? Where did you download this data from? There was surely metadata.
... View more
01-28-2015
11:19 AM
|
0
|
0
|
3027
|
|
POST
|
Here is how to loop through your drive, using Python's os module, to find all the mxds: import os
for root, dirs, files in os.walk('C:/junk'):
for file in files:
if os.path.splitext(file)[1] == '.mxd':
print 'It is an MXD!' ...from here.
... View more
01-28-2015
09:19 AM
|
0
|
2
|
1861
|
|
POST
|
I'm surprised this works in your original script: for pnt in part:
if not pnt: For every time pnt exists in part, if it doesn't exist, do something.
... View more
01-27-2015
05:22 PM
|
0
|
0
|
3686
|
|
POST
|
Can you provide a picture of exactly what you're after?
... View more
01-27-2015
01:07 PM
|
0
|
0
|
585
|
|
POST
|
You can run Raster to ASCII, load/modify spaced-delimited file in spreadsheet software (Excel, perhaps), then convert back to raster with ASCII to Raster. No Arc licensing required. * Xander's Python solution will avoid most of the file conversion glitches and headaches, though.
... View more
01-27-2015
10:23 AM
|
2
|
2
|
10779
|
|
POST
|
It looks like it's having trouble finding numpy. Is there a numpy folder in: C:\Python27\ArcGIS10.2\Lib\site-packages (or wherever your python is)?
... View more
01-26-2015
01:38 PM
|
0
|
1
|
2800
|
|
POST
|
You have two different cases for your dataset list: listDataSet and listDataset. These are two different things in Python.
... View more
01-21-2015
03:16 PM
|
1
|
1
|
876
|
|
POST
|
1 - Summary Statistics tool. Statistics field = area, stat type = sum, case field = habitat code. 2 - Need more information. Suppose in 1980 there was a forest in one polygon, then logged and now agriculture in 2014. Do you want a field that says "1980: Forest, 2014: Agriculture", or something else entirely?
... View more
01-19-2015
03:06 PM
|
0
|
2
|
1673
|
|
POST
|
The red exclamation mark means that the file is not at the location specified as the data source (for example, the layer is pointed to C:/shapefile.shp, but there is no such file). Open the layer properties (double-click on the layer). On the Source tab, choose "Set Data Source..." and navigate to the file location.
... View more
01-19-2015
02:01 PM
|
1
|
0
|
926
|
|
POST
|
I figure if you're clever enough to play around with Python, you should be clever enough to make a backup or suffer the consequences.
... View more
01-15-2015
03:19 PM
|
0
|
1
|
3036
|
|
POST
|
That's my fault. Move the function above the call to the function and it should work. I edited my post above. Also, just a note about your script, you set a value of 100 for x and y shift, and then set both to None in the function definition. So, I would not expect any shift to be observed as it is.
... View more
01-15-2015
03:08 PM
|
1
|
15
|
3036
|
|
POST
|
You need to actually call the shift_features function. As it is, the script executes line 1, then executes line 3, then stops. Everything between 'def' and 'return' is a function just waiting to be called. Your script should look like this: import arcpy
in_features = r"C:/Temp/CP_C06.shp"
x_shift = 20 # may as well shift by some number
y_shift = 50 # ditto
def shift_features(in_features, x_shift, y_shift):
with arcpy.da_UpdateCursor(in_features, ['SHAPE@XY']) as cursor:
for row in cursor:
cursor.updateRow([[row[0][0] + (x_shift or 0), row[0][1] + (y_shift or 0)]])
return
shift_features(in_features, x_shift, y_shift)
Also, please read "Posting Code Blocks in the New GeoNet" so we can copy/paste your code to help.
... View more
01-15-2015
09:42 AM
|
1
|
17
|
3036
|
|
POST
|
I can only think of this somewhat hacky solution, without turning to arcpy.mapping: 1.) add tanks symbolized as usual 2.) add as many text fields as pages on which labels should be displayed (so, one for page 2, and one for page 4). 3.) populate one field with "2", and one field with "4" 4.) copy and paste this layer twice into the table of contents again, so there are three copies of tanks 5.) make the second/third copies with no symbol 6.) turn on labels for the second/third copies 7.) set a Page Definition on each new layer, so that features (and labels) are only displayed if they match the dynamic text name field This works for two pages, but if you want to automate the process, you should look to arcpy.mapping, specifically the Layer object, to turn labels on and off.
... View more
01-14-2015
01:16 PM
|
1
|
1
|
1958
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM | |
| 2 | 07-16-2020 11:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|