|
POST
|
Hi I'm trying to do some algebra with two height rasters.... Just a simple Raster1 minus Raster2 to get a height difference. The trouble is, I think, that the two rasters are different resolutions and when I inspect my resulting TIFF I do not agree with any of the values: eg. if I inspect a random pixel Raster1 = 265 Raster2 = 228 OutputRaster = 97 (of course I expect the value to be 37) The resolution of the output is the same as the input raster with the lower resolution (but the pixels do not line-up). Logically the output should have the same resolution of the more detailed input. I there something I can do so this works intelligently with rasters of differing resolutions?
... View more
08-14-2014
02:50 AM
|
0
|
2
|
2858
|
|
POST
|
This one works for me. Thanks John for your answer - looks pretty straight forward too - I will test it later as a learning exercise. Cheers
... View more
07-28-2014
06:46 AM
|
0
|
0
|
1541
|
|
POST
|
Hi - I'm trying to write a little bit of code to assign a random value to my ORIENT field where ORIENT = 0. My problem is that it chages the ORIENT for the whole table not just where the value is zero. I guess that this is because line 14 does not refer to row but I don't know how to charge it so it does refer to row - can anyone advise??
import arcpy
fc = r"c:\Test_Orient.shp"
feildName = "ORIENT"
expression = "rand_num()*360"
codeblock = """def rand_num():
import random
return random.random()"""
#search for rows to be altered
rows = arcpy.SearchCursor(fc, fieldName + " = 0")
for row in rows:
arcpy.CalculateField_management(fc, fieldName, expression, "PYTHON_9.3", codeblock)
... View more
07-28-2014
04:19 AM
|
0
|
3
|
3142
|
|
POST
|
I don't think the tool works in the way it should - maybe a bug. I have a polygon layer that contains woods and orchards - it was made by merging a few layers and I have some overlaps. So I did a union and then a dissolve on centroid value to remove the overlaps (keeping the original FID as a stats attribute) - all working so far. Now I want to dissolve touching polys of the same category (wood or orchard), again I want to keep an original FID so I can do a join on the original table, but this time instead of giving me the FIRST FID out of the individual groups of polys that are dissolved together every FID for all Wood polys is the same and every FID for all Orchard poly is the same - this is no good to me - doesn't make sense because it worked correctly on the first dissolve.
... View more
07-24-2014
05:46 AM
|
1
|
0
|
10428
|
|
POST
|
I'm having the same problem - I want to dissolve and I want to keep my attributes. The tool is very difficult to use - particularly if you have a large number of attributes. To keep an attribute it must be added to the Statistics Field(s) option - these must be done one-by-one and for each one you also need to select a stats type. Then when you run the tool all the attribute names are changed - they are prefixed with the stats type you chose - if you're using shapefiles this is bad because you start losing the original atrribute name because of the 10 character limit. So, is there a way to keep all my original attribute names?
... View more
07-24-2014
04:22 AM
|
1
|
1
|
10428
|
|
POST
|
Actually I don't know why I mention it I think they are actually very different beasts and just because the flow diagram layout is similar I want to see ModelBuilder with my FME eyes. And whereas FME is super flexible, user friendly and powerful, I have so far found modelbuilder to clunky, inflexible and unclear.
... View more
07-23-2014
05:36 AM
|
0
|
0
|
947
|
|
POST
|
Sorry I didn't see you also corrected the script - I thought you were just saying your way of displaying the code in GeoNet was better. It looks like a screenshot of Notepad++ but you can select the text? I'm pretty new to Arc, I currently find ModelBuilder more confusing than code - I'm used to working with FME a lot so I want it to work like that, I find MB very unintuitive.
... View more
07-23-2014
04:17 AM
|
0
|
2
|
947
|
|
POST
|
Thanks Dan - I'm a tiny step closer to being a python expert.
... View more
07-23-2014
04:06 AM
|
0
|
0
|
947
|
|
POST
|
Closer....closer.... I'm now getting some results but if I have several shapefiles in c:/temp2 the script only amends the last one (print fc lists all files correctly) This is my code now: import arcpy # Remember to change this to wherever your shapefiles are stored arcpy.env.workspace = r"C:\temp2" try: fcs = arcpy.ListFeatureClasses() for fc in fcs: print fc # Create the new field arcpy.AddField_management (fc, "FILENAME", "text", "", "", "50") # Apply the filename to all entries arcpy.CalculateField_management (fc, "FILENAME", '"' + fc + '"') except: print arcpy.GetMessages ()
... View more
07-23-2014
03:32 AM
|
0
|
0
|
1451
|
|
POST
|
What shoul I do to correct the while function, it still refers to fc. I get the following error: IndentationError:unindent does not match any outer indentation level Without the .Next lines how does the code know to iterate through all by shapefiles? sorry - I still need to be spoon fed this stuff.
... View more
07-23-2014
02:25 AM
|
0
|
4
|
1451
|
|
POST
|
Good plan - my Arc machine isn't connected to the internet so usually it's a pain in the neck. I forgot that I had downloaded the code off the internet. This is the code after my changes........ #import relevant modules, create geoprocessing dispatch object import arcpy #gp = win32com.client.Dispatch("esriGeoprocessing.gpDispatch.1") # Remember to change this to wherever your shapefiles are stored arcpy.workspace = "C:\temp2" try: fcs = arcpy.ListFeatureClasses("*", "all") fcs.reset() fc = fcs.Next() while fc: # Create the new field arcpy.AddField_management (fc, "FILENAME", "text", "", "", "50") # Apply the filename to all entries arcpy.CalculateField_management (fc, "FILENAME", '"' + fc + '"') fc = fcs.Next() except: print arcpy.GetMessages ()
... View more
07-23-2014
02:03 AM
|
0
|
6
|
1451
|
|
POST
|
Thanks - that kind of makes sence but the script isn't doing anything. It runs without error but doesn't add the new field. Did you download the script? Can I ask some questions? I removed line 17: gp = win32com.client.Dispatch............... was I correct to do this? I don't understand the 'try:' section....it says: try: fcs = arcpy.ListFeatureClasses("*", "all") fcs.reset() rc = fcs.Next() Why does it define fcs and then reset it on the next line? What is it doing? I'll be happy if you can recommend a place where I can read up on these terms. Regards Ben
... View more
07-23-2014
01:51 AM
|
0
|
8
|
1451
|
|
POST
|
I downloaded this arcscript from here: Filename Insert It's an old script from 2006 and when I run it I get the following error: File "C:\FileNameInsert.py", line 15, in <module> import win32com.client, sys, string, os ImportError: No module named win32com.client How do I modify this script so it works in 2014? (what I hoping to achieve is to add a filename attribute to my shapefiles so that when I merge them together I can trace back to the originals)
... View more
07-23-2014
12:40 AM
|
0
|
16
|
3007
|
|
POST
|
Just one dataset (actually it was originally about 120 but I've merged them all into one - that's the goal, one dataset with duplicate geometries removed)
... View more
07-17-2014
02:48 AM
|
0
|
0
|
981
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2014 05:46 AM | |
| 1 | 12-05-2013 05:15 AM | |
| 1 | 08-24-2015 01:11 AM | |
| 1 | 09-05-2017 11:44 PM | |
| 1 | 10-14-2015 04:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-12-2021
02:38 AM
|