Script Python by Pak Cul
Script Python by Pak Cul
Script Python by Pak Cul
import urllib2,json,os,arcpy,itertools
ws = os.getcwd() + os.sep
#Set koneksi ke ArcGIS Server, map service, layer ID, dan jumlah maksimal request
ke server (1000 adalah default jika tidak diketahui).
#Contoh alamat koneksi ke geoportal kemenlhk adalah
http://geoportal.menlhk.go.id/arcgis/rest/services/KLHK/KHG/MapServer/0/query, maka
dibagi menjadi 3, tulisan query di belakang tidak disertakan, sehingga menjadi;
serviceURL = "http://geoportal.menlhk.go.id/arcgis/rest/services"
serviceMap = "/KLHK/BURN_AREA_2017/MapServer"
serviceLayerID = 0
serviceMaxRequest = 1000
def defServiceGetIDs():
IDsRequest = serviceURL + serviceMap + "/" + str(serviceLayerID) + "/query?
where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR
=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true
&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly
=true&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistic
s=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=
&resultRecordCount=&f=pjson"
IDsResponse = urllib2.urlopen(IDsRequest)
IDsJSON = json.loads(IDsResponse.read())
IDsSorted = sorted(IDsJSON['objectIds'])
return IDsSorted
#**MAIN**#
#Get all objectIDs (OIDs) for the layer (there is no server limit for this request)
AllObjectIDs = defServiceGetIDs()
#Divide the OIDs into chunks since there is a limit to map queries (assumed limit
stored in serviceMaxRequest variable)
ObjectID_Groups = list(defGroupList(serviceMaxRequest, AllObjectIDs))