|
POST
|
Searching globally for a 5x5 meter cell? What are you doing? Does it have to be a square or do you just care about area? This works for a simple raster. Haven't tested on a mosaic, and I'm not sure how to handle the resampling on a mosaic if the rasters have different cell sizes. import arcpy
# load the dem
dem = arcpy.sa.Raster("MosaicPath")
# resample to cellsize of 5m
in_cell_size = dem.getRasterInfo().getCellSize()
resampled_dem = arcpy.sa.Resample(dem, "Bilinear", in_cell_size, 5)
# calculate slope
slope = arcpy.sa.Slope(resampled_dem)
# create a binary raster of slope < 10 (1) or >= 10 (0)
low_slope = arcpy.sa.Con(slope, 1, 0, "VALUE < 10")
# save the result
low_slope.save("C:/Path/low_slope.tif") Each cell of low_slope is 5x5 meters. Each cell with Value 1 has a slope of < 10°. DEM: Output:
... View more
09-07-2022
07:30 AM
|
0
|
0
|
1017
|
|
POST
|
Wouldn't that be as simple as changing the condition? Or am I misunderstanding you? if($feature.Name == "Atlantic Croaker" && $feature.Percentage == 100100) {
return $feature.Value
}
return null Or, to stay with the X/Y notation from your question: var X = "Atlantic Croaker"
var Y = 100100
if($feature.Name == X && $feature.Percentage == Y) {
return $feature.Value
}
return null
... View more
09-07-2022
06:46 AM
|
0
|
0
|
2652
|
|
POST
|
It sounds like you only used the buffers as input fot the tool. If you use the buffers and the parcels as input, the tool will return a feature class that has each intersection between buffers and parcels. If Buffer_1 intersects the whole Parcel_1 and Buffer_2 intersects only a corner of Parcel_1, there will be two entries in the result feature class: whole geometry of Parcel_1 and the attributes of Parcel_1 & Buffer_1 only the corner of Parcel_1 with the attributes of Parcel_1 & Buffer_2 You can then use the buffer attributes (eg ObjectID or another primary key) to filter out the intersections belonging to a certain buffer. With a Python script, it would look like this: parcel_layer = "Parcels"
buffer_layer = "Buffers"
output_class = "IntersectParcelsBuffers"
# intersect
result = arcpy.analysis.Intersect([parcel_layer, buffer_layer], output_class)
# create a layer of this feature class for each buffer
buffer_id_field = "FID_Buffers" # ID field in the result table
buffer_ids = {row[0] for row in arcpy.da.SearchCursor(result, [buffer_id_field])}
for buffer_id in sorted(buffer_ids):
arcpy.management.MakeFeatureLayer(result, f"Buffer {buffer_id}", f"{buffer_id_field} = {buffer_id}") If you really want to use Clip, you can select each buffer and run it separately. This will take much longer and save a result feature class for each buffer (as opposed to the one result table for Intersect). parcel_layer = "Parcels"
buffer_layer = "Buffer"
output_gdb = "" # default gdb, change if you want
buffer_id_field = "OBJECTID"
buffer_ids = {row[0] for row in arcpy.da.SearchCursor(buffer_layer, [buffer_id_field])}
import os
for buffer_id in buffer_ids:
arcpy.management.SelectLayerByAttribute(buffer_layer, "NEW_SELECTION", f"{buffer_id_field} = {buffer_id}")
arcpy.analysis.Clip(parcel_layer, buffer_layer, os.path.join(output_gdb, f"Clip_Buffer_{buffer_id}"))
... View more
09-07-2022
06:36 AM
|
1
|
1
|
4661
|
|
POST
|
You can't symbolize parts of a multipart feature differently. All parts of the same feature will look the same. Multipoint is not the way to go here. Instead: create a point fc, add GlobalID for this example, I'll use these fields: VanID: Text, license plate number of the van Time: Short, possible values: 0 (day), 1 (night) Found: Short, possible values: 0 (no), 1 (yes) create two point features for each van, set the Time field accordingly create an attribute rule (Introduction to attribute rules—ArcGIS Pro | Documentation) // Calculation Attribute rule on Van FC
// Field: empty
// Triggers: Update
// Exclude from application evaluation
// if the value of Found didn't change, abort
if($feature.Found == $originalfeature.Found) {
return
}
// get the corresponding point
var van_id = $feature.VanID
var g_id = $feature.GlobalID
var same_van_other_time = First(Filter($featureset, "VanID = @VAN_id AND GlobalID <> @g_id"))
// safety check: if no other feature was found, abort
if(same_van_other_time == null) {
return
}
// return a dictionary that tells the geodatabase to edit the other feature
return {
edit: [{
className: "NameOfTheVanFC",
updates: [{
{globalID: same_van_other_time.GlobalID, attributes: {Found: $feature.Found}}
}]
}]
} Now when a worker updates the Found attribute of a van, the rule searches for the corresponding feature and updates its Found attribute automatically. You can then symbolize the point fc by unique values, choosing Time and Found as unique fields. This should give you a symbology of ("Day, Found"; "Day , Not Found"; "Night, Found"; "Night, Not Found").
... View more
09-06-2022
11:01 PM
|
1
|
0
|
1277
|
|
POST
|
You don't save your snow_values anywhere, so snow_values is just the date part of the last raster in location_a, which is why the comparison in line 28 returns False. You have location_a and location_b the wrong way around (or you mislabeled your screenshots). Your variable names are really misleading. Here's what you want to do (untested): # build a dictionary {date: raster} for the snow rasters
# I'm going by your screenshots: snow rasters in location_b
snow_raster_dict = dict()
arcpy.env.workspace = location_b
snow_raster_list = arcpy.ListRasters("", "TIF")
for snow_name in snow_raster_list:
snow_raster = Raster(snow_name)
#print(type(snow_raster))
snow_name_parts = snow_name.split("_")
snow_date = snow_name_parts[2]
snow_raster_dict[snow_date] = snow_raster
#print(snow_raster_dict)
# get the names of airtemp rasters
# again, going by your screenshots -> location_a
arcpy.env.workspace = location_a
airtemp_raster_list = arcpy.ListRasters("", "TIF")
#print(airtemp_raster_list)
for airtemp_name in airtemp_raster_list:
airtemp_raster = Raster(airtemp_name)
airtemp_name_parts = airtemp_name.split("_")
airtemp_date = airtemp_name_parts[0]
# try to get the corresponding snow raster
try:
snow_raster = snow_raster_dict[airtemp_date]
# do the calculation
output_raster = Con(snow_raster==1, 0, airtemp_raster)
output = os.path.join(location,airtemp_name.split("_")[0] +'_airtemp'+ '.tif')
output_raster.save(output)
#print(f"created new airtemp raster for {airtemp_date}")
# catch KeyErrors (date not found in snow_raster_dict)
except KeyError:
print(f"no snow raster found for {airtemp_date}")
... View more
09-06-2022
08:27 AM
|
1
|
2
|
2507
|
|
POST
|
from pathlib import Path
def get_folder(dataset):
parent = Path(dataset).parent
if "." in parent.name: # .gdb, .sde
return str(parent.parent)
return str(parent)
... View more
09-06-2022
07:51 AM
|
1
|
0
|
2651
|
|
POST
|
Ha, that's no reason to feel stupid! I've misnamed or misspelled variables so often that it's one of the first things I look for, now...
... View more
09-06-2022
06:37 AM
|
0
|
0
|
1412
|
|
POST
|
Your variable is named width_cat, but you're using width in the When() function.
... View more
09-06-2022
04:02 AM
|
2
|
2
|
1468
|
|
POST
|
Like this? if($feature.AssessmentID == null) {
return "null"
}
return {"Accounting": $feature.AssessmentID} Or do you want to set the value in the table to "null"?
... View more
09-05-2022
08:16 AM
|
0
|
2
|
2259
|
|
POST
|
This is absolutely possible. Instead of specifying the field for the rule and returning a value, you leave the field empty and return a dictionary. This dictionary has to have a defined structure, which you can find here: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm A simple example: // Calculation Attribute Rule
// field: empty
// triggers: insert
return {
edit: [
{className: "OtherTable",
adds: [
{attributes: {TextField: "Value", IntegerField: 5}}
]
}
]
} EDIT: And you can do lots of other things, too. A few examples are listed in this blog post: Advanced Attribute Rules - Editing features on another class with attribute rules (esri.com)
... View more
09-05-2022
05:05 AM
|
2
|
1
|
1821
|
|
POST
|
Besides, the junction point should intersect with one of the polygons in B_DSD_District Well, the Attribute Rule throws an error because the point does not intersect a polygon in the feature class. So, you have two possibilities: change the Attribute Rule, using the expression I posted above change your script, so that it inserts valid points To get more meaningful help, you would have to post your script.
... View more
09-05-2022
12:32 AM
|
0
|
0
|
1496
|
|
POST
|
Do not "transition" in the sense of gradually moving over to Pro, using both products for a long period of time. Just make a hard cut. Finish your current almost finished projects in Map. Rebuild everything else in Pro and don't switch back and forth. This forces you to learn how to do your work with Pro, as opposed to saying "I don't know how to do it in Pro, I'll just fire up Map and do it there". When my IT department finally installed Pro 2 years or so ago, I had them uninstall Map 3 months later, because I just didn't use it anymore. My colleague is very comfortable with Map and always falls back on using it if she has a problem in Pro. Understandable, but because of that she can only do basic mapping in Pro...
... View more
09-05-2022
12:25 AM
|
3
|
1
|
2443
|
|
POST
|
Your error is in the if statement. Most programming languages use "=" as assignment (var x = 3) and "==" as check for equal (x == 3 --> true). if($feature["Data_record_complete"] == "YES") {
return Now()
} While the default return value of Date() is the current date and time, I would use Now() here. It returns the same value but when reading the code it's clearer what you want to do, as you can construct arbitrary Dates with Date(). Also, depending on your field, you might want to use Today(), which only returns the date without the time.
... View more
09-04-2022
10:35 PM
|
1
|
0
|
2362
|
|
POST
|
Spitballing reasons: the FC is part of a service for Enterprise (you said fgdb, but still) I get this error when I have the same FC from a different connection opened in the project the FC is part of a locked Feature Dataset (if a FC in a FDS would be locked, the whole FDS is locked) This is what the docs have to say: Exclusive locks are applied when changes are made to a table or feature class. Editing and saving a feature class in a map, changing a table's schema, or using an insert cursor on a feature class in aPythonIDE are examples of when an exclusive lock is applied by ArcGIS. Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. TheUpdateCursororInsertCursorfunction fails because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset. Cursors supportwithstatements to reset iteration and aid in removal of locks. However, using adelstatement to delete the object or wrapping the cursor in a function to have the cursor object go out of scope should be considered to guard against all locking cases. So, try deleting your cursors (outside of the with block) to be absolutely sure that they don't lock anything anymore: with arcpy.da.XyzCursor(table, fields) as cursor:
for row in cursor:
pass
del cursor
... View more
09-01-2022
11:25 PM
|
0
|
0
|
4361
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-30-2023 09:57 AM | |
| 1 | 05-18-2023 12:51 AM | |
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|