Label only Waterbodies that a path passes through

753
6
10-05-2021 06:31 AM
AlexErnst
New Contributor II

I have a many canoe routes that I have imported from Google Earth using the KML to Layer tool.  I would like to label only the waterbodies (lakes, rivers, streams) which the route passes through (shown as a blue line on my maps).  I can do this by creating my own labels, but this is quite time consuming and I know there must be an easier way.

I have attached a sample of my latest attempt. I am experimenting with monochrome, so bear with me.

Thanks,

Alex Ernst

0 Kudos
6 Replies
jcarlson
MVP Esteemed Contributor

Your map is looking very neat!

There may be a variety of ways to accomplish what you're asking, but it depends on how your data is set up. Are the layers separate files, a geodatabase, a Feature Service?

If you have control over the data, you could use Arcade to calculate a new field, then use that field to control whether or not the features label.

If the data were in a database, you could also do this with a query layer, but that can get a bit more complex.

- Josh Carlson
Kendall County GIS
0 Kudos
AlexErnst
New Contributor II

When I view the data on my base layer, it says "File Geodatabase Feature Class".  I imported it from the Living Atlas, and it is called OHN Waterbody.  It was a very large file and I clipped it to just the area I need.  When I look at the attribute table, I do see labels for naming in the Official_Name_Label column.

All my other data I believe is organized separately, and I can turn layers on and off in the contents pane.

0 Kudos
jcarlson
MVP Esteemed Contributor

Okay, so it's a local feature class. I would use the Calculate Field tool and create a new field called "showLabel". Make it an integer field, and use an expression like this:

var rt = FeatureSetByName($map, 'route_layer_name')

if(Intersects($feature, rt)){
    return 1
} else {
    return 0
}

Then in your label class properties, you can use an SQL expression to filter out non-intersecting features.

While I like the quick simplicity of @David_Brooks's solution, this does keep down the number of layers in your TOC, and you'll only need to configure the symbology / labeling / etc in one layer rather than splitting it across multiple.

I have a followup question: is the end goal to create maps of multiple routes? And if so, do any of the routes share segments, or come near one another? I ask because a simple boolean field may lead to labels showing on other maps.

If your routes are all far enough apart, then huzzah, the boolean field will work just fine. If not, though, then there probably needs to be some other approach, otherwise you'd need to do a bunch of clicking and re-calculating for each route map separately.

- Josh Carlson
Kendall County GIS
0 Kudos
AlexErnst
New Contributor II

Yes, my end goal is to create many maps, each of various routes (about 20).  Some are overlapping, but most are far apart.

I will experiment with your method and see what happens, as I love to learn new techniques. Thanks!

0 Kudos
David_Brooks
MVP Regular Contributor

@AlexErnst a quick way to do it is to select features by location, so that you have a selection set. Then create a layer from the selection:

1. 

Brooks_SummitGeo_0-1633443511470.png

 

2.

Brooks_SummitGeo_1-1633443546554.png

 

3. Just label the selection layer.


David
..Maps with no limits..
AlexErnst
New Contributor II

Ok, selection by location worked really well!  Not only was I able to sort just those labels, but I can also show only those water bodies, which makes a cool looking map.  I still need to work on my label placement, but attached is my current map.

Thanks!