|
POST
|
Thanks, I missed that one too. The formatting ended up getting pretty messed up btw Notepad ++ and Visual Studio and I was terrible about fixing it. I do have a lot of work to do as far as understanding loops and multiple cursors (and probably everything else). I'll check out Richard's posts. Thanks!
... View more
02-14-2017
07:58 AM
|
0
|
0
|
4187
|
|
POST
|
I am trying to create and update a field with a count of line features (tLayer) within a distance of point features (sLayer). I am attempting to use a combination of AddField_management, arcpy.da.SearchCursor, SelectLayerByLocation_management, arcpy.GetCount_management, and arcpy.da.UpdateCursor. The code I have for this is currently updating all records for the Line_Count field with the count of the point features (i.e. 2) for only the (second?) record. Though, a print statement following the GetCount line will return the line count for all of the point features (with a few unessential iterations). What do I need to do to appropriately update the Line_Count field for all of the records? Also, this process will be applied to a large dataset and will be extended to include 'where clauses'; are there any suggestions as to how to make this as efficient as possible. Any tips or suggestions would be helpful. Thanks in advance! Tess Updated Line_count Field (inaccurately recording a count of '2' for each record) : actual line count values for records as returned by print statement: import arcpy
from arcpy import env
arcpy.env.OverwriteOutput = True
defaultGdbPath = 'C:\Topo_Check_Tess_V5.gdb'
sLayer='C:\Topo_Check_Tess_V5.gdb\Stations'
tLayer='C:\Topo_Check_Tess_V5.gdb\Lines'
#ppLayer='C:\Topo_Check_Tess_V5.gdb\Plants'
arcpy.AddField_management(sLayer, "Line_Count", "SHORT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
TLineCountField = "Line_Count"
arcpy.MakeFeatureLayer_management(tLayer, "tLayer_lyr")
with arcpy.da.UpdateCursor (sLayer, TLineCountField) as LineCountList:
for s_row in LineCountList:
with arcpy.da.SearchCursor(sLayer,["OBJECTID", "SHAPE@"]) as s_list:
for station in s_list:
arcpy.SelectLayerByLocation_management("tLayer_lyr", 'WITHIN_A_DISTANCE', station[1],.000002, "NEW_SELECTION")
result=int(arcpy.GetCount_management("tLayer_lyr").getOutput(0))
print result
LineCountList.updateRow(s_row)
del station
del s_row
print "Done"
... View more
02-13-2017
06:22 PM
|
0
|
11
|
6896
|
|
POST
|
I was looking to get the sum of the number of particular fields in a row that had a value greater than zero (to find how many of these unique attributes each feature had, e.g. ). I think Randy hit on exactly what I was looking for. Thanks a bunch!
... View more
01-31-2017
10:22 AM
|
0
|
0
|
3737
|
|
POST
|
Thank you so much. This is exactly what I was looking for! Works great!
... View more
01-30-2017
03:50 PM
|
0
|
0
|
3737
|
|
POST
|
Nope, I meant the count of fields per row (per feature) where designated fields satisfy a query. Here I am looking for the the count of fields (this would only pertain to 5 of the 40 fields in the feature class) which have a value greater than zero. I would also then like to write the count (sum) of the number of fields that satisfy this query into a new field, so this new field would have a count of 0 (or NULL) or an integer from 1 to 5. Does this help? I apologize for the lack of clarity. Thanks for the help! I would also like to eventually integrate this into a Python script (eventually).
... View more
01-27-2017
03:34 PM
|
0
|
2
|
3737
|
|
POST
|
I am wanting to calculate the count of fields in a row where designated fields in a feature class attribute table satisfy a query (in this case, where the value is greater than 0) and then write the count (sum) of the number of fields that satisfy this query into a new field. This seems simple, but I am having a hard time wrapping my head around how to do this using SQL or Python. Any suggestions or advice would be much appreciated. Thanks in advance!
... View more
01-27-2017
02:50 PM
|
0
|
8
|
6369
|
|
POST
|
Does AppStudio for ArcGIS integrate well with the Portal for ArcGIS server extension?
... View more
06-15-2016
12:50 PM
|
1
|
4
|
4409
|
|
POST
|
Thanks for the input! My scripting options might be limited where I am using CE basic. Is there much Python integration I can do with this version, or would I need to look into upgrading CE? I will look into using feature services in the web scene. Might be my best bet at this point... Thanks again!
... View more
02-08-2016
07:59 AM
|
0
|
3
|
1269
|
|
POST
|
Is there a good way to automatically refresh the source data used in a web scene (i.e. space occupancy data)?The data feeding the layer is currently being updated (same fields and geometry) on a nightly basis after moves and space transfers have been processed. I would like to have this automated if possible without having to continually manually update the web scene by updating the layer(s) in CityEngine and re-exporting the scene. I am using CityEngine Basic 2015.2. Thanks, Tess
... View more
01-29-2016
02:01 PM
|
0
|
6
|
3095
|
|
POST
|
I am having issues aligning floor plans (.gdb) with a buildings .obj. The scene, and all layers, is in NAD 83 UTM Zone 12N. All layers are also clipped to the same polygon extent. If I load these exact layers (multipatch vs. obj for buildings) in ArcScene everything snaps together perfectly. Any suggestions on how I can fix this without manual alignment? Thanks!
... View more
01-12-2016
08:22 AM
|
0
|
0
|
2554
|
|
POST
|
Never mind. That was dumb of me. I replaced 'else: NIL' to 'else: AddOutline' where needed. It's all working fine now. Thanks again for all of your help! Tess
... View more
11-10-2015
07:24 AM
|
0
|
0
|
216
|
|
POST
|
I have combined the stairs rule with a floor plan rule in hopes of being able to use the 'floor plan' portion except in the case where the room type is specified as a stairwell in the attributes. The rule works for either the stairs or the floor plan, but I cannot get both to generate at once. CityEngine has automatically assumed two start rules for the rule file (AddOutline and StairMaster). AddOutline is associated with coloring the floors and generating walls and StairMaster (surprise surprise) is for the stairs. When AddOutline is specified as the start rule, the areas where RM_TYPE=STAIR are left empty. When StairMaster is used as the start rule, the stairs are generated but nothing else. How can I get the floor plan and stair shapes to generate simultaneously? Thanks again for all of your help! Tess Here is the rule I have so far: version "2015.1" #attr Fill_Color = "#FFF80" attr Outline_Color = "#000000" @Range(0,1) attr Transparency = 0.1 attr BorderThickness = 0.2 attr Extrude_Height = 1 attr DV_LTR = "" # This will connect to your object attribute from the GDB. AddOutline --> offset( -BorderThickness) comp(f){border: BorderColor | inside: FillColor} BorderColor --> color(Outline_Color) set(material.opacity, 1-Transparency) extrude( Extrude_Height) FillColor --> color(getColorFromOrg(DV_LTR)) # This calls the function below using attribute. set(material.opacity, 1-Transparency) # Expand this function using orgs, with colors in "hex color" format: getColorFromOrg(DV_LTR)= case DV_LTR == "A" : "#baff1e" case DV_LTR == "B" : "#0b5394" case DV_LTR == "C" : "#0000ff" case DV_LTR == "D" : "#c62104" case DV_LTR == "E" : "#ddf1ff" else: "#000000" attr RM_TYPE = "" attr StairColor="#8b8682" attr StairTransparency= 0.3 attr LandingColor="#8b8682" attr LandingTransparency= 0.3 attr landingWidth = 1.2 attr stairDepth = 0.3 attr landingSlabThickness = 0.2 attr stairThickness = landingSlabThickness @Range("CW","CCW") attr TransitionDirection = "CW" attr TransitionHeight = uFeet(13) const transitionHeight = meters(TransitionHeight) attr TransitionOrientation = 0 # Using North=0, CW compass, East=90 @Group("Units",6) @Order(1) @Range("Feet","Meters") attr units = "Feet" unitScale = case units == "Feet": 3.28084 else: 1 const halfFloorHeight = transitionHeight / 2 StairMaster --> case RM_TYPE == "STAIR": # Make flat and aligned to world Y axis. alignScopeToAxes(y) s('1,0,'1) # Remove extra vertices. cleanupGeometry(all,0.5) # Get the inner rectangle, since original shapes might be out of square. innerRect # Align X axis on longer side. # XX Will need to add rotation code. PutScopeXGoingLongways else: NIL PutScopeXGoingLongways --> case RM_TYPE == "STAIR": case scope.sz > scope.sx: rotateScope(0,90,0) OrientationCheck else: OrientationCheck else: NIL OrientationCheck --> case RM_TYPE == "STAIR": # Tilt up end and check which side the landing is oriented, based on the shape. rotate(rel,scope,0,0,90) set(InitialLandingSide, compassDirection) #print("compassDirection"+compassDirection) #print("TransitionOrientation "+TransitionOrientation) rotate(rel,scope,0,0,-90) FlipDirectionMaybe else: NIL @Hidden attr InitialLandingSide = "" compassDirection = case geometry.isOriented(world.north): "N" case geometry.isOriented(world.east): "E" case geometry.isOriented(world.south): "S" case geometry.isOriented(world.west): "W" else: "X" FlipDirectionMaybe --> case RM_TYPE == "STAIR": case InitialLandingSide == "N": case TransitionOrientation == 0: Make270Stairs case TransitionOrientation == 180: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. case InitialLandingSide == "S": case TransitionOrientation == 180: Make270Stairs case TransitionOrientation == 0: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. case InitialLandingSide == "E": case TransitionOrientation == 90: Make270Stairs case TransitionOrientation == 270: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. case InitialLandingSide == "W": case TransitionOrientation == 270: Make270Stairs case TransitionOrientation == 90: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. else: print("Error in TransitionOrientation attribute - compass error.") print("InitialLandingSide = " + InitialLandingSide) color(1,0,0) Error. else:NIL Make270Stairs --> case RM_TYPE == "STAIR": split(x) { landingWidth: LandingLowerAndUpper | ~1: TwoStraightRuns | landingWidth: LandingMiddle } else:NIL LandingLowerAndUpper --> case RM_TYPE == "STAIR": Landing t(0,transitionHeight,0) Landing else:NIL LandingMiddle --> case RM_TYPE == "STAIR": t(0,halfFloorHeight,0) Landing else:NIL Landing --> case RM_TYPE == "STAIR": extrude(-landingSlabThickness) color(LandingColor) set(material.opacity, 1-LandingTransparency) else:NIL @Hidden attr runLength = 0 TwoStraightRuns --> case RM_TYPE == "STAIR": set(runLength, scope.sx) DJScratchDirection else:NIL DJScratchDirection --> case RM_TYPE == "STAIR": case TransitionDirection == "CW": split(z){'0.5: FirstRun | '0.5: SecondRun } else: split(z){'0.5: SecondRun | '0.5: FirstRun } else:NIL FirstRun --> case RM_TYPE == "STAIR": StraightRun else:NIL SecondRun --> NIL #case RM_TYPE == "STAIR": rotateScope(0,180,0) t(0, halfFloorHeight, 0) StraightRun #else: NIL StraightRun --> case RM_TYPE == "STAIR": split(x){adjustedStairDepth: Stair}* else: NIL Stair --> case RM_TYPE == "STAIR": t(0,stairRise * (split.index + 1),0) extrude(-stairThickness) color(StairColor) set(material.opacity, 1-StairTransparency) else: NIL adjustedStairDepth = runLength / stairCount stairCount = rint(runLength / stairDepth) stairRise = halfFloorHeight / (stairCount + 1) ################################################################# # Include this in the rule anywhere. Bottom of rule probably. meters(valueInEitherFeetOrMeters) = case units == "Feet": valueInEitherFeetOrMeters * 0.3048 else: valueInEitherFeetOrMeters # Allows CGA author to specify defaults in feet, rather than meters times scale. uFeet(valueInFeet) = case units == "Feet": valueInFeet else: valueInFeet * 0.3048 uMeters(valueInMeters) = case units == "Feet": valueInMeters * 3.28084 else: valueInMeters
... View more
11-09-2015
01:59 PM
|
0
|
0
|
2244
|
|
POST
|
I just applied the rule to planar sections in stairwells of my floor space. Here is the rule: version "2015.1" attr StairColor="#8b8682" attr StairTransparency= 0.3 attr LandingColor="#8b8682" attr LandingTransparency= 0.3 attr landingWidth = 1.2 attr stairDepth = 0.3 attr landingSlabThickness = 0.2 attr stairThickness = landingSlabThickness @Range("CW","CCW") attr TransitionDirection = "CW" attr TransitionHeight = uFeet(13) const transitionHeight = meters(TransitionHeight) attr TransitionOrientation = 0 # Using North=0, CW compass, East=90 @Group("Units",6) @Order(1) @Range("Feet","Meters") attr units = "Feet" unitScale = case units == "Feet": 3.28084 else: 1 const halfFloorHeight = transitionHeight / 2 @StartRule StairMaster --> # Make flat and aligned to world Y axis. alignScopeToAxes(y) s('1,0,'1) # Remove extra vertices. cleanupGeometry(all,0.5) # Get the inner rectangle, since original shapes might be out of square. innerRect # Align X axis on longer side. # XX Will need to add rotation code. PutScopeXGoingLongways PutScopeXGoingLongways --> case scope.sz > scope.sx: rotateScope(0,90,0) OrientationCheck else: OrientationCheck OrientationCheck --> # Tilt up end and check which side the landing is oriented, based on the shape. rotate(rel,scope,0,0,90) set(InitialLandingSide, compassDirection) #print("compassDirection"+compassDirection) #print("TransitionOrientation "+TransitionOrientation) rotate(rel,scope,0,0,-90) FlipDirectionMaybe @Hidden attr InitialLandingSide = "" compassDirection = case geometry.isOriented(world.north): "N" case geometry.isOriented(world.east): "E" case geometry.isOriented(world.south): "S" case geometry.isOriented(world.west): "W" else: "X" FlipDirectionMaybe --> case InitialLandingSide == "N": case TransitionOrientation == 0: Make270Stairs case TransitionOrientation == 180: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. case InitialLandingSide == "S": case TransitionOrientation == 180: Make270Stairs case TransitionOrientation == 0: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. case InitialLandingSide == "E": case TransitionOrientation == 90: Make270Stairs case TransitionOrientation == 270: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. case InitialLandingSide == "W": case TransitionOrientation == 270: Make270Stairs case TransitionOrientation == 90: rotateScope(0,180,0) Make270Stairs else: print("Error in TransitionOrientation attribute.") color(1,0,0) Error. else: print("Error in TransitionOrientation attribute - compass error.") print("InitialLandingSide = " + InitialLandingSide) color(1,0,0) Error. Make270Stairs --> split(x) { landingWidth: LandingLowerAndUpper | ~1: TwoStraightRuns | landingWidth: LandingMiddle } LandingLowerAndUpper --> Landing t(0,transitionHeight,0) Landing LandingMiddle --> t(0,halfFloorHeight,0) Landing Landing --> extrude(-landingSlabThickness) color(LandingColor) set(material.opacity, 1-LandingTransparency) @Hidden attr runLength = 0 TwoStraightRuns --> set(runLength, scope.sx) DJScratchDirection DJScratchDirection --> case TransitionDirection == "CW": split(z){'0.5: FirstRun | '0.5: SecondRun } else: split(z){'0.5: SecondRun | '0.5: FirstRun } FirstRun --> StraightRun SecondRun --> NIL rotateScope(0,180,0) t(0, halfFloorHeight, 0) StraightRun StraightRun --> split(x){adjustedStairDepth: Stair}* Stair --> t(0,stairRise * (split.index + 1),0) extrude(-stairThickness) color(StairColor) set(material.opacity, 1-StairTransparency) adjustedStairDepth = runLength / stairCount stairCount = rint(runLength / stairDepth) stairRise = halfFloorHeight / (stairCount + 1) ################################################################# # Include this in the rule anywhere. Bottom of rule probably. meters(valueInEitherFeetOrMeters) = case units == "Feet": valueInEitherFeetOrMeters * 0.3048 else: valueInEitherFeetOrMeters # Allows CGA author to specify defaults in feet, rather than meters times scale. uFeet(valueInFeet) = case units == "Feet": valueInFeet else: valueInFeet * 0.3048 uMeters(valueInMeters) = case units == "Feet": valueInMeters * 3.28084 else: valueInMeters
... View more
11-09-2015
07:48 AM
|
0
|
0
|
2244
|
|
POST
|
Hmm it worked perfectly for me...I just added in color and transparency
... View more
11-06-2015
02:25 PM
|
0
|
2
|
2244
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-19-2018 11:46 AM | |
| 1 | 04-10-2018 03:47 PM | |
| 1 | 10-01-2018 08:50 AM | |
| 1 | 02-15-2017 07:50 AM | |
| 1 | 10-19-2018 04:08 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-22-2025
08:12 AM
|