|
POST
|
Never mind about the error. I came up with this solution and it seems to work. feature_layer = arcpy.MakeFeatureLayer_management(fc, str(y + '_layer'))
... View more
10-04-2019
05:05 AM
|
1
|
1
|
7339
|
|
POST
|
Hi Micah, Here is the updated portion of the script. I am trying to figure out a solution to just return the selected records in the Dist_LL layer based on the number of selected records in fc. for fc in fcs:
geometryType = arcpy.Describe(fc).shapeType
print geometryType
if geometryType == 'Point':
#Get feature class name
fcsname = os.path.basename(fc)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
print y
#Get these fields from feature classes
fields = ["OID@", "LANDDISTRICT", "LANDLOT"]
for row in arcpy.da.SearchCursor(fc, fields):
if row[1] is None:
arcpy.MakeFeatureLayer_management(fc, 'fc_layer')
arcpy.SelectLayerByLocation_management('fc_layer', 'INTERSECT', 'DistLL_layer')
for DLrow in arcpy.da.SearchCursor('DistLL_layer', ["LAND_DIST", "LAND_LOT"]):
print DLrow
print row
elif row[2] is None:
print row
else:
continue I am not sure if the problem lies with the way the search cursor is ran or if it was even set up to return the selected features. I will try to modify this to see if I can get the correct result to return, but I am not sure how to get there. Also, I keep receiving this error message for some reason and I don't know how to offset this error. It occurs every time and I don't know if it is the way it is nested or if it is due to not being deleted. I will try a couple of things to see if I can correct this but this error is new to me. Any assistance on this would also be greatly appreciated. Traceback (most recent call last):
File "U:\Models_Tools\Scripts related to Landlot and District\Populate Landlot and District.py", line 31, in <module>
arcpy.MakeFeatureLayer_management(fc, 'fc_layer')
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\management.py", line 6993, in MakeFeatureLayer
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000725: Output Layer: Dataset fc_layer already exists.
Failed to execute (MakeFeatureLayer). Thank you very much for your help Micah. Robert
... View more
10-04-2019
04:21 AM
|
0
|
2
|
1564
|
|
POST
|
Hi Micah, The points do fall inside the Dist_LL layer, and the Dist_LL layer has populated values in the fields. The points that fall inside have the same fields(though named differently) but are null. The points are a set of different feature classes, and I'm trying to see if I can get the feature classes that have null values in them get populated using values in the fields in the Dist_LL layer. I don't have access to my updated script but I will post it once I get back to the office tomorrow. I hoped this explanation is a bit clearer.
... View more
10-03-2019
02:17 PM
|
0
|
2
|
5776
|
|
POST
|
Thanks Robert, Our crews work in designated grids but I was thinking it would make sense to have the grids be something that we could change internally that would show in the web map that they use. That way I'm not having to create bookmarks in a web map for them to click on and zoom to everytime.
... View more
10-03-2019
02:10 PM
|
0
|
0
|
4760
|
|
POST
|
Thanks again Micah, I made the necessary changes but now I have an issue where the number of returned features exceeds that of the queried features. I am trying to figure out what is the best approach to this: Identify the intersecting features in the layer(using the select layer by location) Get the selected records for the fields in the feature layer Using the selected records in that layer, populate the null fields in the other existing layer. So what I am trying to do is basically extract values spatially from one feature and using those values to populate the null fields in another layer. It seemed simple enough, but for some reason it returns an inordinate amount of records, which exceeds that of the queried records. What would be the best way to script this? I am fairly close but I am having trouble figuring out how to get a matching number of records from another layer. Thanks, Robert
... View more
10-03-2019
01:03 PM
|
0
|
4
|
5776
|
|
POST
|
Thanks Micah, I can't believe something that simple had slipped past me. I will make those changes and see if that fixes the issue.
... View more
10-03-2019
12:40 PM
|
0
|
6
|
5776
|
|
POST
|
Thanks Robert, I will give that a shot. I was hoping that there was a way to add bookmarks using published services to automatically create a bookmark using an existing feature.
... View more
10-03-2019
12:37 PM
|
0
|
7
|
4760
|
|
POST
|
Hi Randy, Here is the error message that I receive. Traceback (most recent call last): File "U:\Models_Tools\Scripts related to Landlot and District\Populate Landlot and District.py", line 17, in <module> arcpy.MakeFeatureLayer(fc, 'fc_layer') AttributeError: 'module' object has no attribute 'MakeFeatureLayer'
... View more
10-03-2019
11:41 AM
|
1
|
8
|
5776
|
|
POST
|
Hi, So I am trying to figure out how to get the date for a selected feature using the spatial location using arcpy. I keep running into an issue where the MakeFeatureLayer keeps returning an error and I am not sure as to why. I followed several examples and yet I still keep getting an error. I would greatly appreciate any help with this. import arcpy
import os
workspace = r'Database Connections\Some Connection.sde'
fcs = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")
Dist_LL = "Database Connections\Some.sde\FeatureClass"
for dirpath, dirnames, filenames in walk:
for filename in filenames:
fcs.append(os.path.join(dirpath, filename))
for fc in fcs:
geometryType = arcpy.Describe(fc).shapeType
print geometryType
if geometryType == 'Point':
#Get feature class name
fcsname = os.path.basename(fc)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
print y
#For fields in some feature classes
fields = ["OID@", "LANDDISTRICT", "LANDLOT"]
#Make feature layers
arcpy.MakeFeatureLayer(fc, 'fc')
arcpy.MakeFeatureLayer(Dist_LL, 'Dist_LL')
for row in arcpy.da.SearchCursor(fc, fields):
if row[1] is None:
arcpy.SelectLayerByLocation_management (fc_layer, 'INTERSECT', Dist_LL_lyr)
select_records = arcpy.da.SearchCursor(Dist_LL_lyr)
print select_records
print row
elif row[2] is None:
print row
else:
continue Robert
... View more
10-03-2019
09:52 AM
|
0
|
13
|
7545
|
|
POST
|
Thanks Joshua, I was just curious since I wasn't sure if there was a particular way in which code is written. I am slowly getting the hang of it and so far the scripts are working, but the direction might need some more clarity. I talked with one of my coworkers who suggested to create a diagram of what you would like to accomplish, and from that diagram write the code that corresponds with each step in the diagram. That has worked for me so far, but I also noticed that ( due to the limited experience with python ) I tend to lengthen my coding a bit. The code works but in some areas I would like to figure out where I can simplify the structuring just a bit, especially if the code is designed to accomplish something simple.
... View more
10-03-2019
09:37 AM
|
0
|
1
|
1651
|
|
POST
|
Hi, I was wondering if there was a way to automate the creation of bookmarks for use in ArcGIS Online. We have some contractors who collect data for us and we use bookmarks to indicate where they need to be. I know that you can use existing data to show where they need to collect but unfortunately that would still require them to constantly navigate back to that designated location every time they open Collector. So if there is a way to automate bookmarking I would greatly appreciate it. Robert
... View more
10-03-2019
09:29 AM
|
0
|
12
|
5841
|
|
POST
|
Yeah I wasn't sure the best way to put it. At what point does reducing the lines of code become constraining. I don't code a whole lot but I think knowing the do's and don'ts for reducing lines of code may definitely help. So when is it best to reduce lines of code and when is it not. I would like to know just in case so I don't make the mistake or doing it too much to where troubleshooting the script may turn into a hassle.
... View more
10-03-2019
08:07 AM
|
0
|
3
|
1651
|
|
POST
|
Thanks Dan, I never really thought about that. I simply thought a script that is written with fewer lines looks aesthetically better, but never considered troubleshooting as a factor in writing the script. I am relatively new to this and I see people write these in so many ways, but they oddly function the same. So the thing that I am unsure about is if there is a particular method to writing scripts, or is that simply dependent on personal preference. Robert
... View more
10-03-2019
06:19 AM
|
0
|
6
|
1651
|
|
POST
|
Hey Micah, I was trying to figure out if there are ways to write the same thing with fewer lines. The script worked for what I needed but I wasn't sure if there was a way to write it in a simpler fashion. I know writing a simpler script is not as important as a working script, but knowing that there are ways to simplify what I have already done would make searching through the code a little easier(and streamlined). Thanks for your help Micah, Robert
... View more
10-02-2019
02:40 PM
|
1
|
1
|
4482
|
|
POST
|
Thanks Micah, I had some issues with the overall path names since I had feature classes in both the database and the dataset within the database. I was able to figure out a solution but it was kind of lengthy. I tried to shorthand it but that didn't turn out to well. Here is the solution I came up with when I had the full path names. If there is a better way to shorthand this I would definitely be interested. import arcpy
import os
workspace = r'Database Connections\Connection to dcp-gisapp1tst.sde'
fcs = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
fcs.append(os.path.join(dirpath, filename))
for fc in fcs:
geometryType = arcpy.Describe(fc).shapeType
fcsname = os.path.basename(fc)
name = os.path.splitext(fcsname)
x = geometryType
y = name[1].lstrip('.')
print '{} is a {}'.format(y, x)
... View more
10-02-2019
12:16 PM
|
1
|
11
|
4482
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 2 weeks ago | |
| 1 | 02-10-2026 06:09 AM | |
| 1 | 03-04-2026 01:08 PM | |
| 1 | 02-24-2026 12:59 PM | |
| 3 | 03-03-2026 10:33 AM |
| Online Status |
Offline
|
| Date Last Visited |
Wednesday
|