POST
|
I have a map series with point and line features labelled in a background callout style. However, Pro both places labels on top of each other, and more problematically, cuts them off at the edge of the layout frame. How can I prevent this? Thanks.
... View more
08-06-2018
07:31 AM
|
2
|
8
|
3433
|
POST
|
Thanks Carmel, that worked perfectly.Much appreciated.
... View more
08-01-2018
05:31 AM
|
1
|
0
|
493
|
POST
|
I have a pop up configured in a web map that links to pdfs. Click the link, pdf displays. All good. However, the link in the pop up is 'More Info'. I'd like it to display the actual link, i.e. http://somesite/somepdf.pdf while still linking.Is this possible, and if so, how? Thanks.
... View more
07-31-2018
12:52 PM
|
0
|
2
|
650
|
IDEA
|
It would be helpful to have the ability to add a list of ObjectIds in a REST endpoint query, rather than specifying them all individually. Of course it's possible to construct a string with all the ids in Python, but that's an extra operation when they're already in a list.
... View more
03-06-2018
09:09 AM
|
1
|
0
|
550
|
POST
|
This is part of a script. The layers are needed because I'm applying definition queries to them and then using them in a spatial join. The basic process is to assign annotation text to the polygon containing it, then assign the text to points within the polygon.
... View more
03-01-2018
06:51 AM
|
0
|
0
|
360
|
POST
|
I'm creating 3 feature layers in one function. I'd like to return them from the function in a list, but as I expected, their type in the list is just string. I know I can save them out as a lyr file, but trying to avoid that if possible. Maybe they go out of scope when the function ends? Thanks. def makeFeatureLayers():
"""
Make feature layers from Annotation, Polygon and Points features
"""
print("\nCreating feature layers")
anno = 'Annotation'
pt = 'Point'
poly = 'Polygon'
anno_path = os.path.join(ds_path, anno)
pt_path = os.path.join(ds_path, pt)
poly_path = os.path.join(ds_path, poly)
fc_dict = {}
fc_dict[anno] = anno_path
fc_dict[pt] = pt_path
fc_dict[poly] = poly_path
fc_list = []
for k, v in fc_dict.iteritems():
lyr_name = k + '_lyr'
try:
arcpy.MakeFeatureLayer_management(v, lyr_name)
fc_list.append(lyr_name)
except Exception as e:
print("\nError: {}".format(e))
print(arcpy.GetMessages(2))
for fc in fc_list:
print("\nType of fc: {}".format(type(fc)))
... View more
02-28-2018
08:21 AM
|
0
|
4
|
465
|
POST
|
I have a script that goes out to REST endpoints to retrieve the various services. However, some of these services have hundreds of thousands of records. The max record limit on the endpoints is 1000, meaning I have to first get all the ObjectIDs and query the service in batches of 1000 based on the ObjectIDs. For 100,000 records, this means 100 queries. This is very time consuming. Is there a better way to get this data? Thanks. for id in idstofetch:
# starting and ending object id for each group
idmin = str(id[0])
idmax = str(id[-1])
query_dict = {"token" : token["token"],
"where" : "objectId >=" + idmin + "and objectid <=" + idmax,
"outfields" : "*",
"outSR" : 4326,
"returnGeometry" : "true",
"f" : "json"}
r = requests.get(url, query_dict, stream=True)
# build json file name
f = v.replace(' ', '_')
f = f.replace('(', '_')
f = f.replace(')', '_')
filenm = os.path.join(interim_folder, '{}_'.format(f) + dt + '_' + idmax) + '.json'
# create json file
with open(filenm, 'wb') as fd:
for chunk in r.iter_content(chunk_size=256):
fd.write(chunk)
... View more
02-26-2018
07:33 AM
|
0
|
1
|
574
|
POST
|
I have a tool where I'm trying to do some script validation. The user selects a data frame from a map as the first parameter, self.params[0] (works fine), and then should select a layer from the layers in that data frame. However, I can't get the second parameter to populate based just on the selected dataframe. The code below doesn't throw an error, but returns an empty list, and thus no layers to select. I've tried several variations on this, and the only one that works at all returns all layers in the mxd, not just the ones in the data frame. This seems like it should be simple, but I'm missing something. Any ideas? Thanks. def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened.
Populates data frame parameter with data frames in map and disables other
parameters.
"""
try: # this works
mxd = arcpy.mapping.MapDocument('CURRENT')
dflist = [df.name for df in arcpy.mapping.ListDataFrames(mxd)]
self.params[0].filter.type = "ValueList"
self.params[0].filter.list = dflist
del mxd
except:
arcpy.AddError("\nMust run this tool in ArcMap, not ArcCatalog")
self.params[1].enabled = False
self.params[2].enabled = False
return
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."""
mxd = arcpy.mapping.MapDocument('CURRENT')
if self.params[0].value:
self.params[1].enabled = True
# this does not work the way I want
layerList = [lyr.name for lyr in arcpy.mapping.ListLayers(mxd, self.params[0].value) if not lyr.isGroupLayer]
uniqueList = list(set(layerList))
uniqueList.sort()
self.params[1].filter.type = "ValueList"
self.params[1].filter.list = uniqueList
... View more
01-15-2018
06:17 AM
|
0
|
2
|
1052
|
POST
|
Ok, so I used the code above along with the requests module and got it almost all working (probably don't have to use both urllib and requests, but it works). Works fine, except for one thing: the REST data is in WGS_1984_Web_Mercator_Auxiliary_Sphere, and I want to import it into WGS 1984. From what I've read, setting outSR to 4326 should do it, but no luck. Still imports in Web Mercator. If I go to the rest endpoint in a browser and set it, works correctly, just not in the script. Is this a bug, am I setting it wrong, ??? Thanks.(Sorry, forgotten how to format as code). def getJson(token): # query parameters query_dict = {"token" : token["token"], "where" : "1=1", "outfields" : "*", "outSR" : "4326", "f" : "json"} baseurl = "http://company/arcgis/rest/services/Maps/city/MapServer/" # layers in REST endpoints are identified by index number, not name layerid = layer_dict[infeature] query = "/query" urltoquery = baseurl + layerid + query r = requests.get(urltoquery, auth=(username, password), params=query_dict) # build json file name, saved to user desktop currentuser = os.getenv('username') ext = ".json" filenm = os.path.join(r"C:\Users", currentuser, r"Desktop\project" + infeature) + ext with open(filenm, "wb") as f: for line in r.iter_content(): f.write(line) try: arcpy.JSONToFeatures_conversion(filenm, outfeature) except Exception as e: err = "\nError importing json file\n{}".format(e) arcpy.AddError(err)
... View more
12-29-2017
05:03 AM
|
0
|
0
|
4862
|
POST
|
Hmm, this is more complicated than I thought. Micah, I don't know what they use. Rest endpoint has Sign in link, and Generate token link. I've just signed in. Even the manual approach got me kudos at work, but you know how that turns into "Cool. Now do more". That's ok, enjoy the challenge. Thanks all, I'll try these approaches out and report on results.
... View more
12-22-2017
12:49 PM
|
0
|
1
|
4862
|
POST
|
I have the following code that I want to use to access a secured arc rest api site and query a layer to return the data in json. I can do this manually by going to the rest site in a browser, signing in, and using the query page to return data. And the code below (mostly copied from the web) works on non secured sites, without username and password. But when I try to access the site using the password, I get the error: RuntimeError: RecordSetObject: Cannot open table for Load How can I do log in programmatically to get this data? Thanks. baseURL = "http://company/arcgis/rest/services/Maps/CityMapServer/6/query" where = "1=1" fields = "*" user = "user" password = "pass" query = "?where={}&outFields={}&returnGeometry=true&f=json&auth=({},{})".format(where, fields, user, password) fsURL = baseURL + query fs = arcpy.FeatureSet() fs.load(fsURL)
... View more
12-22-2017
08:37 AM
|
0
|
10
|
16207
|
POST
|
I have a script that adds layer files to a map and optionally saves it. If the map is open, I just reference the map like normal, i.e. mxd = arcpy.mapping.MapDocument("CURRENT"). I'd like to be able to check whether the map is open in the first place, so I can reference the map through a parameter if it isn't. What I've come up with so far is to use a try/except block to catch the runtime error generated if the mxd is not open, then set it to a default if so. Is there a way to check if the map is open or not? Thanks.
... View more
12-07-2017
04:31 AM
|
0
|
1
|
798
|
POST
|
I'm getting a runtime error when trying to geocode a table in a script. Geocoding works fine when done manually in ArcCatalog - right clicking the table and selecting Geocode addresses in the popup.But running it in Pyscripter, Idle or the Python window in ArcMap all give the error. I've also tried different machines. I've tried different variations on this, from just using the table name instead of a view to changing how the address fields are formatted. The only thing that changes is that if the address fields aren't in a list, the error becomes an application error - access violation - that just ends the program without ever hitting the exception. I've used the documentation as a reference. Any and all help appreciated, thanks. Code and error below: try:
print("In geocode_facilities...\n")
address_fields = [["Street Street"], ["City Fac_City"], ["Zip Fac_Zip"]]
cdc = arcpy.MakeTableView_management(childcare_table, "cdc_view")
arcpy.GeocodeAddresses_geocoding(cdc, geocoder, address_fields, geocoded_fc, "STATIC")
except RuntimeError as e:
msg = "Error geocoding table in geocode_facilities():\n\t {0}".format(traceback.format_exc())
traceback.print_exc()
error_list.append(msg + '\n')
""" Error is:
Traceback (most recent call last):
File "G:\Scripts\LARA_CDC_Download.py", line 248, in geocode_facilities
arcpy.GeocodeAddresses_geocoding(cdc, geocoder, address_fields, geocoded_fc, "STATIC")
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\geocoding.py", line 212, in GeocodeAddresses
raise e
RuntimeError: Object: Error in executing tool
"""
... View more
10-13-2016
10:48 AM
|
0
|
1
|
868
|
POST
|
Pretty much what the post title says. I have some python scripts which require background processing to be enabled, other disabled. I know this can be set in tool properties, but these are just stand alone scripts. Haven't been able to find any info one way or the other. Thanks.
... View more
09-07-2016
11:18 AM
|
1
|
8
|
7901
|
POST
|
Thanks again. One other odd thing is that even when manually geocoding by right clicking, I can't change the default resulting file name from Geocoding_Result. Whenever I enter something else I get an Error saving file message.
... View more
09-06-2016
12:00 PM
|
0
|
0
|
602
|
Title | Kudos | Posted |
---|---|---|
1 | 08-22-2019 07:41 AM | |
1 | 05-05-2014 04:30 AM | |
1 | 08-15-2018 06:23 AM | |
2 | 08-06-2018 07:31 AM | |
1 | 03-30-2012 08:38 AM |
Online Status |
Offline
|
Date Last Visited |
12-12-2021
01:00 PM
|