|
POST
|
In theory you could use something like the code below, but it is throwing me an error (might be due to the proxy): def main():
import arceditor
import arcpy
import urllib, urllib2, json
target = r'D:\Xander\GeoNet\Hydrants\test02.shp'
service_url = r"http://gisweb.wsscwater.com/ArcGIS/rest/services/FireHydrant/FireBook/MapServer/0"
if arcpy.Exists(target):
arcpy.Delete_management(target)
bln_copy = True
exceededTransferLimit = True
i = 0
while exceededTransferLimit:
i += 1
if i == 1:
nextoid = 0
url = '{0}/query?where=OBJECTID>%3D{1}&outFields=*&returnGeometry=true&f=json'.format(service_url, nextoid)
print url
params = urllib.urlencode({'f': 'json', 'where': "OBJECTID>={0} AND TIPO_DIRECCION = 'R'".format(nextoid), 'outFields': 'OBJECTID', 'returnGeometry': 'false'})
req = urllib2.Request("{0}/query".format(service_url), params)
response = urllib2.urlopen(req)
jsonResult = json.load(response)
nextoid = getMaxOID(jsonResult) + 1
if "exceededTransferLimit" in jsonResult:
exceededTransferLimit = jsonResult["exceededTransferLimit"]
fs = arcpy.FeatureSet()
try:
fs.load(url)
cnt = arcpy.GetCount_management(fs).getOutput(0)
print "Count: " + cnt
if cnt != 0:
if bln_copy:
print " - copy"
arcpy.CopyFeatures_management(fs, target)
bln_copy = False
else:
print " - append"
arcpy.Append_management(fs, target)
except Exception as e:
print e
if exceededTransferLimit == False:
break
def getMaxOID(jsn):
max_oid = 0
if "features" in jsn:
ftrs = jsn["features"]
for ft in ftrs:
if "attributes" in ft:
att = ft["attributes"]
if "OBJECTID" in att:
oid = att["OBJECTID"]
if oid > max_oid:
max_oid = oid
return max_oid
if __name__ == '__main__':
main() ... so I did it in a little more manual way and attached the shapefile to this post.
... View more
12-18-2014
03:45 PM
|
3
|
2
|
4470
|
|
POST
|
Yes you can. Follow these steps: In the Catalog window in ArcMap, locate Add ArcGIS Server: Double click will reveal a dialog to add an ArcGIS Server: Use GIS services, Next> Specify the URL: http://imagery.arcgisonline.com/arcgis, leave the authentication blank, Finish. This will create an item "arcgis on imagery.arcgisonline.com (user)". Expand it and locate the "LandsatGLSChange" folder which holds the NDVI imagery. Drag the ones you're interested in to the map.
... View more
12-17-2014
08:04 PM
|
3
|
1
|
2078
|
|
POST
|
If you want to have the values in the dialog of the tool then this needs to be scripted in the tool validation. For example if you have a tool like this: and the result is to print a where clause of the values like this: ... the code in the script would be: import arcpy
fc = arcpy.GetParameterAsText(0)
fld = arcpy.GetParameterAsText(1)
selvals = arcpy.GetParameterAsText(2)
lst_vals = selvals.split(';')
where = "{0} in ('{1}')".format(arcpy.AddFieldDelimiters(fc, fld), "','".join(lst_vals))
arcpy.AddMessage(where) the validation code for the "updateParameters" function would be: def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if self.params[1].altered:
if self.params[1]:
fc = str(self.params[0].value)
fld = str(self.params[1].value)
lst_vals = list(set(r[0] for r in arcpy.da.SearchCursor(fc, (fld))))
self.params[2].filter.list = lst_vals
return In the validation, when the selected field is changed and has a value, the fc name and the fld name are read and used for the search cursor to create the list of unique values. This list is assigned to the filter.list of the 3rd parameter. The parameters are defined as follows: For the field you can filter the type of fields (optionally), but you will have to define "Obtained from" and select the feature layer. The list of values is a Multivalue (Yes) and the filter is an empty value list.
... View more
12-17-2014
07:47 PM
|
0
|
6
|
3077
|
|
POST
|
If your purpose is to have a local copy of the data to develop against (not updating the service itself) you could use some python code to extract the data of the map service: import arcpy
fcout = r'C:\Forum\Hydrants\test01.shp'
url = 'http://gisweb.wsscwater.com/ArcGIS/rest/services/FireHydrant/FireBook/MapServer/0/query?text=&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=1%3D1&time=&returnCountOnly=false&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=&outFields=*&f=pjson'
fs = arcpy.FeatureSet()
fs.load(url)
arcpy.CopyFeatures_management(fs, fcout) Since the number of features is more than 1000 and the maps service is configured to return a max of 1000 feature per request, the code should be adapted to use the object id to query with OBJECTID > highest id from previous request. Create the featureclass in the first step and append for the subsequent queries. Note this will only provide you a local copy of the data. The Map Service has no methods to update the service.
... View more
12-17-2014
07:13 PM
|
2
|
5
|
4470
|
|
POST
|
In Batch mode the description of the tool will be displayed: You can edit this by right click on the tool and enter the Properties, Description.
... View more
12-17-2014
06:52 PM
|
0
|
4
|
2650
|
|
POST
|
if you look at this example: ArcGIS Help 10.1 or ArcGIS Help (10.2, 10.2.1, and 10.2.2) you can see that getpass is used to ask for the password.
... View more
12-17-2014
03:27 PM
|
0
|
1
|
1737
|
|
POST
|
If you right click on your model, you will find a menu item called "Item description". In the dialog click on Edit. Now you can define the description for your model and each parameter you defined.
... View more
12-17-2014
03:20 PM
|
0
|
6
|
2650
|
|
POST
|
In addition to what Alexander Nohe mentioned, here is a link to the documentation: Introduction to arcpy.mp—ArcPy | ArcGIS for Professionals and this one is relevant too: Migrating arcpy.mapping to ArcGIS Pro—ArcPy | ArcGIS for Professionals
... View more
12-16-2014
04:44 PM
|
1
|
4
|
2171
|
|
POST
|
Do you need the GLOBALID field in the resulting featureclass? If not, remove the field or make a copy of the featureclass and remove the field there.
... View more
12-16-2014
04:38 PM
|
2
|
1
|
1849
|
|
POST
|
If you have access to an Advanced license you can use the Near tool. ArcGIS Help (10.2, 10.2.1, and 10.2.2) You would use the surrounding points as input features and the population points as near features. This will add information to you surrounding points about the population point that is nearest (field NEAR_FID). Next you could summarize on that field to get the number of surrounding points located near a population point. Join this number and the population to the surrounding points and divide the population by the number of points. If you don't have access to an advanced license, you could use a spatial join. ArcGIS Help (10.2, 10.2.1, and 10.2.2)
... View more
12-16-2014
03:39 PM
|
1
|
1
|
1865
|
|
POST
|
I assume based on your original question that you want to obtain all feature classes that start with "G" and add them to the current mxd. In that case you can do this: #import modules
import os
import arcpy
# input workspace
ws = r'C:\Users\Infomacion.gdb'
arcpy.env.workspace = ws
# feature dataset list
datasets = arcpy.ListDatasets(feature_type='feature')
datasets.append('')
# create a list with the featureclasses
lst_fcs = []
for ds in datasets:
for fc in arcpy.ListFeatureClasses(wild_card="G*", feature_type="polygon", feature_dataset=ds):
path = os.path.join(ws, ds, fc)
lst_fcs.append(path)
# create MXD and dataframe objects
mxd = arcpy.mapping.MapDocument ("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
# loop through feature class list
for fc in lst_fcs:
lyr = arcpy.mapping.Layer(fc)
arcpy.mapping.AddLayer(df, lyr, "BOTTOM") Basically, when you have the path to the featureclass, you can create a layer object (line 26) which can be added to the dataframe.
... View more
12-16-2014
03:22 PM
|
2
|
1
|
1916
|
|
POST
|
I have a burning question... why do you want to convert the script to a stand alone script? What are you trying to gain from this? Is it a something you want to execute as a scheduled task?
... View more
12-16-2014
04:11 AM
|
0
|
2
|
2187
|
|
POST
|
It may be a good idea to update to the final 10.3 now...
... View more
12-15-2014
07:57 PM
|
1
|
0
|
703
|
|
POST
|
How is the relation of the input points and the surrounding points defined? Are the input points already aware of the points the are surrounding the input point? If not, is this relation based on distance? Can a surrounding point be shared between input points?
... View more
12-15-2014
07:55 PM
|
0
|
3
|
1865
|
|
POST
|
When you have the list of featureclasses you can loop through the featureclass names and add them to you TOC. Before the loop you should get your mxd object, the dataframe where you want to add the layers. To get you going, have a look at the AddLayer method:ArcGIS Help (10.2, 10.2.1, and 10.2.2) ... and maybe you are interested in learning a little more on the arcpy.mapping module:ArcGIS Help (10.2, 10.2.1, and 10.2.2)
... View more
12-15-2014
07:51 PM
|
1
|
3
|
1916
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|