|
POST
|
Hi, I've written a geoprocessing script in Arcpy v10.2 that merges contiguous polylines into multipart polylines. At the moment it can take an SQL expression as an input that selects certain features of the input feature class to apply the algorithm to (e.g. I only want to merge intersecting pipes if they operate at the same pressure range, so I'd use the selection query to only select pipes of that pressure range). I'm trying to modify this so instead of a selection query, you can select multiple fields from the input feature class, similar to the Dissolve tool. So for example, I could merge all intersecting pipes of the same material, diameter, and pressure range into separate, contiguous, multi-part polyline features. I'm struggling to find a good way to identify all the unique combinations of values for the selected fields, and loop through each of these combinations, selecting them in turn and applying the algorithm to each of those selections. The usual way to get unique values from one field is to add all the values to a list and then convert it into a set, but this gets tricky when you instead have multiple fields and you don't know how many fields the user will select! It doesn't seem possible to convert a list of lists to a set, as a set won't accept a list as an element as it's mutable. If I try converting the inner lists to tuples I get an error about tuples not being callable. Generally the code I've written to try to achieve this is a hacked together mess! There has to be a better way of doing this! Can anyone suggest how I can do this? Finally, once I have each combination in a list (or maybe a dictionary, with the field name as the key?) is there a nice/efficient way to generate a SQL query to select the features with that combination of values? Thanks Dan
... View more
03-02-2016
02:00 AM
|
0
|
17
|
12786
|
|
POST
|
Hi, I am mosaicing 4 sets of LiDAR DTM data at various resolutions, plus another lower resolution DTM - I first converted each of these from TIFFs into mosaics, which was fairly quick, now I am mosaicing all 5 mosaics into a master one - I'm also creating overviews, pyramids and statistics etc. so I think that's why it was taking so long... I've made a copy and opened it in another ArcMap session and everything looks okay, although the first one is still going...
... View more
02-17-2016
08:15 AM
|
0
|
0
|
1481
|
|
POST
|
I set the Add Rasters to Mosaic Dataset tool running yesterday morning at 09:37. According to the messages in the Results window, it successfully completed at 04:20 this morning. It's now 09:24, and the background geoprocessing still seems to be going: the name of the tool is still scrolling at the bottom right of my ArcMap window, and the dataset in the table of contents is still locked out, although the footprints are displaying in the data view. Is it safe to close ArcMap or is it still actually doing something?
... View more
02-17-2016
01:27 AM
|
0
|
7
|
4900
|
|
POST
|
Also, there are some setting in the AdvancedArcMapSettings utility, found in: C:\Program Files (x86)\ArcGIS\Desktop10.2\Utilities (or similar depending on OS and version):
... View more
12-18-2015
04:59 AM
|
0
|
1
|
3782
|
|
POST
|
Do any of these suggestions help? : 20294 - Cannot map metafile into memory. Not enough memory
... View more
12-18-2015
04:54 AM
|
0
|
2
|
3782
|
|
POST
|
Whitebox is another open source GIS program, which has the quite nice feature that you can view the source code for all of the tools simply by clicking a button in the GUI - no need to worry about checking code out of github and having a suitable IDE etc.
... View more
12-02-2015
08:36 AM
|
1
|
0
|
1847
|
|
POST
|
The indentation is correct in the script, must just be a copy and paste problem. The full text of the error is: Traceback (most recent call last): File "D:\Design_Layer_Tools\Leakage\Code\ValidateLeakage.py", line 93, in <module> for row in cursor: RuntimeError: Item not found in this collection. (Line 93 = Line 02 of the code segment I posted).
... View more
01-28-2015
08:32 AM
|
0
|
1
|
1365
|
|
POST
|
The following code: with arcpy.da.UpdateCursor("QueryTable", ("SHAPE", "leakage_with_pon_list_Eastings", "leakage_with_pon_list_Northings", "leakage_with_pon_list_RandomNumber")) as cursor:
for row in cursor:
row[1] = row[0].positionAlongLine(row[3], True).X
row[2] = row[0].positionAlongLine(row[3], True).Y
cursor.updateRow(row) fails with an "item not found in this collection" error, apparently on line 02. Is it not possible to use an update cursor on a query table or something?
... View more
01-28-2015
08:07 AM
|
0
|
6
|
7273
|
|
POST
|
Ah! The problem was that the field parameter I was passing to ValidateFieldName was the status field again, not the cancel field! Thanks for the help anyway... Dan
... View more
01-15-2015
07:57 AM
|
0
|
0
|
4936
|
|
POST
|
It's as if python is not recognising the nulls as None. I have confirmed this by commenting out the first part so it's just: if not row[1] is None:
row[2] = "Y"
else:
row[2] = "N"
And still the result is 'Y' for everything... How do date fields come across into Python? Are they datetime objects? Whatever type python sees them as, could it be converting the nulls to some other value (January 1st 1970 or something?) Dan
... View more
01-15-2015
06:50 AM
|
0
|
0
|
4936
|
|
POST
|
Hi Tim, Thanks for the suggestion. I don't think it's quite right for what I want though. Let me explain: The dataset I'm working on is a table representing projects. One row in that table is one project. When a project is cancelled, the status has to be changed to include the string "CANC", and the cancel date field should be filled in. Unfortunately people sometimes forget to do one or the other, so I want to check if EITHER the Status field contains the string "CANC" OR the cancel date has a date in (is not null) OR both. row[0] is the status field row[1] is the cancel date fields row[2] is the CANC field (Y/N) row[3] is the PARC field (Y/N) 'PARC' is just another status meaning that the project is archived - that field gets populated correctly but the CANC field is all Y's, regardless of whether row[0] contains "CANC" or whether row[1] contains a date or is null. It's as if python is not recognising the nulls as None. Dan
... View more
01-15-2015
06:36 AM
|
0
|
1
|
4936
|
|
POST
|
I am writing a python script geoprocessing tool and need to use an UpdateCursor to populate a text field with either 'Y' or 'N' depending on whether a date field is null or not. Here is my code: with arcpy.da.UpdateCursor(arcpy.env.scratchGDB + r"/cn42n_table", (cn42n_status_field_validated, cn42n_cancel_date_field_validated, "CANC", "PARC")) as cursor:
for row in cursor:
if "CANC" in row[0] or not row[1] is None:
row[2] = "Y"
else:
row[2] = "N"
if "PARC" in row[0]:
row[3] = "Y"
else:
row[3] = "N" I have tried several ways of checking if row[1] (my date field) is not null but whatever I try the 'CANC' field is populated with a 'Y'. Could someone please tell me the correct way to do this? Thanks Dan
... View more
01-15-2015
05:01 AM
|
0
|
6
|
10456
|
|
POST
|
So basically what I need to do is dissolve my line features to contiguous multipart features... Not just one multipart feature and not into features that are contiguous as far as single part features allow, but something in between.
... View more
08-28-2014
04:12 AM
|
0
|
0
|
1113
|
|
POST
|
Just to add, obviously the above is with create multipart features unticked. If I tick create multipart features, the features above are merged as I want, but they're also part of the same feature as all the other pipes with the same attributes that are not contiguous with that section! If I then do Multipart to Singlepart, I end up with single lines split wherever there's a junction, so in the screenshot example above, the top horizontal line is split into three separate features...
... View more
08-28-2014
03:13 AM
|
0
|
1
|
1113
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-21-2016 07:55 AM | |
| 1 | 12-02-2015 08:36 AM | |
| 1 | 03-25-2014 08:25 AM | |
| 1 | 08-17-2011 07:28 AM | |
| 1 | 03-24-2017 04:26 AM |
| Online Status |
Offline
|
| Date Last Visited |
03-03-2022
10:03 AM
|