POST
|
Hi guys, i have developed a script Python that generate and publish a map service from folder that contains a shape file. The question is! Using Python is possible to add dinamiccaly the new service into a specific web map? thanks best
... View more
07-04-2020
03:10 PM
|
0
|
0
|
365
|
POST
|
Hi at all, I have developed a python script that use a make route agent layer to geo referencing a point or line on a segment. This script works fine on desktop and works fine on ArcGIS server 10.3 as a Geoprocessing Service. Now i have migrated the script on ArcMap 10.6 ( portal with ArcGIS server federated ) and before to publish as GP, he works fine on Desktop, but on server, the script run as a GP give a empty result with the same data using desktop. On ArcGIS Server 10.6 to use the make route event layer I need to set the linear referencing license? Any idea why with a different version on ArcGIS server the GP not works fine? Any help or idea is great. Thanks
... View more
08-13-2019
09:09 AM
|
1
|
0
|
364
|
POST
|
Hi, I have an ArcGIS REST Service that shows me more different Table, all tables are stored into Oracle Geodatabase Enterprise. I have written a python script that calls the REST service, extract data and create an Excel file. The Excel is added into a zip file. The zip file is written into the folder of the script. I have created a toolbox on ArcCatalog and I have set a parameter (GetParameterAsText as input) for the script. When I run the script by ArcCatalog, works fine and the zip file is added into the folder. After published on ArcGIS Server the script as Geoprocessing, I have noticed that the zip file is not written into folder arcgisjobs/gp/geoprocessing_name/scratch. There is some sample to see how I can download specific .zip folder created by the script on the server? The zip file contains all table data formatted into Excel Thanks Best
... View more
03-19-2019
09:48 AM
|
0
|
1
|
2134
|
POST
|
Hi at all, my organization have aa AGOL account and ArcGIS Enterprise 10.6 (Portal with ArcGIS Server Federated). I have seen this guide https://developers.arcgis.com/labs/rest/get-an-access-token/ of ArcGIS to generate token to use for all service into AGOL, in our case Geocoding Service. In this guide the example request clientId and client_secret for token request. In our Portal architecture, we have a geocoding service that uses a custom composite locator. Now into the Portal to generate token and use geocoding service, I don't have clientId and client_secret, correct? Or i can use this process also into the portal? Generally to use service using portal we generate a token by https://our_server/portal/sharing/rest/generateToken using named user credential. Is correct this process, or is possible to use the same process of the first link also into Portal? How?
... View more
02-03-2019
04:44 AM
|
1
|
0
|
498
|
POST
|
Hi Dan, i have updated my code using a correct format and i have added all my code. I hope that you could help me with this issues
... View more
12-15-2018
09:10 AM
|
0
|
1
|
516
|
POST
|
Hi at all, I have developed a Script python that read some different rest service, creates an empty feature and table with "in_memory" method and after use the insert cursor to insert data into in memory Feature and Table. The script works very fine into Desktop and I have published on ArcGIS Server. When I run the GP by rest folder I receive the error: Error executing tool. Spatial Job ID: j375ccc4c96d14276854f03877963f6cc : Traceback (most recent call last): File "/opt/esri/arcgis/data/server/arcgissystem/arcgisinput/GP/Script.GPServer/extracted/v101/script/Script.py", line 162, in ioid = InCur.insertRow(row) RuntimeError: Cannot find field 'field name' Failed to execute Ther filed name exsist into in_memory table. This is a part of the script import arcpy
import sys
import urllib
import urllib2
import datetime
import sys, os
bbox = '\''+arcpy.GetParameterAsText(0)+'\''
starttime = arcpy.GetParameterAsText(1)
endtime = arcpy.GetParameterAsText(2)
service_params = [
{
'url': "http://xxxxxxxx/MapServer",
'layerID': '14',
'fields': 'ORIG_CODE',
'name': 'PGRA_H',
'query':'1=1'
},
{
'url': "http://xxxxxxxxx/MapServer",
'layerID': '15',
'fields': 'ORIG_CODE',
'name': 'PGRA_M',
'query':'1=1'
},
{
'url': "http://xxxxxxxxxx/MapServer",
'layerID': '16',
'fields': 'ORIG_CODE',
'name': 'PGRA_L',
'query':'1=1'
},
{
'url': "http://xxxxxxxxxxxxxxxxxxx/MapServer",
'layerID': '0',
'fields': 'PREV6_BOLLETTINO, PREV6_TIME, PREV6_ACCUMULO, PREV6_PROB_PREC, PREV6_PK',
'name': 'meteo',
'query': 'PREV6_TIME > \''+starttime+'\' AND PREV6_TIME < \''+endtime+'\''
},
{
'url': "http://xxxxxxxxxx/MapServer",
'layerID': '3',
'fields': 'OR_ID, DEFINIZIONE, STATO_SISTEMA, STATO_UTENTE, LO_ORIGINE, LO_DESTINAZIONE,KM_INIZIO, KM_FINE,LT_PERFORMANCE',
'name': 'tratte',
'query': '1=1'
},
{
'url': "http://xxxxxxxxxxxxxxxxxx/MapServer",
'layerID': '0',
'fields': 'COD_PER_IT',
'name': 'PAIfrane',
'query':'1=1'
}
]
def buildUrl(serviceUrl, layerId, fields, bbox, query):
params = { 'outFields' : fields, 'geometry' : bbox, 'where': query, 'geometryType' : 'esriGeometryEnvelope', 'returnGeometry': 'true', 'spatialRel':'esriSpatialRelIntersects',
'f': 'pjson', 'inSR': '4326'}
params_encoded = urllib.urlencode(params)
url = serviceUrl + "/" + layerId + "/query?" + params_encoded
arcpy.AddMessage(url)
return url
def createFeatureSet(serviceUrl, layerId, fields, bbox, query):
fsURL = buildUrl(serviceUrl, layerId, fields, bbox, query)
fs = arcpy.FeatureSet()
fs.load(fsURL)
return fs
layer = {}
for s in service_params:
url = s['url']
layerId = s['layerID']
fields = s['fields']
name = s['name']
query = s['query']
fs_item = createFeatureSet(url, layerId, fields, bbox, query)
fs_item.save("in_memory/"+ name)
layer[name] = "in_memory/"+ name
print layer
#Segmentazione tratte
arcpy.Merge_management("in_memory/PGRA_H;in_memory/PGRA_M;in_memory/PGRA_L", "in_memory/PGRA")
arcpy.Dissolve_management(layer['meteo'], "in_memory/meteopoint_dissolve", "PREV6_PK")
arcpy.SplitLineAtPoint_management(layer['tratte'],'in_memory/meteopoint_dissolve','in_memory/tratte_split_meteopoints',search_radius='10 Meters')
arcpy.FeatureToPoint_management('in_memory/tratte_split_meteopoints','in_memory/tratte_mid_points','INSIDE')
arcpy.SplitLineAtPoint_management('in_memory/tratte_split_meteopoints','in_memory/tratte_mid_points','in_memory/tratte_split_midpoints',search_radius='10 Meters')
arcpy.SpatialJoin_analysis('in_memory/tratte_split_midpoints','in_memory/meteopoint_dissolve','in_memory/tratte_join_meteopoint','JOIN_ONE_TO_ONE',match_option='INTERSECT',search_radius='10 Meters')
arcpy.Dissolve_management('in_memory/tratte_join_meteopoint', 'in_memory/tratte_segmentate',"PREV6_PK", statistics_fields="OR_ID FIRST;DEFINIZIONE FIRST;STATO_SISTEMA FIRST;STATO_UTENTE FIRST;LO_ORIGINE FIRST;LO_DESTINAZIONE FIRST;KM_INIZIO FIRST;KM_FINE FIRST;LT_PERFORMANCE FIRST", multi_part="SINGLE_PART", unsplit_lines="DISSOLVE_LINES")
print arcpy.GetCount_management('in_memory/tratte_segmentate')
arcpy.AddMessage('Eseguita segmentazione tratte')
#Intersezione con pericolo idrogeologico (PGRA e PAI)
arcpy.Identity_analysis('in_memory/tratte_segmentate','in_memory/PGRA','in_memory/identity_PGRA')
arcpy.Identity_analysis('in_memory/identity_PGRA',layer['PAIfrane'],'in_memory/identity_PGRA_PAI')
print arcpy.GetCount_management('in_memory/identity_PGRA_PAI')
arcpy.AddMessage('Eseguite intersezioni con criticita idrogeologica')
#Ciclo punti meteo e creazione output tratte
arcpy.CreateTable_management('in_memory','tableoutput','in_memory/identity_PGRA_PAI')
arcpy.JoinField_management("in_memory/tableoutput",'PREV6_PK',layer['meteo'],'PREV6_PK',['PREV6_BOLLETTINO','PREV6_TIME','PREV6_ACCUMULO','PREV6_PROB_PREC'])
arcpy.AddMessage('Iniziato ciclo punti meteo per associazione informazioni\n\n')
infoarray = []
fields = arcpy.ListFields('in_memory/tableoutput')
for f in fields:
print(f.name)
PointDict = dict([(r[0], (r[1],r[2],r[3],r[4],r[5])) for r in arcpy.da.SearchCursor(layer['meteo'], ['OID@','PREV6_PK','PREV6_BOLLETTINO','PREV6_TIME','PREV6_ACCUMULO','PREV6_PROB_PREC'])])
for k, v in PointDict.items():
arcpy.AddMessage('Dictionary key: {}, valori: {}'.format(k,v))
with arcpy.da.SearchCursor('in_memory/identity_PGRA_PAI', ['PREV6_PK','FIRST_OR_ID','FIRST_DEFINIZIONE','FIRST_STATO_SISTEMA','FIRST_STATO_UTENTE','FIRST_LO_ORIGINE','FIRST_LO_DESTINAZIONE','FIRST_KM_INIZIO','FIRST_KM_FINE','FIRST_LT_PERFORMANCE','ORIG_CODE','COD_PER_IT','OID@']) as TratteCursor:
with arcpy.da.InsertCursor('in_memory/tableoutput',['PREV6_PK','FIRST_OR_ID','FIRST_DEFINIZIONE','FIRST_STATO_SISTEMA','FIRST_STATO_UTENTE','FIRST_LO_ORIGINE','FIRST_LO_DESTINAZIONE','FIRST_KM_INIZIO','FIRST_KM_FINE','FIRST_LT_PERFORMANCE','ORIG_CODE','COD_PER_IT','OID@']) as InCur:
for row in TratteCursor:
if row[0] == v[0]:
ioid = InCur.insertRow(row)
infoarray.append(ioid)
with arcpy.da.UpdateCursor('in_memory/tableoutput',['OID@','PREV6_BOLLETTINO','PREV6_TIME','PREV6_ACCUMULO','PREV6_PROB_PREC']) as UpCur:
for uprow in UpCur:
if uprow[0] in infoarray[:]:
uprow[1] = v[1]
uprow[2] = v[2]
uprow[3] = v[3]
uprow[4] = v[4]
UpCur.updateRow(uprow)
del infoarray[:]
#Export frane e alluvioni
arcpy.SpatialJoin_analysis('in_memory/PGRA',layer['tratte'],'in_memory/Alluvioni_interessate','JOIN_ONE_TO_ONE','KEEP_COMMON','','INTERSECT')
arcpy.SpatialJoin_analysis(layer['PAIfrane'],layer['tratte'],'in_memory/Frane_interessate','JOIN_ONE_TO_ONE','KEEP_COMMON','','INTERSECT')
arcpy.AddMessage('Eseguita estrazione Frane e Alluvioni')
#Calcolo livello di criticita' idrogeologica
arcpy.AddField_management('in_memory/tableoutput','CR_IDROGEO','TEXT','','',2,'CRITICITA\' IDROGEOLOGICA')
arcpy.AddField_management('in_memory/tableoutput','PRECIPITAZ','LONG','','','','PRECIPITAZIONI')
arcpy.CalculateField_management('in_memory/tableoutput','PRECIPITAZ','!PREV6_ACCUMULO!',"PYTHON_9.3")
arcpy.AddField_management('in_memory/tableoutput','DATAORA','DATE')
arcpy.CalculateField_management('in_memory/tableoutput','DATAORA',"datetime.datetime.strptime(!PREV6_TIME!, '%Y-%m-%dT%H:%M:%S')","PYTHON_9.3")
def AlterAlias(fc):
AliasDict= dict({'PREV6_PK':['PREV6_PK','ID PUNTO METEO'],'FIRST_OR_ID':['OR_ID','SEDE TECNICA'],'FIRST_DEFINIZIONE':['DEFINIZIONE','DEFINIZIONE'],'FIRST_STATO_SISTEMA':['STATO_SIS','STATO SISTEMA'],'FIRST_STATO_UTENTE':['STATO_UT','STATO UTENTE'],'FIRST_LO_ORIGINE':['LO_ORIG','LOCALITA\' DI ORIGINE',],'FIRST_LO_DESTINAZIONE':['LO_DEST','LOCALITA\' DI DESTINAZIONE'],'FIRST_KM_INIZIO':['KM_INIZIO','KM INIZIO'],'FIRST_KM_FINE':['KM_FINE','KM FINE'],'FIRST_LT_PERFORMANCE':['LINEA','LINEA'],'ORIG_CODE':['PGRA_CODE','PERICOLO ALLUVIONE'],'COD_PER_IT':['PAI_F_CODE','PERICOLO FRANA'],'PREV6_BOLLETTINO':['PREV6_BOLLETTINO','BOLLETTINO METEO'],'PREV6_TIME':['PREV6_TIME','ORARIO PREVISIONE'],'PREV6_ACCUMULO':['PREV6_ACCUMULO','PRECIPITAZIONI'],'PREV6_PROB_PREC':['PREV6_PROB_PREC','PROBABILITA\' DI PRECIPITAZIONI']})
for k, v in AliasDict.items():
arcpy.AlterField_management(fc,k,v[0],v[1])
AlterAlias('in_memory/tableoutput')
#I range attuali vanno sostituiti con quelli presenti nel documento dell'applicativo METEO
PGRADict = {xrange(10, 20):{'P1':'B','P2':'B','P3':'M'},xrange(20,30):{'P1':'B','P2':'M','P3':'A'},xrange(30,9999):{'P1':'M','P2':'A','P3':'A'}}
PAIDict = {xrange(10, 20):{1:'B',2:'B',3:'M',4:'M'},xrange(20,30):{1:'B',2:'M',3:'M',4:'A'},xrange(30,9999):{1:'B',2:'M',3:'A',4:'A'}}
with arcpy.da.UpdateCursor('in_memory/tableoutput',['PGRA_CODE','PAI_F_CODE','PRECIPITAZ','CR_IDROGEO','OID@']) as UpCur:
for row in UpCur:
arcpy.AddMessage('\n \n Precipitzioni = {}, PGRA = {}, PAI = {}, OID = {}'.format(row[2],row[0],row[1],row[4]))
for LAll, LAllinfo in PGRADict.items():
arcpy.AddMessage(' Alluvioni range: {}, valori: {}'.format(LAll,LAllinfo))
if row[2] in LAll:
arcpy.AddMessage(' Le precipitazioni rientrano nel range {} per il pericolo alluvione'.format(LAll))
for Allkey in LAllinfo:
arcpy.AddMessage(' Valore chiave: {}'.format(Allkey))
if row[0] == Allkey:
arcpy.AddMessage(' Valore associato: {}'.format(LAllinfo[Allkey]))
row[3] = str(row[3]).replace('None','')+str(LAllinfo[Allkey])
UpCur.updateRow(row)
for LFra, LFrainfo in PAIDict.items():
arcpy.AddMessage(' Frane range: {}, valori: {}'.format(LFra,LFrainfo))
if row[2] in LFra:
arcpy.AddMessage(' Le precipitazioni rientrano nel range {} per il pericolo frana'.format(LFra))
for Frakey in LFrainfo:
arcpy.AddMessage(' Valore chiave: {}'.format(Frakey))
if row[1] == Frakey:
arcpy.AddMessage(' Valore associato: {}'.format(LFrainfo[Frakey]))
row[3] = str(row[3]).replace('None','')+str(LFrainfo[Frakey])
UpCur.updateRow(row)
arcpy.AddMessage('Terminato calcolo livello di criticita idrogeologica')
arcpy.SetParameter(3, arcpy.MakeFeatureLayer_management("in_memory/Alluvioni_interessate","Alluvioni_interessate"))
arcpy.SetParameter(4, arcpy.MakeFeatureLayer_management("in_memory/Frane_interessate","Frane_interessate"))
arcpy.SetParameter(5, arcpy.MakeTableView_management("in_memory/tableoutput","tableoutput"))
arcpy.SetParameter(6, arcpy.MakeFeatureLayer_management("in_memory/identity_PGRA_PAI","identity_PGRA_PAI")) Any idea why the server gives the error on insert cursor into in_memory? Thanks
... View more
12-15-2018
08:41 AM
|
0
|
3
|
624
|
POST
|
Hi guys, I have a File Geodatabase that contains Feature classes, Attribute tables, and relationship class. I have exported all data as XML Workspace so I can import the data into an Oracle Geodatabase Enterprise ( Oracle version: Oracle 12c R2 (64 bit) 12.2.0.1 ). When I try to import XML Workspace document I receive this error Any help please to fix this error and load data? Thanks
... View more
04-07-2018
10:20 AM
|
0
|
1
|
2011
|
POST
|
Hi Vince, thanks for your reply. You are right! The coordinate are inverted and epsg is 4326. I have solved my problem and this is the update code: csvfile = arcpy.GetParameterAsText(0)
folder= arcpy.GetParameterAsText(1)
name = arcpy.GetParameterAsText(2)
shapename= name + ".shp"
spatref_epsg=4326
path = folder + "\\" + shapename
# Create Feature
arcpy.CreateFeatureclass_management(out_path=folder, out_name=shapename,geometry_type='POLYLINE',
spatial_reference=arcpy.SpatialReference(spatref_epsg))
arcpy.AddField_management(path, "ADDRESS", "TEXT", "","")
fields = ['SHAPE@','ADDRESS']
icur=arcpy.da.InsertCursor(os.path.join(folder,shapename),fields)
with open(csvfile,'rb') as f:
reader = csv.DictReader(f)
for row in reader:
try:
listrow=ast.literal_eval(row["route"])
listrow1=row["Address"]
line=arcpy.Polyline(arcpy.Array([arcpy.Point(coords[1], coords[0]) for coords in listrow]))
icur.insertRow((line,listrow1))
except:
e = sys.exc_info()[1]
del icur
Thanks for your help
... View more
10-19-2017
01:03 AM
|
1
|
0
|
1358
|
POST
|
Hi, I have a csv file with different fields: Address,route
First Av,[(39.72412, -104.9995), (39.72412, -105.00091), (39.72417, -105.00157), (39.72422, -105.00159)]
Second Av,[(39.72412, -104.9995), (39.72412, -105.00091), (39.72417, -105.00157), (39.72422, -105.00159)]
Street Av,[(39.72412, -104.9995), (39.72412, -105.00091), (39.72417, -105.00157), (39.72422, -105.00159)]
Street Av,[(39.72412, -104.9995), (39.72412, -105.00091), (39.72417, -105.00157), (39.72422, -105.00159)] Whith this code i create a polyline use the array coordinate field by csv: import arcpy,csv,ast
csvfile =r'lyft_1.csv'
folder=r'C:\Temp'
shapename=r'PolylineCSV.shp'
spatref_epsg=3006
icur=arcpy.da.InsertCursor(os.path.join(folder,shapename),'SHAPE@')
with open(csvfile,'rb') as f:
reader = csv.DictReader(f)
for row in reader:
listrow=ast.literal_eval(row["route"])
line=arcpy.Polyline(arcpy.Array([arcpy.Point(*coords) for coords in listrow]))
icur.insertRow((line,))
del icur But how i can insert the field address with array coordinate into Polyline?
... View more
10-12-2017
10:37 AM
|
0
|
2
|
2130
|
POST
|
hi, James, thanks for your replay. Your response if that I needed and i have correct my script in this way : desc = arcpy.Describe(m)
xmin = desc.extent.XMin
xmax = desc.extent.XMax
ymin = desc.extent.YMin
ymax = desc.extent.YMax
envelope = '{"xmin":%s,"ymin":%s,"xmax":%s,"ymax":%s}' % (xmin, xmax, ymin, ymax)
line = arcpy.da.SearchCursor(m, ("SHAPE@JSON",)).next()[0]
queryURL = "http://server/arcgis/rest/services/services/MapServer/1/query"
params = urllib.urlencode({'f': 'json', 'geometryType': 'esriGeometryEnvelope', 'inSR':'4326',
'geometry':envelope,
'spatialRel': 'esriSpatialRelIntersects','relationParam': 'FFFTTT***', 'outFields': '*','outSR':'4326', 'returnGeometry': 'true'})
req = urllib2.Request(queryURL, params)
response = urllib2.urlopen(req)
jsonResult = json.load(response) but now i would like to create a in_memory feature of this result but fc = arcpy.CopyFeatures_management(jsonResult, r"in_memory\feature") copy feature give me errorinstead with arcpy.Feature Set i could. I can create feature by the result of query Map Service? Thanks
... View more
10-06-2017
01:33 AM
|
0
|
0
|
738
|
POST
|
Hi, i have used this script to call a Map Service an retrivethe geometry: URL = "http://server/arcgis/rest/services/services/MapServer/0/query"
where = "1=1"
fields = "*"
query = "?where={}&outFields={}&returnGeometry=true&f=json".format(where, fields)
fsURL = URL + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
Now i need to request this service with POST method by REST folder and pass it InpputGeometry with Spatial Relationship, so i can load only a subset of data. How i can do this? There is some example? Thanks
... View more
10-05-2017
09:52 AM
|
0
|
2
|
2708
|
POST
|
Hi, i'm designing a complex GIS architecture that will publish more over 50 different services. I have think that i will create a logical division and i will develop high availability architecture with 2 or 3 server for all Map Services (30 complex Map Services), 2 server for Geoprocessing services ( 20 Geoprocessing Services and 10 SOE), 2 server for Image Services (3 Image Service by satelite image that size is 150 TB) All this services must be available for 500 total users. I have use this matematical alghoritm writed by Hussein Nasser into a public book, he is a Senior GIS Solution Architect: this is correct? What is the best practice to calculate ram by number users and services? Thanks
... View more
09-16-2017
07:22 AM
|
0
|
0
|
999
|
POST
|
Hi, i have develop a Geoprocessing services that have in a GPString as input value. Now i need to call this GP by other system in SOAP method using python. This is the python script to call GP in SOAP Methos: from suds.client import Client
# Call Server
client = Client('http://my_server/arcgis/services/Folder/FService/GPServer?wsdl')
toolname = 'FService'
json_string 'MQTT'
Values = []
Values.append(json_string)
print(client.service.Execute(toolname, Values[0], 'json','')) # Call with as many parameters you want The script call the SOAP method in correct way but pass always the default parameter of GP instead the value that i have set into script. Why? I have seen this documentation to write this request: ArcGIS Server SOAP SDK Any help please? Thanks
... View more
09-07-2017
08:07 AM
|
0
|
0
|
388
|
POST
|
Thanks Randy for your help. The output now is ok. Great Thanks
... View more
08-28-2017
01:42 AM
|
0
|
0
|
1290
|
POST
|
Hi Dan i have update my reques with code and more info Thanks
... View more
08-25-2017
07:49 AM
|
0
|
1
|
1290
|
Title | Kudos | Posted |
---|---|---|
1 | 02-03-2019 04:44 AM | |
1 | 10-22-2015 02:46 AM | |
1 | 10-19-2017 01:03 AM | |
1 | 02-22-2017 07:15 AM | |
1 | 08-13-2019 09:09 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|