|
IDEA
|
I have to admit I assumed you could already do that...
... View more
04-18-2021
11:01 PM
|
0
|
0
|
3472
|
|
POST
|
Looks like it should work... The error is thrown at line 12, which is one of those (can't tell from your code): var search = Extent(Buffer($feature, .01, "feet"))
var segment = Clip(line, search)["paths"][0] Try these (separate or in combination): var search = Extent(Buffer($feature, 0.1, "feet")) // bigger buffer
var clip_geometry = Clip(Geometry(line), search) // use Geometry(line)
// test if the clip was successfull and return null (or a specific failure value) if not
// this won't solve the underlying problem, but will stop the error
if(clip_geometry == null) {
return null // return -9999
}
var segment = clip_geometry.paths[0] // .paths instead of ["paths"] Also: // Instead of doing the IsEmpty check before returning, do it at the start of the script, so you can return early.
if(!IsEmpty($feature.ROTATION)) {
return $feature.ROTATION
}
var lineClass = ...
// ...
return Angle(segment[0], segment[-1])
... View more
04-14-2021
11:09 PM
|
1
|
4
|
4496
|
|
POST
|
Good question. In that case, you would run this before: cat_names = [c[0] for c in arcpy.da.SearchCursor("Cat_Layer", ["CatName"])]
cat_names = list(set(cat_names)) # names of all cats in Cat_Layer
... View more
04-14-2021
10:38 PM
|
0
|
0
|
1854
|
|
POST
|
cat_names = ["cat_1", "cat_2", "cat_3", "cat_25"]
cat_numbers = []
for name in cat_names:
sql_query = "CatName = '{}'".format(name)
cat_rows = [c for c in arcpy.da.SearchCursor("Cat_Layer", ["CatName"], sql_query)]
cat_numbers.append(len(cat_rows))
for name, number in zip(cat_names, cat_numbers):
print("{} appeared {} times in Cat_Layer.".format(name, number))
#cat_1 appeared 56 times in Cat_Layer.
#...
#cat_25 appeared 572 times in Cat_Layer.
... View more
04-14-2021
08:07 AM
|
0
|
2
|
1875
|
|
POST
|
You can't change the field to disallow Null values as long as there are entries in the table. Delete all relationship classes your table is part of Copy your table Delete all rows from the table Change your field(s), you can now disallow Null values Edit the empty field values in the copy (or do it before step 1 in the original) Copy all rows from the copy to the original Delete the copy Recreate all deleted relationship classes !!! This will change ObjectID and GlobalID values of the table !!!
... View more
04-14-2021
07:34 AM
|
2
|
0
|
7074
|
|
POST
|
If you don't need to work with the tables in question in ArcMap (though you do have ArcMap listed...), you could define Constraint Attribute Rules. https://pro.arcgis.com/de/pro-app/latest/help/data/geodatabases/overview/an-overview-of-attribute-rules.htm // Triggers: Insert, Update
// blocks the edit if the field NotNullable is empty
if(IsEmpty($feature.NotNullable)) {return False}
return True
// or in one line:
// return !IsEmpty($feature.NotNullable) You won't be able to open these tables in ArcMap. You can open views containing the data, though. So if you don't do edits in ArcMap, this could be a solution...
... View more
04-14-2021
12:52 AM
|
1
|
2
|
7083
|
|
POST
|
While the code is still executing, the cell number will be displayed as In [*]: When the cell finished running, the number will be displayed as In [5]: Personally, I add a print statement to the end of each cell...
... View more
04-14-2021
12:43 AM
|
3
|
1
|
4468
|
|
POST
|
Then it gets more complex... county_fields = ["Folio", "Address", "SHAPE@", "Tax", "Owner"]
city_fields = ["folio", "address", "SHAPE@", "tax_rate", "parcel_owner"]
# read the rows of the county_fc
# [ [values_1], [values_2], ... ]
county_rows = [cr for cr in arcpy.da.SearchCursor(county_fc, county_fields)]
# create a lookup dictionary, using folio and address as key
# { [folio_1, address_1]: [values_1], [folio_2, address_2]: [values_2], ... }
county_dict = {cr[0:1]: cr for cr in county_rows}
# loop through the city_fc, lookup the county parcel values and update
with arcpy.da.UpdateCursor(city_fc, city_fields) as city_parcels:
for row in city_parcels:
key = row[0:1]
try:
new_row = county_dict[key]
# Only update if something changed
# I can't test this right now, it could be that this doesn't
# work for SHAPE@
if new_row != row:
# print a message telling you what changed
print("parcel with folio and address = {} was edited. Old values: {}. New Values: {}".format(key, row, new_row))
city_parcels.updateRow(new_row)
# remove row from county_rows
county_rows.remove(new_row)
except KeyError:
print("county_fc has no parcel with folio and address = {}".format(key))
missing_parcels.append(key)
# We removed the entries in county_rows that were already in city_fc.
# All entries still in county_rows must be new entries in county_fc.
print("There are {} new entries in county_fc.".format(len(county_rows ))
for new_entry in county_rows :
print(new_entry)
if len(county_dict) > 0:
# Copy the new county parcels to city_fc
with arcpy.da.InsertCursor(city_fc, city_fields) as city_parcels:
for new_entry in county_rows:
city_parcels.insertRow(new_entry)
... View more
04-13-2021
09:28 AM
|
1
|
0
|
2658
|
|
POST
|
For each of your fish species, create an Arcade expression: // show_fish_species_1
// returns 'inline' if the field is not empty, else 'none'
// If your empty fields are filled with 0, use this
return IIF($feature.FishSpecies1 == 0, 'none', 'inline')
// If your empty fields are empty, use this
return IIF(IsEmpty($feature.FishSpecies1), 'none', 'inline')
// Or just do both
return IIF(IsEmpty($feature.FishSpecies1) || $feature.FishSpecies1 == 0, 'none', 'inline') Edit the HTML source of you popup (your example sentences seem a little too complex to do this way, so I remodeled a bit): {Location} was stocked
<div style="display:{expression/show_brook_trout_1};">
with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1},
</div>
<div style="display:{expression/show_brook_trout_2};">
with {BrookTrout2} 2 year old Brook Trout on {SurveyDate2},
</div>
<div style="display:{expression/show_raibow_trout_1};">
with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3},
</div>
<div style="display:{expression/show_raibow_trout_2};">
and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4},
</div>
. If you always survey all fish of the same species, you can do {Location} was stocked
<div style="display:{expression/show_brook_trout};">
with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1} and {BrookTrout2} 2 year old Brook Trout on {SurveyDate2}.
</div>
<div style="display:{expression/show_raibow_trout};">
It was also stocked with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3} and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4}.
</div>
. The basic idea is simple: put parts of the text in <div> tags and show or hide these (display: inline/none) according to your number fields. Depending on the structure of your surveys and popup sentences, it could get pretty complex.
... View more
04-13-2021
08:49 AM
|
3
|
1
|
6207
|
|
POST
|
The basic code would be something like this: county_fc = "path/to/county/featureclass"
city_fc = "path/to/city/featureclass"
# define the fields that have to be updated
# all other fields will stay the same
# same order for both feature classes
# you need a field that has the same values in both feature classes,
# e.g. ParcelID. In this example, that field has to be the first element
# of the field lists.
county_fields = ["ParcelID", "SHAPE@", "Tax", "Owner"]
city_fields = ["parcel_id", "SHAPE@", "tax_rate", "parcel_owner"]
# read the rows of the county_fc
# [ [values_1], [values_2], ... ]
county_rows = [cr for cr in arcpy.da.SearchCursor(county_fc, county_fields)]
# create a lookup dictionary, using the parcel id as key
# remember, in this example, it's the first element of county_fields
# { parcel_id_1: [values_1], parcel_id_2: [values_2], ... }
county_dict = {cr[0]: cr for cr in county_rows}
# loop through the city_fc, lookup the county parcel values and update
with arcpy.da.UpdateCursor(city_fc, city_fields) as city_parcels:
for row in city_parcels:
parcel_id = row[0]
try:
new_row = county_dict[parcel_id ]
city_parcels.updateRow(new_row)
except KeyError:
print("county_fc has no parcel with parcel_id = {}".format(parcel_id)) You can save that as a standalone Python script and run that manually, or you can schedule it to run periodically, or you can use the code in a script tool.
... View more
04-13-2021
08:18 AM
|
1
|
2
|
2685
|
|
POST
|
This looks like a simple job for Python or Arcade. Python: # values in Date fields in ArcGis are datetime.datetime objects
import datetime
def get_financial_year(timestamp):
"""Returns the Australian financial year of the given timestamp (as datetime.datetime object) as a string."""
year = timestamp.year
if timestamp.month >= 7:
return "{}-{}".format(year, str(year+1)[-2:])
return "{}-{}".format(year-1, str(year)[-2:])
# to test it:
timestamps = [
datetime.datetime(2020, 11, 16, 0, 2, 58),
datetime.datetime(2020, 6, 16, 0, 2, 58),
datetime.datetime(2019, 10, 16, 0, 2, 58),
datetime.datetime(2019, 3, 16, 0, 2, 58),
]
for ts in timestamps:
print(get_financial_year(ts))
#2020-21
#2019-20
#2019-20
#2018-19 You can use that in the CalculateField tool (so you can also use it as part of a model), or you can just keep working with python: fc_path = "path/to/your/feature/class"
date_field = "Timestamp"
financial_year_field = "FinancialYear"
with arcpy.da.UpdateCursor(fc_path, [date_field, financial_year_field]) as cursor:
for date, year in cursor:
cursor.updateRow([date, get_financial_year(date)])
... View more
04-12-2021
01:13 AM
|
1
|
0
|
1774
|
|
POST
|
Edit: Oops, didn't notice this was for the javascript API. I'm leavingn the comment, maybe it helps someone... If I understood you correctly, you want to search a layer in the search widget, then jump to the found feature and open its popup. If you work in a web map, you have to make the layer searchable in the map settings. Follow these instructions: https://doc.arcgis.com/en/arcgis-online/create-maps/configure-feature-search.htm If you work in a web app, you have to edit the settings of the search widget. Follow these instructions: https://doc.arcgis.com/en/web-appbuilder/create-apps/widget-search.htm
... View more
04-09-2021
02:53 AM
|
0
|
0
|
827
|
|
POST
|
You can just put your own anchors into the HTML source. <a id="top"></a>
<a href="#bottom">Go to bottom</a>
<div style="display:block;height:1000px"></div>
<a href="#top">Go to top</a>
<a id="bottom"></a>
... View more
04-09-2021
02:26 AM
|
2
|
1
|
1305
|
|
POST
|
Yeeees, I need that badly. Additionally, it would be great to see in which ArcMap and ArcGIS Pro projects they are used. The amount of times I deleted a view I thought was irrelevant just to have a coworker come to me afterwards and complain that their layer's datasource is broken...
... View more
04-09-2021
01:50 AM
|
0
|
0
|
973
|
|
BLOG
|
Thank you for this great explanation! This is a parameter that always confused me, but ArcGIS always told me when to check that box, so I didn't research it. The attribute rule has to be written in such a way to allow for the server to skip computation that has been already performed in the client. Sure, if I calculated a+b locally to improve throughput on the server, it would be senseless to have the server do it again. But how do you write such a rule? I don't see a way to tell the server that your example rule was already executed. In my opinion, that should be part of the communication between client and server. When applying the edit, the client should tell the server it already did the job, so the server doesn't even have to start the execution to perform some checks built into the rule to see if it already executed.
... View more
04-09-2021
01:29 AM
|
0
|
0
|
9541
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM | |
| 1 | 09-18-2023 04:55 AM | |
| 1 | 11-07-2022 11:15 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|