POST
|
I'm having the same issue - I used the in function, and the script will run (it takes forever - I'm running it in arcpro using a notebook - i don't know why it's suddenly taking 10-15 minutes to run the lines below) - so, it completes running, but no text is actually changed in the layouts. I even tried printing the results - again no dice, even though printing the results claims replacement has occurred, when i go to the layout, no replacement has occurred. oldtext = "Intermountain Region Geographic Resources Division*"
newtext = "Park_Name"
#allow search of all layouts in this Current Project, allowing the code to overwrite
#NOTE: Replace pathway in first line of this block as needed, or specify "CURRENT" if you are in the project
aprx = arcpy.mp.ArcGISProject(r"O:\Professional Services\GIS Information\GIS\Documentation\Pro_Templates_2020\Pro_Templates_2020.aprx")
for lyt in aprx.listLayouts():
for elm in lyt.listElements("TEXT_ELEMENT"):
if oldtext in elm.text:
elm.text = newtext
aprx.save()
del aprx
#THEN I TRIED IT FOR ONE LAYOUT AMONG THE LIST OF LAYOUTS
#TESTING CELL FOR ONE LAYOUT
oldtext = "Intermountain Region"
newtext = "Park_Name"
aprx = arcpy.mp.ArcGISProject(r"O:\Professional Services\GIS Information\GIS\Documentation\Pro_Templates_2020\Pro_Templates_2020.aprx")
lyt_1 = aprx.listLayouts()[0]
for elm in lyt_1.listElements("TEXT_ELEMENT"):
print (elm.name + ":" + elm.text)
if oldtext in elm.text:
elm.text = newtext
print (elm.text)
aprx.save()
del aprx
... View more
08-03-2020
10:39 AM
|
0
|
1
|
1760
|
POST
|
I think this is a separate issue from the ones I've found open regarding layouts - but apologies if this query already exists. I am looking to batch edit via Python a set of pagx files - but I'm not finding any samples or instructions on this. For example, I'd like to point to a folder, and add a certain north arrow to all the .pagx template files in that folder. Is this kind of workflow documented somewhere? I found a good page on looping through elements in an mxd - i.e. arcpy.mapping days - arcpy - Creating Loop to replace text in page layout in multiple MXDs instead of one MXD at a time? - Geographic Informa… However, I am now trying to instead loop through a set of pagx files - or is the best method to simply open up all those pagx files into an aprx file and then batch edit that way?
... View more
07-31-2020
12:22 PM
|
0
|
0
|
492
|
POST
|
#DC Road Data
##"https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Transportation_WebMercator/MapServer/154/query?outFields=*&where=1%3D1"
#gathering a list of field names into a comma separated list is key to copying over the feature service layer into a local geodatabase so that it can be utilized in the Clip analysis
from arcgis.features import FeatureLayer
#identify the boundary layer you will use to query the data
arcpy.env.workspace = r"O:\Professional Services\GIS Information\GIS\Boundary\NAMA_Boundary.gdb" #enter gdb where your park boundary is located
boundary = "NAMA_Boundary_ply"
# Describe the projection of the feature service so that your extents of the boundary layer will be in the appropriate spatial reference
desc = arcpy.Describe("https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Transportation_WebMercator/MapServer/154")
boundaryproj1 = r"O:\Professional Services\GIS Information\GIS\Boundary\NAMA_Boundary.gdb\boundary_proj_1"
arcpy.Project_management(boundary,boundaryproj1, desc.spatialReference)
#query parameters for all rows
base= "https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Transportation_WebMercator/MapServer/154"
where = '0=0'
token = ''
outPath = r"O:\Professional Services\GIS Information\GIS\Flora\2020_Python_TreeRisk_Assessment\2020_Python_TreeRisk_Assessment.gdb"
fields = "*"
##find extent of your parks boundaries and assign it to variable "boundaryext"
descenv = arcpy.Describe(boundaryproj1)
descenvext = descenv.extent
boundaryext = ('{},{},{},{}'.format(descenvext.XMin, descenvext.YMin, descenvext.XMax, descenvext.YMax))
#################################start of code to try to get >2000 records
# Get record extract limit
from urllib.request import urlopen
base= "https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Transportation_WebMercator/MapServer/154"
urlstring = base + "?f=json"
j = urllib.request.urlopen(urlstring)
js = json.load(j)
maxrc = int(js["maxRecordCount"])
print ("Record extract limit: %s" % maxrc)
outdata = r"O:\Professional Services\GIS Information\GIS\Flora\2020_Python_TreeRisk_Assessment\2020_Python_TreeRisk_Assessment.gdb\DC_Roads_all"
# Get object ids of features
where = "1=1"
urlstring = base + "/query?where={}&returnIdsOnly=true&f=json".format(where)
j = urllib.request.urlopen(urlstring)
js = json.load(j)
idfield = js["objectIdFieldName"]
idlist = js["objectIds"]
idlist.sort()
numrec = len(idlist)
print ("Number of target records: %s" % numrec)
# Gather features
print ("Gathering records...")
fs = dict()
for i in range(0, numrec, maxrc):
torec = i + (maxrc - 1)
if torec > numrec:
torec = numrec - 1
fromid = idlist[i]
toid = idlist[torec]
where = "{} >= {} and {} <= {}".format(idfield, fromid, idfield, toid)
print (" {}".format(where))
query = "/query?where={}&outFields={}&returnGeometry=true&f=json&token={}&geometry={}&geometryType=esriGeometryEnvelope&returnExceededLimitFeatures=false".format(where, fields, token, boundaryext)
urlstring = base + query
fs[i] = arcpy.FeatureSet()
fs[i].load(urlstring)
# Save features
print ("Saving features...")
fslist = []
for key,value in fs.items():
fslist.append(value)
arcpy.Merge_management(fslist, outdata)
print ("Done!")
#################################end
#create local copy of traffic layer and clip by the boundary layer
arcpy.env.workspace =r"O:\Professional Services\GIS Information\GIS\Flora\2020_Python_TreeRisk_Assessment\2020_Python_TreeRisk_Assessment.gdb"
where = '1=1'
boundaryext = "393932.62135367095,131367.2651843205,400957.7405239567,139578.9519640468"
query = "/query?where={}&outFields={}&returnGeometry=true&f=json&token={}&geometry={}&geometryType=esriGeometryEnvelope&returnExceededLimitFeatures=false".format(where, fields, token, boundaryext)
fsURL = base + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
outputName = 'DCRoads_extent'
outputPath = os.path.join(outPath, outputName)
arcpy.CopyFeatures_management(fs, outputPath)
... View more
07-15-2020
07:25 AM
|
0
|
0
|
536
|
POST
|
I have spent a full day messing around with this to try to create a tool for planning purposes. I am continuing to get errors on my layers "unsupported elevation setting" even though both are set to on ground, which is supported when I looked into error 00236 fixes. Also, it is apparently impossible to overwrite a 3D scene, so the number of times I've retyped metadata to the point where i gave up is mind numbing. If anyone has best practices workflow on how to get 3D simple shapes into a web app, please advice. I also tried a work around by publishing 3D from 2D as a weblayer, which didn't work. I can't share a weblayer from pro arc scene, so I'm not really clear on whether to bother trying to utilize 3D shapefiles from arcmap pro in an online environment - or if I should be publishing 2D with Z values and then using something online to build those up into basic shapes.
... View more
02-08-2019
12:45 PM
|
1
|
3
|
690
|
Title | Kudos | Posted |
---|---|---|
1 | 02-08-2019 12:45 PM |