Create Multiple site address points from one

803
3
Jump to solution
10-16-2020 11:56 AM
JoeBorgione
MVP Emeritus

I have set of site address points that instead of a single house number, they contain a range of house numbers.  I would like to create a point in the same location for each of the house numbers in the range.  Here is the beginning of the python logic:

addrRange = '8909-8927' # the hyphenated string is in the HouseNumber field
begin = int(addrRange.split('-')[0]) 
end = int(addrRange.split('-')[1])
addresses = int((end - begin) / 2)
houseNumberList = [begin]

for i in range(addresses):
    begin +=2
    houseNumberList.append(begin)‍‍‍‍‍‍‍‍‍

Now I have a list of house numbers and the goal is to create a new point for each of list elements:

[8909, 8911, 8913, 8915, 8917, 8919, 8921, 8923, 8925, 8927]

Basically, where there was one point, (in this case) I want ten points stacked on top of each other.  Could be it's Friday, or could be I just can't wrap my head around the next step (that will involve an insert cursor) but I need another set of eyes on this.  Each new point attribute record will be a copy of the original but the value in the HouseNumber field will correspond with the list element.

Thanks in advance

That should just about do it....
0 Kudos
1 Solution

Accepted Solutions
RandyBurton
MVP Alum

Perhaps something like this, assuming a search cursor or some such loop contains your geometry, address range and attributes.  (You could add a small amount to your x,y coordinates as you do the loop, if you didn't want the points on top of each other.)

searchCursor = [['geo1', '8909-8927', 'attr1'],
                ['geo2', '8908-8926', 'attr2']]

# start an insert cursor here
# then continue with search cursor or other loop for address ranges
for row in searchCursor:
    begin = int(row[1].split('-')[0])
    end =  int(row[1].split('-')[1])+1 # 1 past address range
    for address in range(begin, end, 2): # step by 2
        print(row[0], address, row[2]) # this is your data to insert‍‍‍‍‍‍‍‍‍‍

''' results:
('geo1', 8909, 'attr1')
('geo1', 8911, 'attr1')
('geo1', 8913, 'attr1')
('geo1', 8915, 'attr1')
('geo1', 8917, 'attr1')
('geo1', 8919, 'attr1')
('geo1', 8921, 'attr1')
('geo1', 8923, 'attr1')
('geo1', 8925, 'attr1')
('geo1', 8927, 'attr1')
('geo2', 8908, 'attr2')
('geo2', 8910, 'attr2')
('geo2', 8912, 'attr2')
('geo2', 8914, 'attr2')
('geo2', 8916, 'attr2')
('geo2', 8918, 'attr2')
('geo2', 8920, 'attr2')
('geo2', 8922, 'attr2')
('geo2', 8924, 'attr2')
('geo2', 8926, 'attr2')
'''‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

3 Replies
RandyBurton
MVP Alum

Perhaps something like this, assuming a search cursor or some such loop contains your geometry, address range and attributes.  (You could add a small amount to your x,y coordinates as you do the loop, if you didn't want the points on top of each other.)

searchCursor = [['geo1', '8909-8927', 'attr1'],
                ['geo2', '8908-8926', 'attr2']]

# start an insert cursor here
# then continue with search cursor or other loop for address ranges
for row in searchCursor:
    begin = int(row[1].split('-')[0])
    end =  int(row[1].split('-')[1])+1 # 1 past address range
    for address in range(begin, end, 2): # step by 2
        print(row[0], address, row[2]) # this is your data to insert‍‍‍‍‍‍‍‍‍‍

''' results:
('geo1', 8909, 'attr1')
('geo1', 8911, 'attr1')
('geo1', 8913, 'attr1')
('geo1', 8915, 'attr1')
('geo1', 8917, 'attr1')
('geo1', 8919, 'attr1')
('geo1', 8921, 'attr1')
('geo1', 8923, 'attr1')
('geo1', 8925, 'attr1')
('geo1', 8927, 'attr1')
('geo2', 8908, 'attr2')
('geo2', 8910, 'attr2')
('geo2', 8912, 'attr2')
('geo2', 8914, 'attr2')
('geo2', 8916, 'attr2')
('geo2', 8918, 'attr2')
('geo2', 8920, 'attr2')
('geo2', 8922, 'attr2')
('geo2', 8924, 'attr2')
('geo2', 8926, 'attr2')
'''‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
JoeBorgione
MVP Emeritus

Thanks for your help Randy.  Between your suggestion and the insert cursor help I was able to get it to work

Here is my final script:

import arcpy

fc = r'N:\GIS\AddressDataManagement\Data\AppendIntoSitesMSD.gdb\RangeAddresses'

# use list comprehension to create a list
# of all the existing rows where the the 
# house number is in the form of a range for example 1110-1120

fields = ['Shape', 'PARCEL','ADDR_HN', 'ADDR_PD','ADDR_SN', 'ADDR_ST',
          'ADDR_SD','CITY', 'ZIP_CODE']
rowValues = [i for i in arcpy.da.SearchCursor(fc,fields)]


# the TestTarget feature class is created a-priori
# and has the fields shown the in the insertFields list


target = r'N:\GIS\AddressDataManagement\Data#\TestTarget'
insertFields = ['SHAPE@XY', 'Parcel','HouseNumber', 'PreDir', 'StreetName', 'SufType', 'SufDir','City', 'Zip']
cursor = arcpy.da.InsertCursor(target, insertFields)


# the fun begins: plow through the original rowValues list
# figure out what the range of addresses will include
# since I am creating a value for the house number
# I create a tuple that contains the info from the rowValues list
# as well as my new house numbers for each of the house numbers
# in the range.  And then append all the tuples to a list called rv

rv = []
for i in range(len(rowValues)):
    
    begin = int(rowValues[i][2].split('-')[0])
    end = int(rowValues[i][2].split('-')[1])+2
    for hn in range(begin,end,2):
        theTuple = (rowValues[i][0], rowValues[i][1], hn,rowValues[i][3], rowValues[i][4], 
        rowValues[i][5], rowValues[i][6], rowValues[i][7], rowValues[i][8])
        #print(theTuple)
        rv.append(theTuple)
        
# plow throught rv list of tuples and insert them...

for row in rv:
    cursor.insertRow(row)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This creates a new point for each of the house numbers in the given range, and stacks them on top of each other.  For example, the original house number for this location on Patricia Dr was 2836-2838; once the processing is done, the  rv list of tuples looks like this:

[((1476733.9007378817, 7427506.225450307), '14292050050000', 2836, 'S', 'PATRICIA', 'DR', '', 'MAGNA', '84044')
 ((1476733.9007378817, 7427506.225450307), '14292050050000', 2838, 'S', 'PATRICIA', 'DR', '', 'MAGNA', '84044')
...]

There were 101 original addresses as a range and I ended up with 450+- individual address points...

That should just about do it....
0 Kudos
JamesBushOpelika
New Contributor III

Hello!

I want to develop a similar process, I am a bit green with python. I am just looking for a more efficient solution to add multiple address points. For instance, when a new subdivision comes along I receive the addressing and need to create a point with attributes. For a single street, the only fields that change are the house number and a hyperlink. The x,y changes as well but I can recalculate them when the points are placed. I just want a way to create multiple points at once in arcmap, If I have to move them manually once created that is fine. Any idea on a script or tool to do this. attached is an example of my attributes. Thanks!AddressSample.JPG

James Bush
jabush@opelika-al.gov
0 Kudos