|
POST
|
Thanks, Yeah it took me a while to figure it. Perfect.
... View more
08-28-2018
07:10 AM
|
0
|
0
|
3677
|
|
POST
|
Thank you for the great help, Yes this what I want, I was confused about these 2 line of code quad_row = 1 + 28 * block_v and quad_row = 15 + 28 * block_v Thanks again every thing is clear now.
... View more
08-28-2018
06:55 AM
|
0
|
2
|
3677
|
|
POST
|
Thank you, Yes I have 49 Blocks now, that mean its 196 Rectangle in total. "Should the character change every 3 blocks?" No Each block consists of 4 columns and 8 rows (?) Yes For this new case I have only one Section A. Need the number to goes like this from lower left Row> A183-A196 ------- A15 - A28 A1 To A14 using same logic you used before for the three part- (A-13-1) The Problem is I have Many cases with different h_block, v_block no. I am trying to understand the script logic. Thanks
... View more
08-28-2018
05:33 AM
|
0
|
5
|
3677
|
|
POST
|
Thank you Xander, I am still did not get it, now my scenario is changed I am only have one section now, and no spacing x_start = 2523853.5 # lower left
y_start = 7124354.1 # lower left
rect_width = 10.0
rect_height = 5.0
num_blocks_h = 7
num_blocks_v = 7
num_rect_in_block_h = 4
num_rect_in_block_v = 8
spacing_h = 0.0
spacing_v = 0.0 and here is the complete code, but I have some logic errors, see the Red in the Results (Repeating row no) def main():
import arcpy
import os
# settings
fc_out = r'C:\HH\ce\cemeterypy.gdb\result05'
fld_lbl = r'RectangleID'
sr = arcpy.SpatialReference(2276) # NAD_1983_StatePlane_Texas_North_Central_FIPS_4202_Feet?
x_start = 2523853.5 # lower left
y_start = 7124354.1 # lower left
rect_width = 10.0
rect_height = 5.0
num_blocks_h = 7
num_blocks_v = 7
num_rect_in_block_h = 4
num_rect_in_block_v = 8
spacing_h = 0.0
spacing_v = 0.0
# create output featureclass
arcpy.env.overwriteOutput = True
fc_ws, fc_name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(fc_ws, fc_name, "POLYGON", None, None, None, sr)
# add field
arcpy.AddField_management(fc_out, fld_lbl, "TEXT", None, None, 10)
# insert cursor
flds = ("SHAPE@", fld_lbl)
cnt = 0
with arcpy.da.InsertCursor(fc_out, flds) as curs:
# loop through blocks
for block_h in range(num_blocks_h):
for block_v in range(num_blocks_v):
# loop through rectangles
for rect_h in range(num_rect_in_block_h):
for rect_v in range(num_rect_in_block_v):
x_min = x_start + block_h * spacing_h + block_h * num_rect_in_block_h * rect_width + rect_h * rect_width
y_min = y_start + block_v * spacing_v + block_v * num_rect_in_block_v * rect_height + rect_v * rect_height
x_max = x_min + rect_width
y_max = y_min + rect_height
rectangle = CreateRactangle(x_min, y_min, x_max, y_max, sr)
label = GetLabel(block_h, block_v, rect_h, rect_v)
cnt += 1
if cnt % 50 == 0:
print("Processing rectangle: {}".format(cnt))
curs.insertRow((rectangle, label, ))
print("Finished processing {} rectangles".format(cnt))
def CreateRactangle(x_min, y_min, x_max, y_max, sr):
coords = [[x_min, y_min], [x_min, y_max], [x_max, y_max],
[x_max, y_min], [x_min, y_min]]
return arcpy.Polygon(arcpy.Array([arcpy.Point(*coord) for coord in coords]), sr)
def GetLabel(block_h, block_v, rect_h, rect_v):
# 4 parameters necessary:
# - block_h = block number horizontally
# - block_v = block number vertically
# - rect_h = rectangle number horizontally
# - rect_v = rectangle number vertically
# determine if the rectangle number horizontally is even or uneven
even = rect_h % 2 == 0
# devide the block vertically in two halves
if rect_v < 4:
# lower 4 rectangle lines inside a block
if even:
# determine the 3rd part of the label
# values 0 + 1 to 3 + 1 -> (1 - 4)
part3 = rect_v + 1
else:
# values 0 + 5 to 3 + 5 -> (5 - 8)
part3 = rect_v + 5
# determine the quadrant of the block (in rows)
# for instance the second block (=1 when starting to count at 0) vertically
# will result in 1 + 12 * 1 = 13 (which is where the lower left starts
# see "A-13-1"
quad_row = 1 + 14 * block_v
# determine the quadrant of the block (in cols)
if rect_h <2:
# left part of block
quad_col = block_h * 2
else:
# right part of block
quad_col = 1 + block_h * 2
else:
# do the same for the upper 4 rectangle lines inside a block
if even:
part3 = rect_v - 3
else:
part3 = rect_v + 1
quad_row = 15 + 14 * block_v
if rect_h <2:
quad_col = block_h * 2
else:
# lower right
quad_col = 1 + block_h * 2
# part 2 of the label is the result of adding quad_row and quad_col
part2 = quad_row + quad_col
if block_h < 7:
# for first 3 blocks horizontally, assign an "A"
part1 = "A"
else:
# otherwise assign a "B" and correct part 2 of the label
part1 = "B"
part2 = part2 - 7
# construct the label combing the 3 parts
return "{}-{}-{}".format(part1, part2, part3)
if __name__ == '__main__':
main()
Result Thank you
... View more
08-27-2018
10:47 PM
|
0
|
7
|
3702
|
|
POST
|
I am playing around this script, I am not quite well understanding the second part (creating the label - starting from GetLabel function). If you could put some comments on this parts,
def GetLabel(block_h, block_v, rect_h, rect_v):
even = rect_h % 2 == 0
if rect_v < 4:
# lower
if even:
part3 = rect_v + 1
else:
part3 = rect_v + 5
quad_row = 1 + 12 * block_v
if rect_h <2:
quad_col = block_h * 2
else:
# lower right
quad_col = 1 + block_h * 2
else:
if even:
part3 = rect_v - 3
else:
part3 = rect_v + 1
quad_row = 7 + 12 * block_v
if rect_h <2:
quad_col = block_h * 2
else:
# lower right
quad_col = 1 + block_h * 2
part2 = quad_row + quad_col
if block_h < 3:
part1 = "C"
else:
part1 = "D"
part2 = part2 - 6
return "{}-{}-{}".format(part1, part2, part3)
I am trying to modify this part so the label goes straight through C only without D section and without the offset, Thank You
... View more
08-27-2018
02:26 PM
|
0
|
9
|
3702
|
|
POST
|
Hi, Just wonder how this Local Layer widget supports GeoJSON. I tried to add a local geojson file from my local HD with no luck, Please let me know if that is possible through your widget. Thanks
... View more
08-10-2018
06:28 AM
|
0
|
1
|
6875
|
|
POST
|
I can't figure out how to add geojson file (from a folder) with this widget nor a custom layer using the transformer, The Tips and tricks documentation is not clear about that, if you can explain in more details. Did the widget accept only ArcGIS Rest Services, and AGO. I also uploaded my json file to my live server(as a file), but still no luck.
... View more
07-06-2018
07:31 PM
|
1
|
0
|
753
|
|
POST
|
Thank you a ton, Yes, its working so far, I have to work on that to make it interact with other widget, like attributes, eSearch.. etc. now its just a static layer.
... View more
07-06-2018
07:37 AM
|
0
|
0
|
531
|
|
POST
|
Unfortionatley I could make it to work, every time trying to add json file from a directory of url, it look like screen shot below, what I am doing wrong?
... View more
07-06-2018
05:53 AM
|
0
|
2
|
3812
|
|
POST
|
Thank you Robert, I did that , I added the json to my my web server but still showing Red exclamation. Thank you again, will try again later and let you know
... View more
07-05-2018
01:38 PM
|
0
|
0
|
3812
|
|
POST
|
Yes you are right, but the issue is its not loading the geojson on map load, we have to do that annually every time the map started.
... View more
07-05-2018
10:01 AM
|
0
|
8
|
3812
|
|
POST
|
Assuming that I don't have ArcGIS Server or AGO, is there any approach to add local geojson file to the map, just like how Robert Scheitlin, GISP did it in this thread Is there any out of box widget or custom one, to add local geojson file to the map (on map load ), or even a direction on how to convert the code in this thread to widget. Thanks
... View more
07-05-2018
08:45 AM
|
1
|
10
|
5621
|
|
POST
|
Thank you for your response. fantastic, and more than I need
... View more
07-05-2018
07:49 AM
|
0
|
0
|
3611
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-19-2020 12:53 AM | |
| 1 | 04-06-2020 10:52 AM | |
| 2 | 11-13-2018 07:53 AM | |
| 1 | 09-13-2019 10:55 AM | |
| 1 | 03-07-2019 11:43 PM |
| Online Status |
Offline
|
| Date Last Visited |
05-04-2026
09:32 AM
|