This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample of how to copy a feature layer from a local ArcGIS server and publish it to AGOL. | |
import arcgis | |
from arcgis import features | |
from arcgis import GIS | |
from arcgis.gis import Item | |
import json | |
gis = GIS(username="username", password= "password") | |
#Turn Feature Layer to a Feature Set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcgis | |
from arcgis.gis import GIS | |
# Provide credentials to the GIS object. | |
gis = GIS(username="username", password= "password") | |
#Get the id of the hosted feature layer | |
item = gis.content.get("id of feature layer") | |
#Get the feature layer itself |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(["esri/map", | |
"esri/layers/ArcGISDynamicMapServiceLayer", | |
"esri/tasks/query", | |
"esri/tasks/QueryTask", | |
"esri/dijit/Popup", | |
"dojo/dom-construct", | |
"esri/dijit/PopupTemplate", | |
"dojo/domReady!" | |
], function (Map, ArcGISDynamicMapServiceLayer,Query, QueryTask, Popup, domCon, PopupTemplate) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require([ | |
"esri/Map", | |
"esri/views/MapView", | |
"esri/layers/FeatureLayer", | |
"dojo/domReady!" | |
], | |
function (Map, MapView, FeatureLayer) { | |
const filter = document.getElementById('state'); | |
//Create a new map and set the basemap to Dark gray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Adding an item to AGOL and publishing it | |
csv = r'path to csv' | |
csvItem = gis.content.add({}, csv) | |
csvFeatureLayer = csvItem.publish() | |
#Overwriting a service | |
#Search for the FeatureService by name | |
MyFeatureService = gis.content.search(query='title:SampleTest AND owner:owner') | |
#Get the id related to the Feature Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This sample uses the server to find if any points are within a certain polygon. | |
// This option only uses one for loop to go through each polygon and then uses a spatial filter as input to the query for the points. | |
// For this option your points would need to be on the server either through a map service or a feature layer. | |
require(["esri/map", | |
"esri/layers/FeatureLayer", | |
"esri/tasks/query", | |
"esri/tasks/QueryTask", | |
"esri/geometry/geometryEngine", | |
"esri/graphic", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Using a feature layer | |
import arcgis | |
from arcgis.gis import GIS | |
from arcgis.features import FeatureLayer | |
gis = GIS() | |
# Use the FeatureLayer class to get item from an service endpoint | |
url = 'https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Climate_Outlooks/cpc_6_10_day_outlk/MapServer' | |
layer = FeatureLayer(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcgis | |
from arcgis.gis import GIS | |
import requests | |
gis = GIS(None,'username', 'password', verify_cert=False) | |
try: | |
featureLayerItem = gis.content.get('item id') | |
r = requests.post('https://{0}/sharing/rest/content/items/{1}/setContentStatus'.format('org domain',featureLayerItem.id), data= {'status': 'org_authoritative','clearEmptyFields': 'false', 'f':'json', 'token': 'token'}) | |
print(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcgis | |
import json | |
from arcgis.gis import GIS | |
gis = GIS(None,'username', 'password', verify_cert=False) | |
# Download all data from a user | |
def downloadUserItems(owner, downloadFormat): | |
try: | |
#Search items by username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcgis | |
import json | |
from arcgis.gis import GIS | |
gis = GIS(None,'username', 'password', verify_cert=False) | |
#This function takes in a username and a item [type] for deletion | |
def deleteContent(owner, itemType): | |
try: |
OlderNewer