|
POST
|
Hi @jcarlson , If you're using AGOL, you already have Notebook available and you can add a notebook as an item from your pc onto AGOL: or create a new one. Once it's been added/created you can share it to anyone or to a specific member just like other items. If you're using Portal, first you need to have Notebook Server installed in Portal (ArcGIS Enterprise). Then similar to AGOL you will have different sharing options. Cheers Mehdi
... View more
12-13-2020
05:37 PM
|
0
|
1
|
1084
|
|
POST
|
Hi @SharitaU , I've already provided two scripts in the link below for appending and overwriting a feature layer: https://community.esri.com/t5/arcgis-api-for-python-questions/correct-workflow-for-publishing-then-updating-hosted-feature/m-p/1007794#M5284 I hope that helps.
... View more
12-13-2020
05:26 PM
|
0
|
0
|
2991
|
|
POST
|
Hi @KrishV , That's bizarre! Did you try to apply that manually in ArcGIS Pro to see if the process gives the same result or not?
... View more
12-13-2020
05:06 PM
|
0
|
1
|
2270
|
|
POST
|
Hi @NatalieDobbs1 You are getting this error because the following video has not be shared publicly:
... View more
12-13-2020
05:02 PM
|
0
|
3
|
4308
|
|
POST
|
Hi @KrishV There is no Band 13 in Sentinel2 and your NBR formula "(b9 - b13) / (b9 + b13) + 2000" is different from that of esri. The correct formula for NBR is "(b5 - b7) / (b5 + b7+1000)" Besides that, you have used time=[datetime(2020, 4, 3), datetime(2020, 4, 15)] this period of time which means there might be no fire occurred between these dates. If you visualize prefire and midfire, you might be able to check if a fire has occurred in the images or not prior to further calculations. Cheers Mehdi
... View more
12-08-2020
10:25 PM
|
0
|
1
|
2405
|
|
POST
|
Hi @Jay_Gregory The script I've written reads a GDB feature class and updates a web feature layer i.e. appends new data to it. You just need to change/update the fields of attribute table. from arcgis import GIS
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis import geometry
from copy import deepcopy
gis = GIS('url', 'username', 'password')
sdf_to_append = pd.DataFrame.spatial.from_featureclass(r"path to gdb feature class")
#search for the hosted feature layer/service
featureLayer_item = gis.content.search('type: "Feature Service" AND title:"xxxxx"')
#access the item's feature layers
feature_layers = featureLayer_item[0].layers
#query all the features
fset = feature_layers[0].query()
features_to_be_added = []
template_hostedFeature = deepcopy(fset.features[0])
for index, row in sdf_to_append.iterrows():
x = sdf_to_append.loc[index]['SHAPE']['x']
y = sdf_to_append.loc[index]['SHAPE']['y']
new_feature = deepcopy(template_hostedFeature)
input_geometry = {'y':float(y), 'x':float(x)}
output_geometry = geometry.project(geometries = [input_geometry],
in_sr = 3857,
out_sr = 3857,
gis = gis)
# assign the updated values
new_feature.geometry = output_geometry[0]
new_feature.attributes['HoleID'] = row['HoleID']
new_feature.attributes['Project'] = row['Project']
new_feature.attributes['InterFrom'] = row['InterFrom']
new_feature.attributes['InterTo'] = row['InterTo']
new_feature.attributes['Grade'] = row['Grade']
new_feature.attributes['GramMetre'] = row['GramMetre']
new_feature.attributes['RegoProf'] = row['RegoProf']
new_feature.attributes['MidPoint'] = row['MidPoint']
new_feature.attributes['IntercptNo'] = row['IntercptNo']
new_feature.attributes['Overlap'] = row['Overlap']
new_feature.attributes['EndDate'] = row['EndDate']
new_feature.attributes['EAST'] = row['EAST']
new_feature.attributes['NORTH'] = row['NORTH']
new_feature.attributes['RL'] = row['RL']
new_feature.attributes['Width'] = row['Width']
features_to_be_added.append(new_feature)
feature_layers[0].edit_features(adds = features_to_be_added)
print("Hosted feature layer is updated with gdb feature class!") However if you want to overwrite a feature layer, it's recommended to truncate it first then do an overwrite: from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("url", "username", "password")
# get the feature layer
flc_item = gis.content.get("item_id")
fLyr = flc_item.layers[0]
fLyr.manager.truncate()
# get the gdb item
gdb_item = gis.content.get("gdb_item_id")
feature_layer_collection = FeatureLayerCollection.fromitem(flc_item)
feature_layer_collection.manager.overwrite(gdb_item) I hope that's helpful. Cheers Mehdi
... View more
12-08-2020
05:21 PM
|
0
|
4
|
4193
|
|
POST
|
Hi @RichThomas2 , If you do a truncate on the feature layer first then overwrite the feature layer collection, it should work. from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("url", "username", "password")
# get the feature layer
flc_item = gis.content.get("item_id")
fLyr = flc_item.layers[0]
fLyr.manager.truncate()
# get the gdb item
gdb_item = gis.content.get("gdb_item_id")
feature_layer_collection = FeatureLayerCollection.fromitem(flc_item)
feature_layer_collection.manager.overwrite(gdb_item) I hope that helps.
... View more
12-02-2020
06:16 PM
|
0
|
0
|
1955
|
|
POST
|
@ejuser Depending on what aggregation function you want the 3 years for one unit code in the output, try this out. I've used sum and you can change the aggfunc to mean, .... df.pivot_table(values=['GrowYrAbr','AvgHt','MaxHt','WstHt','AvgHt21','MaxHt21','WstHt21','AvgHt22','MaxHt22','WstHt22','AvgHt23','MaxHt23','WstHt23'],
columns='Unit',
aggfunc='sum',
fill_value=0,
margins=False,
dropna=True,)
... View more
11-19-2020
10:54 PM
|
1
|
1
|
3037
|
|
POST
|
Hi @ejuser , Pivot method in pandas might do what you are looking for. See below: import pandas as pd
df = pd.read_csv(path to csv file)
df.pivot(index='Unit', columns='GrowYrAbr', values=['AvgHt','MaxHt','WstHt','AvgHt21','MaxHt21','WstHt21','AvgHt22','MaxHt22','WstHt22','AvgHt23','MaxHt23','WstHt23']) you can change the index and columns if this is not the result you are after. Hope that's helpful.
... View more
11-18-2020
05:47 PM
|
1
|
2
|
3077
|
|
POST
|
Hi @Jay_Gregory , I tested the code in 1.8.2 and it's working fine. I can recommend to upgrade to ArcGIS API for Python 1.8.2: from arcgis.gis import server
from arcgis.features import FeatureLayer
gis = server.Server("server url/hosting/admin", username="username", password="password", verify_cert=False)
fl = FeatureLayer("your_ent_admin_profile", gis=gis)
features = fl.query(where='1=1', out_fields='location, rating',)
features <FeatureSet> 7 features features.sdf
... View more
11-16-2020
04:59 PM
|
0
|
2
|
1825
|
|
POST
|
Hi Gregory Greene, I checked the ArcGIS API for Python reference, there is nowhere mentioning about the vertices limitation for polygon or polyline feature classes. I can recommend implementing Repair Geometry on the polygon feature class in ArcGIS Pro. This will fix the geometry issues you might have in the polygon feature class before running edit_features(). Hope that helps. ------------------------------------------------------------------------------------------------------------------------------------ Please mark as helpful if you find it helpful. If it answered your question please mark it as answered.
... View more
11-10-2020
04:59 PM
|
1
|
4
|
4297
|
|
POST
|
Hi Rubén Pérez Planillo, Map options and export options are not included in the web map json for export_map method in ArcGIS API for Python by default yet. As such, you need to insert those options into web map json first then run the export_map method. from arcgis.gis import GIS
from arcgis.mapping import export_map
gis = GIS("portal or AGOL url", "username", "password")
webmap_item = gis.content.get("webmap id")
webmap_json = webmap_item.get_data()
# Modify json with map options and export options
webmap_json['mapOptions'] = {
"extent" : {
"xmin": webmap_item.extent[0][0],
"ymin": webmap_item.extent[0][1],
"xmax": webmap_item.extent[1][0],
"ymax": webmap_item.extent[1][1],
"spatialReference": {
"latestWkid": 3857,
"wkid": 102100
}
},
"scale" : 24000,
"spatialReference" : {
"wkid" : 102100
}
}
webmap_json['exportOptions'] = { "dpi" : 96,
"outputSize" : [746, 575]
}
out = export_map(web_map_as_json=webmap_json, format='PNG8', layout_template='MAP_ONLY', gis=gis) For a spatial reference variable, you can use "spatialReference" : webmap_item.spatialReference instead of hard-coding provided the web map is already spatially defined. I hope that helps. ------------------------------------------------------------------------------------------------------------------------------------ Please mark as helpful if you find it helpful. If it answered your question please mark it as answered.
... View more
11-09-2020
06:14 PM
|
1
|
0
|
2944
|
|
POST
|
Hi Dylan Warburg, I reckon ArcGIS API for Python is faster than arcpy in updating hosted feature services/layers. Here's a link that shows how to update attributes of a hosted feature layer in AGOL or Portal: Updating Feature layer using ArcGIS API for python. ------------------------------------------------------------------------------------------------------------------------------------ Please mark as helpful if you find it helpful. If it answered your question please mark it as answered.
... View more
11-09-2020
04:51 PM
|
0
|
0
|
1252
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-16-2021 09:38 PM | |
| 1 | 03-17-2024 06:09 PM | |
| 1 | 11-10-2020 04:59 PM | |
| 1 | 02-08-2021 09:29 PM | |
| 1 | 02-17-2021 04:47 PM |