|
POST
|
I guess the question is can I format an image in the Attribute Expression and then apply this Attribute Expression in the Popup? I can do it with Text but want an image.... Then based on the value of the field I can change the image being represented In the example below I am hardcoding an image into the popup....but I want to be able to change this image based on a field in the actual data... So the image would have to be formatted or constructed in the Attribute Expression
... View more
10-26-2020
01:55 PM
|
0
|
1
|
1148
|
|
POST
|
Is it possible to add an URL image to an attribute Expression? I want the text to be follow by a specific image based on the field value. I can get the text to change with no issues but want to add a specific image function symbol(feature){
image1 = "https://img.icons8.com/color/search/96 "
image2 = "https://img.icons8.com/color/search/96 "
var display = When(feature == 1, 'Permittee' + image1, feature == 0, 'Trap' + image2, 'n/a');
return display
}
symbol($feature.LOK)
... View more
10-26-2020
10:06 AM
|
0
|
2
|
1180
|
|
POST
|
Randy Burton Thanks Randy...I really do like this approach and learning as I go....much appreciated. Think this is the approach I am going to take...modified your example a bit and added some more validation and it is working great..
... View more
09-10-2020
06:10 AM
|
0
|
0
|
1198
|
|
POST
|
I have a python script that I can run from ArcCatalog with no issues. I go to publish this script after running it and First verify there are no errors or warnings I then publish it.... I get an error that pops up....I have never seen this before. NOTE: I have published many scripts to the exact server and folder location as I am placing this one. The names are shorter than some of the other ones that were successful Any ideas that I can check Runs fine in Catalog After Running the Analyze I get no errors I then hit PUBLISH and I can see it starting to write the Service Definition I can see the folder size get to 147mb and then it just errors out
... View more
09-09-2020
12:13 PM
|
0
|
0
|
430
|
|
POST
|
Dan Patterson was I correct in the logic about reading in my geometry for the polygon.... Yea I am using python here....trying to publish this out to a service but its not letting me.....keeps blowing up saying Error in creating the definition file
... View more
09-09-2020
10:30 AM
|
0
|
2
|
1198
|
|
POST
|
Last questions.....Can you do? distance = 25 + " Mile"
point.with-distance-of(polygon, distance)
... View more
09-09-2020
09:51 AM
|
0
|
4
|
1198
|
|
POST
|
OK I think I am understanding now....so I would just read in my geometry.... Do I have this correct.... read in my Polygons coordinates instead of the squares XYs create the array from list of coords create my point with my XY coordinates Test and point.within(polygon) will return true if within and false if outside # READ IN THE COORDINATES OF MY POLY INSTEAD OF THE SQUARE BELOW
coords = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]]
# CREATE ARRAY OF THOSE COORDS
polygon = arcpy.Polygon(arcpy.Array([arcpy.Point(*a) for a in coords]), sr)
print "polygon area:", polygon.area
# READ IN MY POINT GEOMETRY
point = arcpy.PointGeometry(arcpy.Point(X Coord, Y Coord), sr)
# TEST IF INSIDE WILL RETURN TRUE IF YES AND FALSE IF NO?
print "point within polygon:", point.within(polygon)
... View more
09-09-2020
09:34 AM
|
0
|
5
|
1970
|
|
POST
|
Dan I am interested in this approach...is there a better example? Trying to get a better understanding of this.
... View more
09-08-2020
12:04 PM
|
0
|
8
|
1970
|
|
POST
|
Think I might have it.....but not sure still testing...took the fcPoint we created and used MakeFeatureLayer and used that arcpy.MakeFeatureLayer_management(fcPoint, "PointfromGeocode") results = arcpy.SelectLayerByLocation_management('PointfromGeocode', 'WITHIN', 'state_lyr')
... View more
09-08-2020
06:28 AM
|
0
|
0
|
1970
|
|
POST
|
OK I am here again....still having issues with the first parameter ....Im trying to create the Feature and put it into memory as you suggested....but getting the same error where the parameters are incorrect. I am not sure about this line in your example fcPoint<Result 'in_memory\\points'> ERROR: Traceback (most recent call last): File "E:\ArcGIS Server\ArcGIS Published MXDs\Projects\NWTL\Python\NWTL_In_Virginia.py", line 132, in <module> results = arcpy.SelectLayerByLocation_management('IN_MEMORY\\points', 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION') File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 7891, in SelectLayerByLocation raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data. Failed to execute (SelectLayerByLocation). # USE THE GEOCODED LOCATION
ptGeometry = arcpy.PointGeometry(arcpy.Point(\
geocodeResult["candidates"][0]["location"]["x"],\
geocodeResult["candidates"][0]["location"]["y"]),\
arcpy.SpatialReference(geocodeResult["spatialReference"]["wkid"]))
print(ptGeometry.JSON)
print ""
out_path = "IN_MEMORY"
out_name = "points"
geometry_type = "POINT"
template = ""
has_m = ""
has_z = ""
fcPoint = arcpy.CreateFeatureclass_management(out_path,out_name,geometry_type,template,has_m,has_z,\
spatial_reference=arcpy.SpatialReference(geocodeResult["spatialReference"]["wkid"]))
#fcPoint<Result 'in_memory\\points'>
cursor = arcpy.da.InsertCursor(fcPoint,["SHAPE@"])
cursor.insertRow([ptGeometry])
del cursor
## TEST TO SEE IF POINT IS INSIDE THE BUFFERED GEOMETRY
results = arcpy.SelectLayerByLocation_management('IN_MEMORY/points', 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION')
# If features matched criteria, write them to a new feature class
matchcount = int(arcpy.GetCount_management(results)[0])
if matchcount == 0:
print('no features matched spatial and attribute criteria')
else:
print('found something')
print ""
varResult = "true"
# DELETE THE FEATURE WHEN DONE
arcpy.Delete_management('IN_MEMORY/points')
... View more
09-08-2020
06:22 AM
|
0
|
1
|
1970
|
|
POST
|
Thanks for your reply randy burton At one point I was taking my state layer and buffering it and then trying to see if the point was inside it. Now I am simply using the SelectLayerByLocation and specifying a distance to search for the point location within a user specified distance of the state I WANT to find if the point is in the State or within a specified distance of the state The issue I am running into is that I cannot use the ptGeometry as a parameter because I get the following error If I use a Point in afeature class it works..... Notice below in the code that changed the output to UTM Zone 17N. That is the Projection of the State Layer being referenced and its in meters. I need to be able to geocode an address, get the XY and then test if its in the state with the user specified distance to search slightly outside the boundary. results = arcpy.SelectLayerByLocation_management(ptGeometry, 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION') This is what I get back when I run it. address: 1520 Split Oak Ln, Henrico, VA, 23229
distance: 25
805193.59194
4167142.87407
{"x":805193.59194028517,"y":4167142.8740720972,"spatialReference":{"wkid":null}}
Traceback (most recent call last):
File "E:\ArcGIS Server\ArcGIS Published MXDs\Projects\NWTL\Python\NWTL_In_Virginia.py", line 120, in <module>
results = arcpy.SelectLayerByLocation_management(ptGeometry, 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION')
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 7891, in SelectLayerByLocation
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000368: Invalid input data.
Failed to execute (SelectLayerByLocation). # SNIP OUT THE CODE ABOVE THAT HANDLES THE PARAMETERS FOR ADDRESS AND DISTANCE
distanceMeters = int(varsearchDistance) * 1609.34
def singleAdressGeocode(address, geoCodeUrl, outSR = "26917"):
##clean up the address for url encoding
address = address.replace(" ", "+")
address = address.replace(",", "%3B")
#send address to geocode service
lookup = requests.get(geoCodeUrl + "?SingleLine=" + address + "&outSR=" + outSR + "&maxLocations=1&f=pjson")
data = lookup.json()
if data["candidates"]:
##coords = data["candidates"][0]["location"]
##return coords
return data
else:
##no results
return "Address not geocoded: " + address
# DEFINE VARIABLES FOR THE ADDRESS AND X AND Y VALUES
geocodeResult = singleAdressGeocode(varsearchAddress, geoCodeUrl)
addressResult = geocodeResult["candidates"][0]["address"]
coordinateX = geocodeResult["candidates"][0]["location"]["x"]
coordinateY = geocodeResult["candidates"][0]["location"]["y"]
# DEFINE THE STATE FEATURE CLASS
arcpy.MakeFeatureLayer_management(r"E:/ArcGISProjects/CountySelection/xx.sde/Virginia_Prj_Meters", "state_lyr")
## SET THE DISTANCE PARAMETER
distance = int(distanceMeters)
ptGeometry = arcpy.PointGeometry(arcpy.Point(coordinateX,coordinateY))
arcpy.MakeFeatureLayer_management(ptGeometry, "PointfromGeocode")
print(ptGeometry.JSON)
results = arcpy.SelectLayerByLocation_management(ptGeometry, 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION')
# If features matched criteria, write them to a new feature class
matchcount = int(arcpy.GetCount_management(results)[0])
if matchcount == 0:
print('no features matched spatial and attribute criteria')
else:
print('found something')
print ""
varResult = "true"
... View more
09-03-2020
12:45 PM
|
0
|
3
|
1970
|
|
POST
|
OK ... Puzzled here....I can get this to work if I reference the point that is in a Feature Class but I cannot get it to work with the result from my Geocoded address and resulting XY My original address that is geocoded is WGS84 I convert that to UTM Nad83 Zone 17N (26917) The state State layer is stored in UTM Nad83 Zone17N (26917) Meters The input from the parameters is Miles and I am converting that distance to Meters. I know the distance thing is working because I can test that against a Point that is outside the state in a Feature Class and increase that distance and it eventually finds it... Any thoughts as to why the Geocoded result is not being found...I am converting this to the Appropriate Spatial Reference.....ugggggg This Does NOT work ## CONVERT MILE TO METERS FOR SPATIAL BUFFER
# Value received from input parameter in JSON string
distanceMeters = int(varsearchDistance) * 1609.34
arcpy.MakeFeatureLayer_management(r"E:/ArcGISProjects/Selection/xx.sde/Virginia_UTM_Meters", "state_lyr")
x = -77.434769 # longitude
y = 37.541290 # latitude
# convert from WGS84 to UTM zone 17N
ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(4326)).projectAs(arcpy.SpatialReference(26917))
arcpy.MakeFeatureLayer_management(ptGeometry, "PointfromGeocode")
distance = int(distanceMeters)
results = arcpy.SelectLayerByLocation_management('PointfromGeocode', 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION') This works - only real difference is that I am pointing to a Feature Class point instead of usign the XY to create the point geometry ## CONVERT MILE TO METERS FOR SPATIAL BUFFER
# Value received from input parameter in JSON string
distanceMeters = int(varsearchDistance) * 1609.34
arcpy.MakeFeatureLayer_management(r"E:/ArcGISProjects/Selection/xx.sde/Virginia_UTM_Meters", "state_lyr")
arcpy.MakeFeatureLayer_management(r"E:/ArcGISProjects/Selection/xx.sde/TestPoint", "testPoint")
distance = int(distanceMeters)
results = arcpy.SelectLayerByLocation_management('testPoint', 'WITHIN_A_DISTANCE', 'state_lyr', distance, selection_type='NEW_SELECTION') HOW CAN I Test this new Layer? I tried the below but I dont get anything returned. ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(4326)).projectAs(arcpy.SpatialReference(26917))
arcpy.MakeFeatureLayer_management(ptGeometry, "PointfromGeocode")
print "start"
fields = ['SHAPE@XY']
with arcpy.da.SearchCursor('PointfromGeocode', fields) as cursor:
for row in cursor:
print(u'{0}'.format(row[0]))
print "end of first"
... View more
09-03-2020
08:06 AM
|
0
|
5
|
3213
|
|
POST
|
Think I might have it....Using the MakeFeatureLayer to take the ptGeometry and make a feature layer.... ptGeometry = arcpy.PointGeometry(arcpy.Point(coordinateX,coordinateY),arcpy.SpatialReference(4326)).projectAs(arcpy.SpatialReference(4269))
arcpy.MakeFeatureLayer_management(ptGeometry, "PointfromGeocode") Also changed the Coord system to match that of my State Layer (webaux sphere) ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(4326)).projectAs(arcpy.SpatialReference(3857)) For some reason not finding the XY coordinates keep telling me no matches... matchcount = int(arcpy.GetCount_management(results)[0])
if matchcount == 0:
print('no features matched spatial and attribute criteria')
else:
print('found something')
print ""
varResult = "true"
... View more
09-03-2020
07:02 AM
|
0
|
0
|
3213
|
|
POST
|
randy burton Thanks for your input... If I do the below I am getting this error thrown back at me.... Maybe I should project all my data and use a different coord system? Note: My polygon layer (state of VA) is: GCS_WGS_1984 WKID: 4326 Authority: EPSG ERROR: Traceback (most recent call last): File "E:\ArcGIS Server\ArcGIS Published MXDs\Projects\NWTL\Python\NWTL_In_Virginia.py", line 109, in <module> results = arcpy.SelectLayerByLocation_management('IN_MEMORY/BufferGeom', 'CONTAINS', ptGeometry, selection_type="NEW_SELECTION") File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 7891, in SelectLayerByLocation raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data. Failed to execute (SelectLayerByLocation). varsearchDistance = This value comes from a Parameter being sent to the .py script via a JSON string. It is in miles and I then convert ot meters.
## CONVERT MILE TO METERS FOR SPATIAL BUFFER
distanceMeters = int(varsearchDistance) * 1609.34
arcpy.MakeFeatureLayer_management(r"E:/ArcGISProjects/CountySelection/xx.sde/Virginia", "state_lyr")
x = -75.369027 # longitude
y = 37.935822 # latitude
# WGS 1984: 4326
# GCS North American 1983: 4269 ## use the factory/authority code for BufferGeom layer
ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(4326)).projectAs(arcpy.SpatialReference(4269))
## BUFFER THE STATE LAYER AND PUT IT IN MEMORY
arcpy.Buffer_analysis('state_lyr', 'IN_MEMORY/BufferGeom', distanceMeters)
results = arcpy.SelectLayerByLocation_management('IN_MEMORY/BufferGeom', 'CONTAINS', ptGeometry, selection_type="NEW_SELECTION")
... View more
09-03-2020
06:18 AM
|
0
|
0
|
3213
|
|
POST
|
dan patterson OK I got it working but it seems the issue is around the point feature that I am creating from the Geocoded results... Any thoughts? The data is in WGS84 If I point this to a point Feature Class as such this WORKS arcpy.MakeFeatureLayer_management(r"E:/ArcGISProjects/CountySelection/xx.sde/Test", "testPoint")
results = arcpy.SelectLayerByLocation_management('testPoint', 'WITHIN', 'IN_MEMORY/BufferGeom') But I need to create a Point reference from the Geocoded XY this FAILS # CREATE THE POINT FROM THE X AND Y
point = arcpy.Point(coordinateX, coordinateY)
ptGeometry = arcpy.PointGeometry(point)
# DEFINE THE POINT FEATURE CLASS
arcpy.MakeFeatureLayer_management(ptGeometry, 'point_lyr')
results = arcpy.SelectLayerByLocation_management('point_lyr', 'WITHIN', 'IN_MEMORY/BufferGeom')
... View more
09-02-2020
05:42 AM
|
0
|
9
|
3215
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-20-2018 11:09 AM | |
| 1 | 09-10-2018 06:26 AM | |
| 1 | 09-15-2022 11:02 AM | |
| 1 | 05-21-2021 07:35 AM | |
| 1 | 08-09-2022 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-19-2022
09:23 PM
|