Hello,
I have a JavaScript label expression that I am having trouble converting to ARCADE. The label expression is addresses for New York City Buildings. Since some buildings have multiple addresses the ability to minimize text is essential.
In the label field are parenthesis and since ARCADE uses parenthesis i can't figure out how to represent them as text.
Here is the label expression in JavaScript:
function FindLabel ( [FIELDNAMEl] )
{
return [FIELDNAME].replace(/::/g, "\n").replace(/ *\([^)]*\) */g, "");
}
In ARCADE I currently have the label expression looking like this:
Replace($feature.FIELDNAME, '/::/g/ *\([^)]*\) */g', " " )
Parenthesis need to be removed from the label as well, which should remove the street name, for example, (W 34TH ST).
All types of characters should be replaced with nothing. I want to minimize code as well.
Thanks in Advance.Xander BakkerJake Skinner
Solved! Go to Solution.
Hi jbrockwe ,
Yes, the code I provided is not connected to any field, so it is returning the same result for each record. Try this (I assume your field is called "Address_Label", see line 1):
var input = $feature["Address_Label"];
// remove all after (
var result = Trim(Split(input, "(")[0]);
// Replace :: by new line
result = Replace(result, "::", TextFormatting.NewLine);
// Replace charctars -> add all the characters you want to strip:
var remove = ["\\", "(", "[", "^", ")", "]", "*"];
for (var a in remove) {
Console(a);
result = Replace(result, remove[a], "");
}
return result;
Hi John Brockwell ,
I assume you are trying to convert a VBScript label used in ArcMap (?) to an Arcade label in ArcGIS Pro. Is that the case?
Have a look at the test code below:
var input = "338 - 350, 350A, 350B, 5 AVE::1 - 31 W 33 ST::2 - 20 W 34 ST";
var input = "352 - 350 (5 AVE)";
var input = "1 (W 34 ST)";
var input = ")123^*[]";
// remove all after (
var result = Trim(Split(input, "(")[0]);
// Replace :: by new line
result = Replace(result, "::", TextFormatting.NewLine);
// Replace charctars
var remove = ["\\", "(", "[", "^", ")", "]", "*"];
for (var a in remove) {
Console(a);
result = Replace(result, remove[a], "");
}
return result;
as result:
"338 - 350, 350A, 350B, 5 AVE::1 - 31 W 33 ST::2 - 20 W 34 ST"
returns:
338 - 350, 350A, 350B, 5 AVE
1 - 31 W 33 ST
2 - 20 W 34 ST
"352 - 350 (5 AVE)"
returns:
352 - 350
"1 (W 34 ST)";
returns:
1
")123^*[]";
returns:
123
Thank you for your assistance.
Yes, I am trying to bring an ArcMap label expression (below) into ArcGIS Pro and ArcGIS Enterprise / ArcGIS Online.
I brought the expression into ArcGIS Pro from ArcMap.
When I ran your code in ArcGIS Pro using Arcade the buildings were all "123".
Not sure where the disconnect is?
Thanks again,
JB
Hi jbrockwe ,
Yes, the code I provided is not connected to any field, so it is returning the same result for each record. Try this (I assume your field is called "Address_Label", see line 1):
var input = $feature["Address_Label"];
// remove all after (
var result = Trim(Split(input, "(")[0]);
// Replace :: by new line
result = Replace(result, "::", TextFormatting.NewLine);
// Replace charctars -> add all the characters you want to strip:
var remove = ["\\", "(", "[", "^", ")", "]", "*"];
for (var a in remove) {
Console(a);
result = Replace(result, remove[a], "");
}
return result;
This is great! You da Man!!!
My pleasure John! Glad to hear that it is working.
Hola a todos.
Tengo un script VBScript de ArcMap que lo utilizo en una GDB catalogada, ahora quiero utilizar el mismo script en ArcGIS Pro y me genera un error. No soy programador, es por esa razón que no entiendo el porqué me sale eso, si en el Pro utilizo la misma opción.
Ejemplo del Script utilizado en ArcMap:
if ([rpdt] = "2") then
d="2"
end if
if ([rpdt] = "1") then
d="1"
end if
if ([rpdt] = "998") then
d="998"
end if
en dónde el valor numérico (1 - 2 - 998) tienen asignada una categoría ejm: (1 = plana; 2=Muy suave; 998=No Aplica), son categoria de un mapa de pendientes usado en geología.
Ahora cuando ingreso el código en el Pro, me marca los números de rojo como error, y en dónde dice (rpdt_desc=) no me acepta la variable "d"