|
POST
|
Move all the spare points to a new featureclass. It doesn't sound like a clean dataset to be building nodes from a cluster of points. You could use Spatial Statistics>Utilities>Collect Events tool to remove the duplicates and just keep one for the network. Maybe have a relate to a table so that you can have multiple attributes for the other points? Why do you need all the points in the same featureclass? Selecting one of many points to keep is a tricky problem not available in the standard tools, but you can make a tool to create a unique ID for a location using a Geohash. Or use ET Tools, a great set that fills in all sorts of little gaps in the Esri toolset. Once you have a unique location ID you can number the points within the group and offset them a little. Needs a bit of Python programming to extend the toolset for adventurous analysts like yourself.
... View more
06-10-2014
03:20 AM
|
0
|
0
|
963
|
|
POST
|
Duplicate points are not an error, but duplicate vertices are. However you can only have vertices in a polyline or polygon, so there is nothing wrong with your sample. To find coincident points you need another tool. It is not a useful thing to have any featureclass using play coordinates in the range 0 - 10 to test this sort of thing because of rounding errors during storage using integers and offsets. It is recommended that you always have a coordinate system defined and use real coordinates such as UTM with lots of figures if you are going to stress test Esri algorithms for bugs. There are lots of issues with the interpretation of valid geometry between systems that check geometry does not report. See FME for a more comprehensive testing tool. Something that is valid in Esri may not be allowed in OSGeo simple features. For example a vertex may be allowed to touch the edge of the polygon or not. Why not repair geometry instead of just checking it? The main issue that repair geometry handles is polygon vertex order is back to front in KML sourced polygons that need to be reversed to be Proper Polygons in ArcGIS.
... View more
06-10-2014
03:00 AM
|
0
|
0
|
1773
|
|
POST
|
Each time you upgrade ArcGIS a new folder is created in your login directory so you lose your old personal toolboxes until you move them to the new directory.
... View more
06-10-2014
02:38 AM
|
0
|
0
|
1224
|
|
POST
|
Run with ties unmatched first. Then set the score to match at 100 and open again with the Address Inspector. Select tied matches. Then you can go through the tied matches one by one and choose. One by one?? You can't have many! Just calculate how many per hour you can do. I assume you are batch matching. If not, perhaps try building a composite locator that combines combinations of tied addresses, non-tied addresses, scores and so on. It all seems a bit tedious to me for large numbers of addresses. Maybe you can edit the match field to help the locator decide between the pairs? I use various scrubbing scripts using Python tools to improve the source addresses. Use regular expressions, lookup tables and other information to complete the addresses before you run or rerun the locator. Maybe even select all status = 'U', turn off the shape field and export the match table to run a separate scrub and match. It might be useful to standardise addresses first. This splits them into components that are easier to scrub. For batch processing if you can't see why the matches are tied, turn on the option to return the scores in a field. Have a look at them to see what component could be improved. For example you might be able to fill in missing zip codes if you know the city, or split the data into geographic regions and turn on 'match in visible extent'.
... View more
06-10-2014
02:31 AM
|
0
|
0
|
1099
|
|
POST
|
Why can't you join the layers? It does seem a bit of a lost cause if you can't at least do that. However some joins may be very inefficient if there is no index and you do not have permission to build it. Copy the data so that you can, or extract the data to enable the comparision. Don't think 'loop through' if at all possible, use SQL type queries on whole tables for efficiency. If the data is small enough to fit into memory there are Python structures to make comparisons fast. For example you could use a cursor to read in the fields from each table into a list and a dictionary and run a set comparision to get a list of differences. If that is small compared to the total, then there is a huge benefit.
... View more
06-08-2014
01:50 PM
|
0
|
0
|
520
|
|
POST
|
Instead of drawing a graphic to use as a clip, use a tool to create a featureset which is created interactively just like a graphic when setting up parameters to run the tool. If you have hundreds of graphics that should have been features, there is a menu item to turn graphics to features. You can then select a real feature from a featureclass to use it as a clip. Just don't use graphics as features, they are really most suitable for illustrations of non GIS data in a layout.
... View more
06-08-2014
01:33 PM
|
0
|
0
|
611
|
|
POST
|
I was intending to explain the only obscure part of your question as best as I could guess from your description. Getting an interactive point using a standard ArcTool is easy with a custom tool that you would need to write. I assume you were intending to write a script for the tool yourself? I can only guess that you want a volume from the seabed to a water surface. Here is a sample tool, the script that reads the parameters, and images before and afterwards. You will have to create your own template point featureclass to use as a template to indicate that you want points collected, not polylines or polygons. #-------------------------------------------------------------------------------
# Name: VolumeCalculator.py
# Purpose: Calculate a volume under an arbitary rectangle
#
# Author: kimo
#
# Created: 05/06/2014
# Copyright: (c) kimo 2014
# Licence: Creative Commons 3.0 NZ
#-------------------------------------------------------------------------------
import arcpy
import math
fds = arcpy.GetParameter(0)
width = arcpy.GetParameter(1)
length = arcpy.GetParameter(2)
angle = arcpy.GetParameter(3)
raster = arcpy.GetParameter(4)
tin = arcpy.GetParameter(5)
# the fds is an in_memory featureclass, get the first point
with arcpy.da.SearchCursor(fds,["SHAPE@X","SHAPE@Y"]) as cur:
row = cur.next()
x = row[0]
y = row[1]
# feedback for demo
msg = "{} {} {} {} {} {} {}".format(x,y,width,length,angle,raster,tin)
arcpy.AddMessage(msg)
# calculate volume....
... View more
06-04-2014
03:02 PM
|
0
|
2
|
3329
|
|
POST
|
You need to add a Node layer that is now at ArcGIS a point layer with references added to each line to link the node number. This was built into ARC/INFO so it was really easy. Now you need a third party tool such as Renode Polylines to make this easy such as in ETGeotools. http://www.ian-ko.com/. Just adding points to the ends does not add a single point at the ends, you get two unrelated points. Sigh, this takes a lot of extra steps to cleanup. When you have properly related point-nodes and polylines you can select all the unsealed polylines and tag the nodes with an 'unsealed end' tag. Now you can select all sealed segments to see if both end nodes have an 'unsealed' tag. Each road segment will have a field FnodeID and TnodeID. The node points will have a NodeID. Segments that share a node will have the same id. At T junctions the logic is a bit more complex. You will have to tag those as 'unsealed' if all roads are unsealed connecting it. Another useful tag on the nodes is a valence (the count of connectors) to help identify these by running a frequency on the segment end IDs. All of these steps can be done with an SQL query or a join and calculate, don't step through each segment with a cursor!
... View more
06-03-2014
02:40 AM
|
0
|
0
|
615
|
|
POST
|
You can control the table of contents in ArcMap using arcpy.mapping module commands. So you would need to create a tool that toggled the layer and then add the tool to ModelBuilder. You need to build the tool with input and output parameters.
... View more
06-03-2014
01:47 AM
|
0
|
0
|
550
|
|
POST
|
You don't have to wait over the weekend to know that you have not approached the problem the best way. I have a rule of thumb called the "Cup of Coffee Rule". If an single process has not finished by the time I have finished my coffee, then I interrupt the process and find a better way. It must be something seriously wrong since computers are now so fast. Maybe a missing index, working across a network instead of local data, exceeding the size that can fit in memory. Just using a tool with inappropriate tolerances or settings can turn a simple process into something impossible. In this case I can see the problem at once - you are running geoprocessing tools inside a cursor! They are not designed that way, you are supposed to frame your problem to run a tool over the whole dataset in one pass. Never in a cursor. It is just too slow to restart a process and cleanup. Since the tools are not designed that way, it is likely that garbage collection is not being worked either so you will run out of memory long before you get any useful results. I have never run a tool inside a cursor, there is always a way of avoiding it. I know it is easy to visualise a problem by considering a feature and then applying the same thing a million times, but this is not the best way usually. Think of the way that SQL queries work. You specify what is to be done with a pair of tables and you let the database engine decide how to do it, you don't even have the luxury of a cursor in the SQL language. It would be nice if GIS tools had a similar command to SQL called Explain which shows how things are going to be solved. Instead you have to think it through yourself and recognise the patterns that will not work. You need to multiply the numbers of operations together by the expected time to see if it will finish before you retire. Any 40,000 updates should finish in a few seconds or minutes, to give you a feel for what can be achieved. I know this has not reworked the problem and supplied you with a neat alternative. While I am reviewing your code, I suggest that you don't use CalculateField in a script. It is better left for ModelBuilder. Since it is just wrapping a cursor around an expression, it would be better to just use an expression in the cursor. It is much easier to understand, can be debugged more easily and you can trap unexpected data and recover with if statements. It would also be much faster. If you are using shapefiles, consider using file geodatabases. Then the area is automatic, you don't have to calculate it.
... View more
06-03-2014
12:53 AM
|
0
|
0
|
2603
|
|
POST
|
You can do this with the standard toolbox using the featureset input type. This will capture one or more mouse clicks to draw an interactive graphic of whatever type template you have used for the featureset. It will also have fields that you can fill in the properties to be included in the new feature. In your example you would have a point feature and some properties, maybe filled with defaults. When you execute the tool you capture the input parameter as a geometry object to either convert to a featureclass or process further. In this case you would just get out the XY of the point and calculate the boundaries of a polygon to create a polygon geometry object for output. But maybe you would just create the polygon directly with a polygon template. http://resources.arcgis.com/en/help/main/10.1/index.html#//002w00000023000000 You could make a really slick interface that picked a coordinate using python AddIns, but that does not easily allow a form to input additional information like a featureset. Addins are much harder to debug.
... View more
06-02-2014
09:43 PM
|
0
|
0
|
3329
|
|
POST
|
At ArcGIS 10.2.1 there are new python modules included called XLRD and XLWT which are excellent modules for reading spreadsheets and extracting the data. It can handle multiple sheets and can pick out any cell or range of cells. Don't bother trying to use the new Excel to Table tool unless the data is already in a suitable format with valid field names etc. Here is an example of reading the 4th sheet that was not formatted for a database, no header field names and lots of comments all over the sheet. I needed three columns in the middle of the sheet. By the way watch for new uses of Sqlite with spatial extensions as Spatialite and the OSGEO recent standard http://www.opengeospatial.org/standards/geopackage #-------------------------------------------------------------------------------
# Name: loadXLS
# read Table 4 from 68 spreadsheets to get Unoccupied Dwellings
# Purpose: read Stats spreadsheets into a Sqlite database that cannot
# be read by FME, ArcGIS or anything other than Excel
# saves writing out to CSV first
# Author: kimo
#
# Created: 08/05/2014
# Copyright: (c) kimo 2014
# Licence: Creative Commons
#-------------------------------------------------------------------------------
import xlrd # installed with ArcGIS 10.2 by default
import sys,os
import re
import glob
import sqlite3
import arcpy # only needed for final message
pat = re.compile("^[0-9]{6}") # pattern of AU code in AU name in Column 0 ("A")
dType = {0:'Empty', 1:'Text', 2:'Number', 3:'Date', 4:'Boolean', 5:'Error', 6:'Blank'}
def extract_tla(filename):
'''extract Unoccupied Dwellings'''
workbook = xlrd.open_workbook(filename)
worksheet = workbook.sheet_by_name('Table 4')
num_rows = worksheet.nrows
num_cells = worksheet.ncols
rec = 0
for curr_row in range(num_rows):
curr_col = 0
cellAn = worksheet.cell_value(curr_row, curr_col)
cell_type0 = worksheet.cell_type(curr_row, curr_col)
if cell_type0 == 1 and pat.match(cellAn):
a = str(worksheet.cell_value(curr_row,curr_col))
val = [a[0:6],a[7:]]
for curr_col in range(1,4):
count = worksheet.cell_value(curr_row,curr_col)
if count == '-':
n = 0
else :
n = int(count)
val.append(n)
rec+=1
#print val
insert_ud_row(udTable,val)
# print "Records found",rec
# fields au2013,auname,ud2001,ud2006,ud2013
return rec
def create_ud_tab(conn,udTable):
# (re-)create a table
c = conn.cursor()
c.execute('''DROP TABLE IF EXISTS '''+ udTable)
c.execute('''CREATE TABLE '''+udTable+''' (
au text NOT NULL,
auname text ,
ud2001 integer,
ud2006 integer,
ud2013 integer )''')
conn.commit()
c.close()
return
def insert_ud_row(outTab,row):
'''insert a row
requires a sqlite database to be connected
and a cursor to be open
'''
try:
cmd = "INSERT INTO " + outTab + " VALUES (" + (",?"*(len(row)))[1:] + ")"
# implied transaction already opened
c.execute(cmd,row)
except Exception,msg:
print msg
print row
print cmd
conn.rollback()
conn.close()
sys.exit()
# -------------------------------------------------------------------------
if __name__ == '__main__':
try:
source_folder = sys.arg[1]
except:
source_folder = 'C:/data/census2013/source'
os.chdir(source_folder)
conn = sqlite3.connect('C:/data/census2013/dwelling.sqlite')
udTable = 'DwellingEmptyAU'
create_ud_tab(conn,udTable)
# Open a cursor and insert records from all the spreadsheets
c = conn.cursor()
print "sqlite database successfully opened"
trec = 0
lstXLS = glob.glob('*.xls')
for x in lstXLS:
rec = extract_tla(x)
trec+=rec
print rec,x
conn.commit()
c.close()
conn.close()
msg = '{} Total records inserted into {}'.format(trec,udTable)
print msg
arcpy.AddMessage(msg)
... View more
05-30-2014
02:35 AM
|
0
|
0
|
2133
|
|
POST
|
You need to run the script 'in process' from ArcMap. If you have the script attached to a tool, make sure that the option in the tool dialog option 'Always run in foreground' is ticked. Then run the tool from the Catalog window in ArcMap.
... View more
05-30-2014
02:18 AM
|
0
|
0
|
834
|
|
POST
|
The way that Esri suggests is to keep a template graphic element located off the layout page that has 90 degrees set. You clone an element and edit the text with arcpy.mapping functions on Layout Elements. Have a look at the help for Layout Elements. There is a sample script for exactly this case so I won't bother to duplicate it here. http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000040000000
... View more
05-30-2014
02:04 AM
|
0
|
0
|
533
|
|
POST
|
I suggest you do not use the CalculateField tool in a Python script. It is much better to use an UpdateCursor which is just as fast or faster because CalculateField wraps a cursor around the expression anyway. You can also handle unexpected input such as null values, put in conditional tests and generally make the process more readable. But answering your question, it looks like you have the exclamation marks around the whole expression, not just the field name, so I am very surprised that it works interactively at all. fieldName3 = "Azimuth"
expression2 = "180+math.atan2(( !Shape!.firstpoint.X - !Shape!.lastpoint.X ),( !Shape!.firstpoint.Y - !Shape!.lastpoint.Y ) ) * (180 / math.pi )"
arcpy.CalculateField_management(outFeatureClass, "Azimuth", expression2, "PYTHON")
... View more
05-02-2014
01:50 PM
|
0
|
0
|
1048
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 2 weeks ago | |
| 1 | 03-11-2023 03:54 PM | |
| 1 | 09-15-2024 10:32 PM | |
| 1 | 03-12-2026 01:10 AM | |
| 1 | 03-13-2026 08:30 PM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|