BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cjinsf
Obsidian | Level 7

Hi!  Just need a little help using maps.counties.

Using maps.counties as a base data set I need to remove boundaries between two adjacent counties and redraw a new boundary.

For example, in California (state 6) I need to remove the boundary between Riverside County (county 65) and Orange County (county 59) and redraw a vertical line where x = 2.0475 (so now Orange County's new border extends into Riverside).

I was thinking I could use proc gremove to remove the boundary, but how would I add the new vertical boundary at x = 2.0475?  I know sort order is important, so where would this new boundary need to be placed in my counties dataset?

Thanks for any help/ hints given!

1 ACCEPTED SOLUTION

Accepted Solutions
Darrell_sas
SAS Employee

First, why are you moving the country boundary?  Has the county line actually changed?

If so, you might consider using the new MAPSGFK map library (first released with 9.3m2).

Unless this is a very recent change, it should be reflected in this data.

As far as removing and adding the boundary in your current map, is isn't trivial.

Gremove can take a counties data set and remove the internal county lines and leave you with the state boundary only.  It does this by having multiple variables to identify the area.  One is the state and one is the county.  So, to remove the line between these counties, you need a similar set of values that indicates these 2 counties are in the same larger group (like state was above).

Adding a line back is difficult.  You must end up with 2 polygons and you have now created one out of the two areas.  You really need to know the y and x values at each end of this new line, that is, where the new line intersects the outside polygon.  And that line coordinates must be inserted into each polygons.

Looking at the example below, you have straight boundary lines.  But your counties will not and there may not already be a point where you want to insert the new line.   This starts after you removed the existing line and now have only one polygon.

y, x

1,3                           1.5,3                      2,3

  -----------------------------------------------------

  |                             A                               |      After removing - Only have polygon "A"

  |                                                              |

  ------------------------------------------------------

1,4                                                           2,4

In the map data set, the data might look like this:

ID         y        x       segment

A         1        3        1

A          2       3         1

A          2       4         1

A          1       4         1

What you need:

y,x

1,3                           1.5,3                      2,3

  -----------------------------------------------------

  |               A                |              B           |      After adding new line and having 2 polygons.

  |                                 |                            |

  ------------------------------------------------------

1,4                                                           2,4

You need to change it to, where A and B are the 2 different counties.

ID        y         x       segment

A         1         3         1

A         1.5      3         1                    <= New Line

A         1.5      4         1                    <= New Line

A          1        4         1

B         1.5      3         1                    <= New Line

B          2        3         1

B          2        4         1

B         1.5      4         1                     <= New Line

You will probably have to add this manually using data step code.

Hope that helps.

View solution in original post

2 REPLIES 2
Darrell_sas
SAS Employee

First, why are you moving the country boundary?  Has the county line actually changed?

If so, you might consider using the new MAPSGFK map library (first released with 9.3m2).

Unless this is a very recent change, it should be reflected in this data.

As far as removing and adding the boundary in your current map, is isn't trivial.

Gremove can take a counties data set and remove the internal county lines and leave you with the state boundary only.  It does this by having multiple variables to identify the area.  One is the state and one is the county.  So, to remove the line between these counties, you need a similar set of values that indicates these 2 counties are in the same larger group (like state was above).

Adding a line back is difficult.  You must end up with 2 polygons and you have now created one out of the two areas.  You really need to know the y and x values at each end of this new line, that is, where the new line intersects the outside polygon.  And that line coordinates must be inserted into each polygons.

Looking at the example below, you have straight boundary lines.  But your counties will not and there may not already be a point where you want to insert the new line.   This starts after you removed the existing line and now have only one polygon.

y, x

1,3                           1.5,3                      2,3

  -----------------------------------------------------

  |                             A                               |      After removing - Only have polygon "A"

  |                                                              |

  ------------------------------------------------------

1,4                                                           2,4

In the map data set, the data might look like this:

ID         y        x       segment

A         1        3        1

A          2       3         1

A          2       4         1

A          1       4         1

What you need:

y,x

1,3                           1.5,3                      2,3

  -----------------------------------------------------

  |               A                |              B           |      After adding new line and having 2 polygons.

  |                                 |                            |

  ------------------------------------------------------

1,4                                                           2,4

You need to change it to, where A and B are the 2 different counties.

ID        y         x       segment

A         1         3         1

A         1.5      3         1                    <= New Line

A         1.5      4         1                    <= New Line

A          1        4         1

B         1.5      3         1                    <= New Line

B          2        3         1

B          2        4         1

B         1.5      4         1                     <= New Line

You will probably have to add this manually using data step code.

Hope that helps.

cjinsf
Obsidian | Level 7

Thank you!  Exactly what I needed.  County boundaries haven't changed; just using this as a guide to annotate areas that mostly follow county lines to define specific areas of interest on a state/ county map.

Thanks again!

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1942 views
  • 0 likes
  • 2 in conversation