|
POST
|
Joshuas answer seems the best way. Another take, is to use the tool you were doing, but only run it on 1 feature at a time, something like: src_shp = r'a_shapfile'
result_fc = 'a_different_shapefile'
for row in arcpy.SearchCursor(src_shp):
row_oid = row.getValue('OBJECTID')
row_where = """ObjectID = %s""" % row_oid
active_lyr = arcpy.MakeFeatureLayer(src_shp, where_clause=row_where)
if arcpy.Exists(row_result):
arcpy.Delete(row_result)
row_result = Feature to Polygon (active_lyr, temp_layer)
append_management(row_result, result_fc)
I imagine Joshuas approach above will perform much faster though!
... View more
05-28-2019
08:42 AM
|
2
|
0
|
3191
|
|
POST
|
Ive always done.. Add a Unique ID Field to data "Generate Points along lines" (Choose a resolution for the vertices, that is relevant to your data without going crazy!) "Feature Vertices To Points" "Create Thiessan Polygons" "Dissolve" using the UniqueID Field Works great..ish for me. (The boundarys can get a bit zigzaggy!)
... View more
05-09-2019
03:04 AM
|
0
|
0
|
655
|
|
POST
|
Im trying to understand what your achieving with this code: with arcpy.da.SearchCursor(feature_class, 'SHAPE@AREA') as acursor:
for row in acursor:
if row[0] > 100000000:
print("{} greater than 10K km2, splitting...".format(row[0])
tgrid = arcpy.GenerateTessellation_management(t_out, oe, "SQUARE", 100000000, sr)
print("Splitting complete")
else:
print("point extent smaller than 10K km2, not splitting.") To me, you need to do something with TGrid, otherwise you are just overwriting each iterations previous output. I think this is also what causes your issue as you are still "Referencing" the output in the python script, so it will lock the shapefile maybe. You could test this theory, by changing it to: with arcpy.da.SearchCursor(feature_class, 'SHAPE@AREA') as acursor:
for row in acursor:
if row[0] > 100000000:
print("{} greater than 10K km2, splitting...".format(row[0])
tgrid = arcpy.GenerateTessellation_management(t_out, oe, "SQUARE", 100000000, sr)
print("Splitting complete")
del(tgrid)
else:
print("point extent smaller than 10K km2, not splitting.")
... View more
05-07-2019
04:49 AM
|
1
|
1
|
1474
|
|
POST
|
Theres a slight chance if you had the layer in the map the whole time, that ArcGIS had cached the Shape column so its not loading all the data from disk permanantly. You could try dragging the layer into a new ArcMap window to be sure! Or add a call at the end of your script to http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/refreshactiveview.htm For me, normally if i zoom in and out, then it seems to reload the data as well. (Panning not so much)
... View more
05-02-2019
03:13 AM
|
0
|
1
|
3240
|
|
POST
|
when it says "City_Lyr is not defined", what this means is, you have not yet "defined" your city layer This is because in this line of code: for lyr in arcpy.mapping.ListLayers(mxd, "City*", df): if lyr.name == "City Points (2010)": city_lyr = lyr it never actually gets to run the line of code: city_lyr = lyr Which is where you try to define it. The reason for that, I am not so sure, but the "If" statement is somehow not letting any of your layers get defined as the city lyr. Same issue regarding your other layer.
... View more
05-01-2019
07:01 AM
|
1
|
0
|
328
|
|
POST
|
Dans Answer is correct. in_fc = 'C:/Your_spaceless_path/CoordGeom.gdb/Polygons'
arr = arcpy.da.TableToNumPyArray(in_fc, 'Shape_Area') # pick a field
# nan functions account for nulls, cast to the dtype of the field using astype
np.nanmax(arr.astype('float'))
155.0 If this is returning different numbers based on selection, then this is because you are not entering "in_fc" as shwon above. E.g. in_fc = 'C:/Your_spaceless_path/CoordGeom.gdb/Polygons' Is different than: in_fc = 'Polygons' One points to a layer in a map, and will return results based on selections and things, the other points to data on a disk, and will return counts of whatever is inside that dataset. The only possible thing that could go wrong using this, is if a user is inside an Edit session, then there features are not saved to the "dataset on disk" until they save Edits.
... View more
04-29-2019
05:34 AM
|
1
|
0
|
924
|
|
POST
|
Due to the way your code is written, I cant see much potential for warping of the features via this. Which mostly, just leaves coordinate systems. Ensure your input, and output FC have matching coordinate systems.
... View more
04-26-2019
03:57 AM
|
2
|
1
|
1094
|
|
POST
|
Thanks great to see the shapefile thing has changed! My ArcPro is a bit out of date, as we use a concurrent server now instead of named users, and im not able to download the update since the switch. Need to contact my Org admin to get help with that! With regards to new folders, this is specifically when navigating folders, via any geoprocessing "Select output path" interface. In a perfect world I would create the folder before opening a tool, but I tend to forget as I always opened the tool, then created the folder for the past 15 years
... View more
04-09-2019
06:49 AM
|
1
|
2
|
1621
|
|
POST
|
Thanks Rory, I think I must have been thinking you cant Right click inside a folder to create shapefiles. (I know you can with FGDBs and FCs, but we still use shapefiles for most workflows) This is why I believe its an ESRI design choice to force us to adopt more modern and improved practises, but our ecosystem exists beyond esri and other softwares do not tend to interface natively with these FGDBs. Another example - When choosing an output location of any geoprocess tool. In ArcMap whilst browsing locations I could simply click -- New folder, or new GDB, in ArcPro this isnt there. So I either have to close the window then go and make the GDB in catalog then reopen it, or use windows to go and make a folder. Simple usability things that ArcGIS has these covered and works for everything I need stop me from considering upgrading. The new good things are very good and the one time I need to use them I load ArcPro, but it fails for me on the activities I typically do 100s of times a day. (Creating shapefiles, and choosing output locations)
... View more
04-09-2019
06:11 AM
|
0
|
4
|
1621
|
|
POST
|
Am I the only person who had almost daily crashes all way through ArcGIS 9.X versions. And ArcGIS 10 has mostly fixed these and made it a rare occurance My biggest gripes are that it performs very slowly over the network drive, which is obviously a hard challenge to overcome. With regards to ArcPro. I love it, but I can never use it. Sadly its all design decisions I dont think they will change.... basic things like right click to create an FC, or copy and paste shapefiles, its just too painful. Arghhhhhhhhhh
... View more
04-09-2019
03:30 AM
|
0
|
6
|
1817
|
|
POST
|
Here is a function I use to build where cluases from lists, I use it like this.
values = ['test', 'test2']
field_name = 'query_field'
sql_where = build_where_clause_from_list (field_name, values)
values = [11, 27]
field_name = 'query_field'
sql_where = build_where_clause_from_list (field_name, values, field_type='Number') def build_where_clause_from_list(field_name, value_list, field_type="String"): """Build a SQL In Where clause using a list e.g. field_name = 'Cheese', value_list=['Edam', 'Cheddar', 'Stinky Bishop'] output: "Cheese" in ('Edam', 'Cheddar', 'Stinky Bishop') """ where = """ "%s" in (""" % field_name if field_type == 'String': where+= "'" if field_type == 'String': joinTxt = "','" else: joinTxt = "," where += joinTxt.join(map(str, value_list)) if field_type == 'String': where += "'" where += ")" return where
... View more
04-08-2019
06:08 AM
|
1
|
1
|
776
|
|
POST
|
The short and dirty answer is, inside Pycharm / Spyder / any python IDE, there is a setting "Project Interpreter", which is pointing to a python.exe in a folder such as C:\python27\python.exe You need to update this setting to point to a place such as: C:\Program Files\ArcGIS\Pro\bin\Python\python.exe
... View more
04-04-2019
07:27 AM
|
0
|
21
|
2375
|
|
POST
|
Ive found that if I store the code in a temporary Microsoft Format. (Word, Excel etc) The single quotes, are not compatible with some of the ESRI stuff. But if you copy the same text into notepad, then copy that into Arc, many tools will work.
... View more
03-20-2019
07:52 AM
|
0
|
1
|
4144
|
|
IDEA
|
Using ArcGIS, I often have workflows that involve selecting features. When using ArcGIS pro, it seems that when the map is updated (panned/zoomed) the Application draws all of the layers, including the base map etc. Finally it then draws the "Cyan" selected features. My corporate network is slow, the base map / all layers often takes about 8 seconds to finish drawing. Now I have to wait 8-10 seconds to see my selected features. Using ArcGIS, my selection was visible immediately. Please move this thread up in the application priority order.
... View more
03-20-2019
03:58 AM
|
1
|
0
|
433
|
|
POST
|
Hello, Most of your issues seem to be 'basic' python issues that can be resolved with a little experience and have mostly been answered. e.g. -there seem to be problems with converting/using characters which don't fit into ASCII - i couldn't figure out how to ask properly if Field 5 is Null - I could not properly translate the "AND" and the "OR" from Excel to Python (for example: If Field 4 is Null AND Field 5 is Null AND Field 1 is 612, Field 6 = ...) When it comes to this point, I feel your excel formulaes, or whatever other method you use will require the same amount of code / a big formulae. Do you see this differently? - the code will become huge (I have more fields and values to compare) Anyways, to come from a different angle, answers to date seem to be focused on a more functional programming style. I like to try and break down my problem, and write as much code in more descriptive 'english' as I can, Ill provide a sample code showing what I mean by this but as its hard to work out what your doing it might come across badly! I tested this in ArcMap and it works great. You do need to add logic for the "Uncaught text"
def compare(code_field, date_field1, date_field2, text_field1, text_field2):
# -*- coding: latin-1 -*- or # -*- coding: utf-8 -*-
def get_date_text():
if code_field == '617':
return str(date_field2)
else:
return str(date_field1)
def get_sometext_string():
if text_field1 == 'ABC' and text_field2 is None:
return "Sometext"
elif text_field1 == 'ABC' and text_field2:
return "Someothertext"
else:
return "UNCAUGHT_TEXT"
def get_otherfield_data():
if text_field1 == 'ABC' and text_field2 is not None:
return text_field2.encode("UTF-8")
else:
return ""
#First I will work out each of the "Parts" that I need to represent in the output text and make a variable for these
#(This bit isnt really needed, but helps us picture what we are going to do in our head)
date_text = ""
divider = ' | '
string_about_sometext = ""
other_field_data = ""
#Now I know what I need to populate, I can write a function thinknig about each bit seperately, then put it all together later.
date_text = get_date_text()
string_about_sometext = get_sometext_string()
other_field_data = get_otherfield_data()
#Now I should have everything, ready to combine into an answer
#(I would normally write this code using other string functions, but to keep it simpler am just combining all the strings and making sure each function returns a string)
final_text = date_text + divider + string_about_sometext + other_field_data
return final_text #Expression compare( !Field1! , !Field2! , !Field3! , !Field4! , !Field5! )
... View more
01-18-2019
09:45 AM
|
1
|
0
|
410
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-29-2019 07:45 AM | |
| 1 | 05-13-2013 07:11 AM | |
| 1 | 05-24-2011 07:53 AM | |
| 1 | 05-22-2017 05:01 AM | |
| 2 | 07-29-2019 05:34 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-22-2024
10:40 AM
|