Skip to content

Instantly share code, notes, and snippets.

@nommuna2
nommuna2 / Sample.py
Last active April 26, 2019 21:01
(ArcGIS API for Python) Sample of downloading feature services from AGOL
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
@nommuna2
nommuna2 / Sample.py
Last active April 26, 2019 21:03
(ArcGIS API for Python) Deleting all content from a user [Python API]
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:
@nommuna2
nommuna2 / Sample.py
Last active April 26, 2019 21:04
(ArcGIS API for Python) Sample of exporting a Feature layer to a file GeoDatabase using Python API
import arcgis
import json
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
# Log into AGOL account [admin level]
gis = GIS(None,'username', 'password', verify_cert=False)
# Grab the feature layer item by id
featureLayerItem = gis.content.get('feature layer id')
@nommuna2
nommuna2 / sample.py
Last active April 26, 2019 21:04
(ArcGIS API for Python) Update service definition in AGOL
import arcgis
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
# Log into AGOL account [admin level]
gis = GIS(None,'username', 'password', verify_cert=False)
# Grab the feature layer item by id
featureLayerItem = gis.content.get('feature layer id')
@nommuna2
nommuna2 / sample.py
Last active April 26, 2019 21:06
(Arcpy and ArcGIS API for Python) Automation of sd files and then publishing them to ArcGIS Enterprise
import arcgis
from arcgis.gis import GIS
import arcpy
import os
def createSDFiles():
workSpace = 'C:/sdFiles/'
arcpy.env.workspace = workSpace
fileList = os.listdir(workSpace)
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:09
(ArcGIS API for JavaScript) Sample of putting a third party chart API in a popup
require([
"esri/Map",
"esri/views/MapView",
"esri/PopupTemplate",
"esri/layers/FeatureLayer",
"esri/widgets/Popup",
"esri/tasks/support/Query",
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.js",
"dojo/domReady!"
],
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:15
(ArcGIS API for JavaScript) Sample of rendering polylines from a csv
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/CSVLayer",
"esri/config",
"esri/geometry/Polyline",
"esri/Graphic",
"esri/layers/GraphicsLayer",
"esri/layers/FeatureLayer",
"esri/layers/support/Field",
@nommuna2
nommuna2 / Sample.py
Last active April 26, 2019 21:16
(ArcGIS API for Python) Sample of turning a feature set to a feature collection using python api
import arcgis
from arcgis.gis import GIS
try:
gis = GIS(None,"USERNAME", "PASSWORD", verify_cert=False)
featureLayer = gis.content.get('ID')
# A Query operation returns a FeatureSet (https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html?highlight=query#featureset)
featureSet = featureLayer.layers[0].query(where="1=1", out_fields="*")
#Use the featureSet to make a featureCollection
featureCollection = arcgis.features.FeatureCollection.from_featureset(featureSet)
@nommuna2
nommuna2 / index.html
Last active January 8, 2020 17:55
(ArcGIS API for JavaScript) Sample of using chart.js with the Esri 4.7 API (Typescript version)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>ArcGIS JSAPI 4.6 TypeScript Demo</title>
<style>
html,
body,
#viewDiv {
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:19
(ArcGIS API for JavaScript) Sample of creating a form in a popup and using applyEdits operation to make edits to the feature layer.
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/widgets/Popup",
"esri/Graphic",
"dojo/domReady!"
],
function (Map, MapView, FeatureLayer, Popup, Graphic) {