|
POST
|
Hi Anne, Good for you that want to understand the Python code that solves your problem. In order to give you some pointers, it is necessary to know a little more: what version of ArcGIS are you using? do you have any programming knowledge? About Python In case you don't have (much) experience with Python, consider the next resources: The thread below provides some useful links to resources: http://forums.arcgis.com/threads/96424-Learning-Python A good way to start can be using the Python window in ArcGIS, since you obtain context sensitive Help. Also after you manually execute a ArcGIS tool, you can use the option Copy as Python Snippet in the Results window. When working with looping through feature classes and tables, have a look at cursors (especially the data access cursors): Accessing data using cursors And you can follow free courses online at Esri: http://training.esri.com/gateway/index.cfm?fa=search.results&searchterm=python Depending on your knowledge and needs, there are many options. Also the Forums are a very useful resource. Always look at the posts by jscheirer (Jason Scheirer). He is on the Python team at Esri and also posts on: http://arcpy.wordpress.com/ I heard about the book "Programming ArcGIS 10.1 with Python" which appears to be a good resource, and there will be a new one "Mastering Python Programming for ArcGIS". About your question I assume your post in this threads is related to what you are asking here: http://forums.arcgis.com/threads/69130-ArcGIS10.0-PythonWindow-Make-XY-Event-Layer-.csv-amp-WGS-1984-Errors-000622-amp-000628?p=366433&viewfull=1#post366433 From this thread I extracted that in your workspace you have a number of DBF tables: AB10_.dbf, AB11_.dbf, AB15_.dbf, CFHMS_.dbf, CFMHN_.dbf, FA_.dbf, HSFHome_.dbf, HSFVAN_.dbf, KF18_.dbf, KF1W_.dbf, LASA_.dbf, MB_HAck_.dbf, PCM10_.dbf, PMB28_.dbf, pmc9_.dbf, SHROCK_.dbf, simo09_.dbf, SIMO94_.dbf, SP150_.dbf, sp42_.dbf, T13East_.dbf, T13West_.dbf, TB53_.dbf, TB63_.dbf, WSFBOW_.dbf, WSFDALLAS_.dbf I assume they all have the the same coordinate fields: "Lat" and "long". Please note that in your code in the other thread you assign the Lat to x and Long to y (it should be the other way around!). After converting the DBF's to shapefiles, you want to perform inverse distance weighted interpolation on each attribute. What I don't completely understand is whether you want to merge all the tables together first, or whether for each table/shapefile and attribute the IDW should be performed. Main question here is what you want to do with the rasters that result from the operation. Looking at the table names, it seems that each table covers a different area. Is that right? In that case merging the features would be an option, but if you want to do that, you will have to look at the schema's of the tables (do they have the same fields?). If the schema's are different, you will probably have to use cursors and more programming to do that or some nasty field mapping. I could advise you on that, but will need to have a look at the data first. I don't know if that's an option for you... Please note that looping through each field of a shapefile to perform the IDW will result in more rasters then you want, since your lat and long fields will also be used. You will have to include some more intelligence to do this right. Let me know if I can help you. Kind regards, Xander
... View more
02-18-2014
03:48 AM
|
0
|
0
|
1947
|
|
POST
|
Hi Anne, The "Error 000622" is referring to invalid parameters for the tool. In this case due to the fact that you specify the list of tables in the MakeXYEventLayer tool, rather than the table itself. Please observe the code below: tables = arcpy.ListTables()
for tbl in tables:
arcpy.MakeXYEventLayer_management(tbl, xc, yc, out_layer, spRef)
"tables" is a variable with the list of tables found in the current workspace then you do a for loop, accessing each table "tbl" in the list "tables" specify the variable "tbl" (the single table) to be used in the MakeXYEventLayer tool Another thing to remember is that you use your latitude as X-coord and you Longitude as Y-coord. This should be the other way around: xc = "long"
yc = "Lat" Kind regards, Xander
... View more
02-18-2014
03:12 AM
|
0
|
0
|
704
|
|
POST
|
Hi Justyna, I suppose you used the Focal Statistics tool and switched the option "Ignore NoData" on, right? This is OK. What you need to realize though, is that pixels that have NoData value in your input raster, but have Data cells in their direct vicinity will receive a value too. To set these pixels to NoData again, you can you the Con Tool (Spatial Analyst\Conditional\Con). Use your input raster (first image in your post) from the previous step as conditional raster, leave the expression blank, use the focal statistics raster as "true raster" and leave the "false raster" empty. This will set the pixels outside the area to NoData. Kind regards, Xander
... View more
02-06-2014
07:01 AM
|
0
|
0
|
839
|
|
POST
|
Hi Adriane, That is a pretty large raster; about 63% of the earths circumference... I'm kinda curious; what type of raster data is this, how large is it (several TBs?), and more importantly why do you want to do this? In general it is a lot easier to project the vector data (shapefile) to the projected coordinate system van the raster. If you project a raster you will probably apply some resampling and create a second dataset (which, depending of the cell size, will probably be huge too). Kind regards, Xander
... View more
02-06-2014
06:16 AM
|
0
|
0
|
343
|
|
POST
|
Hi Marianne, What you could also try is to use the properties of the data you're accessing. So read the "lengthFieldName" properties after doing a describe on your data: desc = arcpy.Describe(inFeatures)
fldLength = desc.lengthFieldName
Next, construct the expression. Make use of "AddFieldDelimiters" which will add the appropriate field delimiter if necessary: minLength = 300
expression = "{0} < {1}".format(arcpy.AddFieldDelimiters(inFeatures, fldLength), minLength)
In my (non-versioned) SDE the expression will be: "Shape.len" < 300 In a FGDB it will be: Shape_Length < 300 Then continue with the UpdateCursor: fields = ['OID@', 'SHAPE@', 'GM_LABEL', 'GM_USER_DEF']
uCursor = arcpy.da.UpdateCursor(inFeatures, fields, expression) Kind regards, Xander
... View more
02-06-2014
05:45 AM
|
0
|
0
|
621
|
|
POST
|
Hi David, You're nearly there... I guess the problem is that the row you write should have the same dimensions as the row you read. I renamed the x_shift and y_shift variables to x_new and y_new for readability. I didn't test this, but if I think this could work. import arcpy
fc = r'c:\yourFGDB.gdb\yourLines'
# update cursor (be careful with this and try it on a copy of your data)
fields = ["SHAPE@","XCentroid","YCentroid"]
with arcpy.da.UpdateCursor(fc,fields) as curs:
for row in curs:
geom = row[0]
x_new = row[1]
y_new = row[2]
array = arcpy.Array()
for part in geom:
lastpnt = part[len(part) - 1]
lastpnt.X = x_new
lastpnt.Y = y_new
part[len(part) - 1] = lastpnt
array.add(part)
curs.updateRow([arcpy.Polyline(array), x_new, y_new]) Kind regards, Xander
... View more
02-05-2014
04:30 AM
|
0
|
0
|
1924
|
|
POST
|
Hi Malcolm, Your second statement using the IsNull tool treats the NoData cells appropriately. NoData is handled differently by many tools, and normally results in NoData in your output. So although you think the Con statement results in either True or False, it also has a hidden case NoData. I recommend you to read the Help Topic on "NoData and how it affects analysis" which explains this behavior. Kind regards, Xander
... View more
02-05-2014
12:05 AM
|
0
|
0
|
793
|
|
POST
|
Yes you can. Just follow these steps: Convert you TIN to raster (use an appropriate cell size) Convert you building shapefile to raster (use the height as value, and the same cell size) Combine both rasters using a CON statement (Spatial Analyst) Convert the resulting raster to ASCII grid Kind regards, Xander
... View more
02-04-2014
11:52 PM
|
0
|
0
|
1799
|
|
POST
|
Hi Ananya, Tip 1:specify a workspace without trailing slashes: replace: inputPath = "F:\\GIS\\_Projects\\NPMRDS\\GDB\\NHS_npmrds_2013.gdb\\" by: inputPath = "F:\\GIS\\_Projects\\NPMRDS\\GDB\\NHS_npmrds_2013.gdb" Tip 2: It is better to use os.path.join to join a location and a name: Add this to the beginning of the script: import os and change your code to: inputTable = os.path.join(inputPath, speedTable) (this should give the same result as you already had) Do the same for inputFC, tmpQueryTable, QueryTableFeatureClass: inputFC = os.path.join(inputPath, featureClass)
tmpQueryTable = os.path.join(inputPath, "QueryTable")
QueryTableFeatureClass = os.path.join(inputPath, "copyFeatures") Tip 3: your fieldList contains objects and not the fully qualified field names. In order to get this right, the easiest way would be to execute the tool manually. See instructions here: http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000006r000000 After a successful run, open the "Results" window and right click on the successfully executed tool. This will reveal the option "Copy as Python Snippet". Now you are able to paste the python code to your Python IDE and examine what the content of each parameter has been. Adapt you script to create the same type of parameters. Tip 4: expression is not valid The expression uses names of variables, but should use the content of the variables. Use this instead and verify if you need to use fully qualified names in the expression. expression = "{0} = {1}".format(tmc1, tmc4) this would yield: "NHS_tmc = tmc" Kind regards, Xander
... View more
02-04-2014
11:22 PM
|
0
|
0
|
460
|
|
POST
|
Hi David, Try the code below on a copy of your data and see if this is what you want. import arcpy fc = r'c:\yourFGDB.gdb\yourLines' x_shift = 5 y_shift = 5 # update cursor (be careful with this and try it on a copy of your data) fields = ["SHAPE@"] with arcpy.da.UpdateCursor(fc,fields) as curs: for row in curs: geom = row[0] array = arcpy.Array() for part in geom: lastpnt = part[len(part) - 1] lastpnt.X += x_shift lastpnt.Y += y_shift part[len(part) - 1] = lastpnt array.add(part) curs.updateRow([arcpy.Polyline(array)]) Kind regards, Xander
... View more
02-04-2014
10:07 PM
|
0
|
0
|
1924
|
|
POST
|
Hi Todd, Sounds to me that that's the way to go. You should have a look to what distance of the edge the distortion is present and let that define the amount of overlap. Good luck, hope it works... Kind regards, Xander
... View more
01-20-2014
06:07 AM
|
0
|
0
|
720
|
|
POST
|
Hi Mary, Imagine a graduate slope in an near flat area (the green line in the attached image). When translating this data to integer, it will create a "jump" at an elevation of 0.5 (see blue dashed line); all decimal values from 0 to 0.5 will be 0 and all values from 0.5 to 1 will be 1. At this "jump" location, the slope will be high, while the rest of the slope will be 0. [ATTACH=CONFIG]30267[/ATTACH] Kind regards, Xander
... View more
01-05-2014
09:23 PM
|
0
|
0
|
2086
|
|
POST
|
Hi Sol, Good point that a center of gravity of population may well be placed on a location where no population exists (+1 for that)... Key question remains; what is the purpose of the analysis? Kind regards, Xander
... View more
01-02-2014
10:50 AM
|
0
|
0
|
2284
|
|
POST
|
Hi Mary, The DEM is integer and as an integer does not have the detail te create a decent slope map. I tried to approximate what it should be; a float with decimal values by applying a Focal Statistics Mean with a Circle radius of 25 cells. If you calculate the slope on this dataset, you will find something more similar to what it should be. See the image attached (left slope on the original DEM and right slope on smoothed DEM displayed in 3D). [ATTACH=CONFIG]30190[/ATTACH] The important thing to do is, to see if you can get the data that was used to create the DEM yourself or ask the provider if they have a better (floating) version of the data. The data at this point is not useful to derive Slopes. Kind regards, Xander
... View more
01-02-2014
10:44 AM
|
0
|
0
|
2086
|
|
POST
|
Hi Sol, First of all thanks for the +1, and for the additional ideas you have on the matter. If I look at the original question, to me it clearly states that the density of the points is asked. The polygons are merely used to define which points should be combined to 1 center. On the other hand, we should ask Palermo what he wishes to achieve with the analysis, to be able to define what analysis suits his needs. If I look close at the picture and the name of it ("Urban_density.jpg") it sounds to me that the polygons are counties and the points are urbanizations. To get the "center of gravity" it might be more realistic to use a certain characteristic as weight; say population per point. This would result in the center of gravity of population per county. One more thought on using the outline of the polygon to determining the center; if you use for instance each vertex or equally separated points on the outline, a polygon with a lot of detail on one side (like the one center right in the picture) would pull the center of gravity towards the detailed part of the outline. I don't think this is what we want... Kind regards, Xander
... View more
01-02-2014
08:16 AM
|
0
|
0
|
2284
|
| Title | Kudos | Posted |
|---|---|---|
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM | |
| 1 | 05-29-2019 02:45 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-26-2025
02:43 PM
|