POST
|
What version of the Python API are you using? Can you try the item.update with version 1.5.1 of the Python API? The newest version 1.6.0 did not work for me but 1.5.1 did.
... View more
03-25-2019
01:20 PM
|
0
|
2
|
6724
|
POST
|
Hello Hugo, Here is how you would delete a field from a feature layer hosted in AGOL. import arcgis
from arcgis.gis import GIS
# Provide credentials to the GIS object.
gis = GIS(username="your username", password= "your password")
#Get the id of the hosted feature layer
item = gis.content.get("id to the feature layer")
#Get the actual feature layer
fl = item.layers[0]
#This is the JSON structure you need to pass in so that it knows what field to delete.
# https://developers.arcgis.com/rest/services-reference/delete-from-definition-feature-layer-.htm
json = {
"fields" : [
{
"name" : "POP90_SQMI"
}
]
}
result = fl.manager.delete_from_definition(json)
print(result)
... View more
03-25-2019
10:33 AM
|
1
|
1
|
2363
|
POST
|
Hello Aaron, You can search by your organization id, then loop though all the items and print out the tags. Below is an example.... import arcgis
from arcgis.gis import GIS
gis = GIS()
search_result = gis.content.search(query="orgid: Your org id here", max_items = 100)
for item in search_result:
print(item.tags)
... View more
03-13-2019
11:40 AM
|
3
|
1
|
1276
|
POST
|
Essentially, there isn't concrete information on how the two API's work together. In general, they are two separate products. ArcGIS API for Python, is supposed to be used for automation of your web GIS while ArcPy is used for automation of GIS workflows when using ArcMap or ArcGIS Pro. You might get instances where you can use the two API's together and it works but you can't always rely on that since an object in ArcGIS API for Python may not be the same in ArcPy and vise versa (as Joshua Bixby pointed out). Your best bet is to stick with one API. It looks like you are mostly doing Web GIS related workflows. So, Joshua Bixby sample would get you the fields without using ArcPy.
... View more
02-06-2019
09:40 AM
|
0
|
1
|
3396
|
POST
|
Hello Benjamin, I think it is because arcpy.ListFields is expecting a string type and not an object type for the first parameter according to the documentation. This would make sense why feature_layer.url works because that would be a string.
... View more
02-01-2019
12:50 PM
|
0
|
3
|
3396
|
POST
|
Yes, I have updated the sample and it should work with polygons and polylines.
... View more
12-13-2018
02:50 PM
|
1
|
1
|
4229
|
POST
|
Hello Centerline, I was actually working on a sample that takes the 3.x sample of adding shapefiles to the map (Add Shapefile) and converting it to 4.x. It currently only works when the shapefile has points and not polygons/polylines. I ran into some issues when trying to complete this though... There is currently a bug with esri/request where the query parameters does not get passed to the body when making a POST. To work around this you can use a different request API like Fetch. Like I have said above, I have a working beta for shapefiles that include points. If you would like to use that as a starting point, feel free to let me know and I can send it to you. Also, you mentioned client-side, the sample would need an Portal or ArcGIS Online for this to work since it uses the Generate operation. EDIT: Looks like I actually got it to work. Here is the link to the code Sample of add shapefile. You do need AGOL or Portal for this to work. Also you may need the resource proxy to remedy any CORS errors you may get. This sample is based on the 3.x, so a lot of the code from that sample is the same with some changes for 4.x.
... View more
12-12-2018
12:27 PM
|
1
|
4
|
4229
|
POST
|
Hello Morten, I don't think the API support making items "authoritative" yet. But you can use the API to get the id's then use the requests module to hit the endpoint and make the item authoritative. Here is an example... import arcgis
from arcgis.gis import GIS
import requests
gis = GIS(None,'username', 'password')
featureLayerItem = gis.content.get('Your item id here')
r = requests.post('https://{0}/sharing/rest/content/items/{1}/setContentStatus'.format('Your org domain here',featureLayerItem.id), data= {'status': 'org_authoritative','clearEmptyFields': 'false', 'f':'json', 'token':'Your token here'})
You will need to put in your organizations domain and also you will need to get a token so that you can pass it with the request. This documentation shows how you can get a token using python.
... View more
08-24-2018
11:59 AM
|
1
|
0
|
2032
|
POST
|
Hello Gina, What version of ArcGIS Pro are you using? If it is not version 2.2.1, please upgrade to that version and try to run the Jupyter notebook again.
... View more
08-20-2018
03:30 PM
|
0
|
1
|
3249
|
POST
|
Hello Daniel, You can use the update method on an item to overwrite a csv on AGOL. Something like this might work for you..... import arcgis
from arcgis.gis import GIS
gis = GIS()
# Grab the id of the csv
csv = gis.content.get('ef220b9f500348e5867095d10fe751e5')
# Call the update method to replace/overwrite it with a csv file from disk
csv.update({}, r'path to csv file from disk') You can read up more on the parameters of the update method on the API documentation page (arcgis.gis module — arcgis 1.5.0 documentation).
... View more
08-17-2018
10:09 AM
|
1
|
0
|
4008
|
POST
|
Hello Gary, It might be because the major_cities_layers[0] does not have the properties attribute on it. This is the way I get attributes from a layer.... import arcgis
from arcgis.gis import GIS
gis = GIS()
featureLayerItem = gis.content.get('id for your feature layer')
print(featureLayerItem.layers[0].properties.extent) Which returns this.... {
"xmin": -178.21759836236583,
"ymin": 18.921786345087018,
"xmax": -66.9692710360024,
"ymax": 71.40623535327114,
"spatialReference": {
"wkid": 4269,
"latestWkid": 4269
}
}
... View more
08-17-2018
09:49 AM
|
2
|
1
|
554
|
POST
|
Hello Konrad, Something like this would work..... import arcgis
from arcgis.gis import GIS
gis = GIS()
# Grab the feature layer item by id
featureLayerItem = gis.content.get('c7c2420dfa884f34890da0a78b6a0533')
#Print out layer 0 from the layer list
print(featureLayerItem.layers[0]) Essentially, you can call the "layers" property which gives you back a list. Then you can access an item from that list by using the square bracket notation.
... View more
08-15-2018
03:56 PM
|
0
|
0
|
367
|
POST
|
Hello Scott, It is my understanding that a feature layer collection is just a collection of feature layers and tables. You can access a feature layer through the id or using the URL associated with it. The following documentation (Using Feature Layers | ArcGIS for Developers ) does a good job of explaining this workflow. In regards to overwriting a layer you will need to make sure that the local GDB has the same schema as the layer. Then you would just do the following.... Grab the feature layer you want to overwrite either through id or URL. This should give you back a feature layer collection. You can access the individual layers by using the "layers" attribute. Then call the overwrite method which is accessed using the manager property. The steps above is explained in the following sample (overwriting_feature_layers | ArcGIS for Developers). The sample is using a CSV but you can easily omit the parts you don't need since you are using a local GDB.
... View more
08-14-2018
09:24 AM
|
0
|
0
|
1495
|
POST
|
Hello Chai-Yuan Liu, If you want to publish a csv to portal you can do the following.... import arcgis
import json
from arcgis.gis import GIS
gis = GIS(None,'username', 'password', verify_cert=False)
try:
# Path to the CSV file
pathToFile = r'path to file'
# Add the CSV file to portal.
item = gis.content.add({'title': 'testcsv'}, pathToFile)
# If you want the table as a hosted feature layer then publish the item
item.publish()
except Exception as e:
print(e)
... View more
08-09-2018
03:31 PM
|
0
|
1
|
1005
|
POST
|
Hello Bob, To find all content for each user in a AGOL organization, you would just search for each user account and then loop through their items. Here is an example.... import arcgis
from arcgis.gis import GIS
# Log into AGOL account [admin level]
gis = GIS(None,'username', 'password', verify_cert=False)
# This function will show all content from all users in a AGOL subscription
def findItems():
try:
# Accounts is a list of all user objects
Accounts = gis.users.search(query= None, max_users =50)
# For each user in the org, give me a list of the items they own
for user in Accounts:
userItem = user.items(max_items=10)
if userItem: #checks to see if there are items in the current list
for item in userItem:
print("The item {0} is of type {1} and is owned by {2}".format(item.title,item.type,item.owner))
except Exception as e:
print(e)
findItems() I think this is what you are trying to do.
... View more
08-07-2018
10:36 AM
|
2
|
0
|
1889
|
Title | Kudos | Posted |
---|---|---|
1 | 08-17-2018 10:09 AM | |
1 | 03-25-2019 10:33 AM | |
1 | 03-09-2018 03:19 PM | |
1 | 12-13-2018 02:50 PM | |
1 | 03-22-2018 02:37 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|