|
POST
|
Are the Data Categories restricted to a certain data type when using the Tag Query? I've added the tag Transportation to a few feature services in AGOL. I then added the same tag here in the Tag Query box. But, after clicking on this Data Category link in the website for testing I only get one result. I was expecting all the feature services to be there. I'm not sure what's going on.
... View more
02-28-2018
01:21 PM
|
0
|
1
|
1212
|
|
POST
|
I have the same problem, basically. I gave a few feature services the same tag in AGOL. Then in our Open Data Editor, in the Tag Query box, I put the same tag. When viewing the website I only see one result when there should be a few? I made sure the tags were spelled correctly and the data is set to view publicly. Do the Data Categories in Open Data only allow you to tag certain data types?
... View more
02-28-2018
12:36 PM
|
0
|
1
|
2272
|
|
POST
|
Thanks everybody. While Matthew's renaming link was pretty much what I was looking for I decided to go with Blake's version as it was right here and works great.
... View more
02-08-2018
06:52 AM
|
0
|
0
|
6285
|
|
POST
|
Matthew, EDIT: You answered my question, and that worked to name it correctly, but I still have a problem. I wasn't very clear but I actually want a script to put the date on existing zipfiles, this one being one of them in a folder full of them. I'm not sure if the write method is even what I should be doing.
... View more
02-07-2018
01:38 PM
|
0
|
1
|
6285
|
|
POST
|
Using PythonWin 2.7.10, I would like to append a date to a bunch of zipfiles in a folder. I've been using the time module which prints the current month, day and year. But, I'm not sure how to append this date to the end of my zipfiles' file name. In this case I've been running tests on the WillCounty_PLSS.zip file, which contains a shapefile. This script seems to work, but it creates an odd looking file with no content: import time
import arcpy
from arcpy import env
ws = arcpy.env.workspace = r'\\gisfile\GISstaff\Jared'
current_time = time.strftime("%m%d%Y")
output_name = "WillCounty_PLSS.zip" + current_time
output_file = open(ws + output_name, "w")
print current_time Here's how the file was named: JaredWillCounty_PLSS.zip02072018 EDIT: What do I need to do to have the look like this: WillCounty_PLSS_02072018.zip?
... View more
02-07-2018
12:59 PM
|
0
|
7
|
6750
|
|
POST
|
Thanks both Dan and Randy. That was the solution. Interestingly, what you have there works to order the fields in a descending order. On the other hand, the only way I got them to order in ascending order was not to have anything after ...ContestTitle: for rows in arcpy.da.SearchCursor(intable, field, sql_clause=(None, "ORDER BY ContestTitle")): I tried "ORDER BY ContestTitle ASCE" and it threw an errror.
... View more
01-31-2018
11:50 AM
|
0
|
1
|
8187
|
|
POST
|
Using arcpy.da.SearchCursor, how do you sort data in either ascending or descending order? I noticed the old arcpy.SearchCursor had sort_fields. arcpy.SearchCursor(dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields}) I have a script that uses arcpy.da.SearchCursor to create a list of table fields. The "D" in the function of line 8 is meant to put it in descending order, but it does not. env.workspace = r'\\gisfile\GISstaff\Jared\ModelBuilder\TEST folder\TESTGDB.gdb'
#variables
intable = "ElectionResults_Nov2016"
tbList = [] #create list
#use cursor to get all unique values in field, and list them in ascending order
for row in arcpy.da.SearchCursor(intable, "ContestTitle", "D"):
if row[0] not in tbList:
tbList.append(row[0]) EDIT: I've also been looking into sorted. It's a matter of placing it in the cursor, though. sorted()
... View more
01-31-2018
08:02 AM
|
0
|
4
|
11398
|
|
POST
|
Randy, It works pretty flawlessly, thanks! Could you briefly explain how the dictionary works in this script? tbList = []
... View more
01-29-2018
07:39 AM
|
0
|
1
|
2905
|
|
POST
|
Randy, Thanks for the help. All options are great. I went with the last one. I copied the script verbatim and it wrote new tables successfully except for one table, Results31. It's hung up. I did a few things to troubleshoot this: closed everything, used the 'ElectionResults_Nov2016' file in a different workspace, made sure the 'STATES ATTORNEY' record was even there... Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "\\gisfile\GISstaff\Jared\Python Scripts\Test2.py", line 22, in <module>
arcpy.TableSelect_analysis(intable, v, where_clause)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\analysis.py", line 145, in TableSelect
raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used. [ElectionResults_Nov2016]
An invalid SQL statement was used. [SELECT * FROM ElectionResults_Nov2016 WHERE ContestTitle = 'STATE'S ATTORNEY ']
The table was not found. [Results31]
Failed to execute (TableSelect). **EDIT: the 'STATE'S ATTORNEY' record is the only one with an apostrophe. So, I'm guessing this may be a format issue. I'm attempting to use the substitution function to get rid of it. import re
re.sub() Also, instead of naming the new tables 'Results' how would you give them the table record's name?
... View more
01-25-2018
12:22 PM
|
0
|
4
|
2905
|
|
POST
|
TableSelect_analysis(in_table, out_table, {where_clause}) "Selects table records matching a Structured Query Language (SQL) expression and writes them to an output table." Using this function I have this simple script: import arcpy
from arcpy import env
env.workspace = r'\\gisfile\GISstaff\Jared\ModelBuilder\JaredTest.gdb'
#variables
intable = r"\\gisfile\GISstaff\Jared\ModelBuilder\JaredTest.gdb\ElectionResults_Nov2016"
outtable = r"\\gisfile\GISstaff\Jared\ModelBuilder\JaredTest.gdb\Results3"
where_clause = "ContestTitle = 'BALLOTS CAST - TOTAL'"
arcpy.TableSelect_analysis(intable, outtable, where_clause) It selects all records named 'BALLOTS CAST - TOTAL' from the 'ContestTitle' column of my 'ElectionResults_Nov2016' table and writes them in the newly created 'Results3' table. 'BALLOTS CAST - TOTAL' is only one of 58 separate table record names. How can I write all 58 to their own tables? Thanks for any help.
... View more
01-19-2018
11:50 AM
|
0
|
7
|
3181
|
|
POST
|
It's a bit late for Kathleen's question, but for future reference you can clip to layers in the data frame. For example, I'm always dealing with street labels hanging over the edges of a county boundary. One of two ways I found to clean these up are converting them to annotation in the map (as mentioned above), but this is way too time consuming with so many features. The other way is to 'clip to shape'. You can do this by double clicking the data frame you're working with --> Data Frame tab --> Clip to Shape --> and then there are a few options to clip to. I clipped to a polygon that doesn't cover anything within the county, only outside it-- Surrounding Counties.
... View more
01-08-2018
08:15 AM
|
2
|
1
|
5162
|
|
POST
|
Is there still no transparency setting? I'm having trouble finding it if there is.
... View more
01-05-2018
11:09 AM
|
0
|
0
|
1940
|
|
POST
|
Shaun, Thanks for the help. I put the same question to Sack Exchange and was answered by at least one alternative to BeautifulSoup: python - remove BeautifulSoup tags from Text file - Stack Overflow This uses the w3lib library and it seems to have done the trick. For the time being, I'm going with this: import arcpy
import arcpy_metadata as md
import w3lib.html
from w3lib.html import remove_tags
ws = r'Database Connections\ims to Plainfield.sde\gisedit.DBO.Tax_Map_LY\gisedit.DBO.Tax_Map_Parcels_LY'
metadata = md.MetadataEditor(ws)
path = r'\\gisfile\GISstaff\Jared\Python Scripts\Test\Parcels'
def meta2txt():
abstract = metadata.abstract
if abstract:
new_abstract = remove_tags(abstract)
print('Description:\n{}\n'.format(new_abstract))
else:
print('Description: \nThere is no description.\n')
meta2txt()
... View more
12-27-2017
01:05 PM
|
0
|
0
|
7059
|
|
POST
|
I have a script that uses a Python package called arcpy_metdata. It basically allows you to get at ArcGIS metadata. The script is set up to write the metadata to a text file and runs without errors, but unfortunately HTML code used to format the Description and Limitation items also gets written. It interferes with the readability of the textfile. I contacted the author of the package and he suggested BeautifulSoup, which leads to my question. I have this so far, but am at a loss at how to implement it: from bs4 import BeautifulSoup
cleantext = BeautifulSoup(raw_html).text And here is my Metadata2Txt script: import arcpy
import arcpy_metadata as md
import re
ws = r'Database Connections\ims to Plainfield.sde\gisedit.DBO.Tax_Map_LY\gisedit.DBO.Tax_Map_Parcels_LY'
metadata = md.MetadataEditor(ws)
path = r'\\gisfile\GISstaff\Jared\Python Scripts\Test\Parcels'
##cleantext = BeautifulSoup(raw_html).text
def meta2txt():
title = metadata.title
tags = metadata.tags
purpose = metadata.purpose
abstract = metadata.abstract
credits = metadata.credits
citation = metadata.citation
limitation = metadata.limitation
extent_description = metadata.extent_description
desc = arcpy.Describe(ws)
sr = desc.spatialReference
tf = open(path + " " + "{}".format("Metadata.txt"), "w")
tf.write("Metadata Content:" + "\n")
tf.write("----------------------------------------------" + "\n")
if title:
print('Title:\n{}\n'.format(title))
tf.write('Title:\n{}\n'.format(title) + '\n')
else:
print('Title: \nThere is no title.\n')
tf.write('Title: \nThere is no title.\n' + '\n')
if tags:
print('Tags:\n{}\n'.format(tags))
tf.write('Tags:\n{}\n'.format(tags) + '\n')
else:
print("Tags: \nThere are no tags.\n")
tf.write('Tags: \nThere are no tags.\n' + '\n')
if purpose:
print('Summary:\n{}\n'.format(purpose))
tf.write('Summary:\n{}\n'.format(purpose) + '\n')
else:
print('Summary: \nThere is no summary.\n' + '\n')
tf.write('Summary: \nThere is no summary.\n' + '\n')
if abstract:
print('Description:\n{}\n'.format(abstract))
tf.write('Description:\n{}\n'.format(abstract) + '\n')
else:
print('Description: \nThere is no description.\n')
tf.write('Description: \nThere is no description.\n' + '\n')
if credits:
print('Credits:\n{}\n'.format(credits))
tf.write('Credits:\n{}\n'.format(credits) + '\n')
else:
print('Credits: \nThere are no credits.\n')
tf.write('Credits: \nThere are no credits.\n' + '\n')
if citation:
print('Citation:\n{}\n'.format(citation))
tf.write('Citation:\n{}\n'.format(citation) + '\n')
else:
print('Citation: \nThere is no citation.\n')
tf.write('Citation: \nThere is no citation.\n' + '\n')
if limitation:
print('Limitation:\n{}\n'.format(limitation))
tf.write('Limitation:\n{}\n'.format(limitation) + '\n')
else:
print('Limitation: \nThere is no limitation.\n')
tf.write('Limitation: \nThere is no limitation.\n' + '\n')
if extent_description:
print('Extent:\n{}\n'.format(extent_description))
tf.write('Extent:\n{}\n'.format(extent_description) + '\n')
else:
print('Extent: \nThere is no extent.\n')
tf.write('Extent: \nThere is no extent.\n' + '\n')
if sr:
print('Spatial Reference:\n{}\n'.format(sr.name))
tf.write('Spatial Reference:\n{}\n'.format(sr.name) + '\n')
else:
print('Spatial Reference: \nThere is no spatial reference.\n')
tf.write('Extent: \nThere is no spatial reference.\n' + '\n')
meta2txt() Here's how Description item of this particular feature class looks in the textfile after running the script: Description:
<DIV STYLE="text-align:Left;"><DIV><DIV><P><SPAN>The tax map parcels layer is published
every year normally during the spring through the Will County Clerk Tax Extension. This
layer contains various parcels within Will County. The tax map parcels entered is only
digitized based upon plats and recorded documents received by the Tax Extension within
the Will County Clerk Office. </SPAN></P></DIV></DIV></DIV>
... View more
12-22-2017
12:08 PM
|
0
|
2
|
25830
|
|
POST
|
Thanks Dan. Using if... is not None it printed fine. But, when there is no text and it should jump to the else statement, it doesn't. Using this feature class with the Summary (purpose) missing it never runs the else statement: import arcpy
import arcpy_metadata as md
metadata = md.MetadataEditor(r'\\gisfile\GISstaff\Jared\Attractions.gdb\Metra')
def meta2txt():
title = metadata.title
tags = metadata.tags
purpose = metadata.purpose
abstract = metadata.abstract
if title is not None:
print('Title:\n{}\n'.format(title))
else:
print('Title: \nThere is no title.\n')
if tags is not None:
print('Tags:\n{}\n'.format(tags))
else:
print("Tags: \nThere are no tags.\n")
if purpose is not None:
print('Summary:\n{}\n'.format(purpose))
else:
print('Summary: \nThere is no summary.\n')
if abstract is not None:
print('Description:\n{}\n'.format(abstract))
else:
print('Description: \nThere is no description.\n')
meta2txt()
... View more
12-08-2017
08:03 AM
|
0
|
1
|
1363
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 9 hours ago | |
| 1 | 2 weeks ago | |
| 1 | 07-24-2025 01:27 PM | |
| 1 | 11-13-2025 08:22 AM | |
| 1 | 11-12-2025 08:37 AM |
| Online Status |
Online
|
| Date Last Visited |
10 hours ago
|