BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ashmai
SAS Employee

I want to add an inward buffer zone around boundaries in my map.

 

I have a US states shapefile, reading it in with proc gmap.  I get an output dataset with X,Y that represent the lats/longs of the boundaries.  I would like to "shrink" the boundaries of each state by 0.5 miles for analysis.  IE the outline of NC is now 0.5miles inward of what it used to be, the outline of TN is also 0.5miles inward of what it used to be.  The state boundaries would no longer be contiguous.

 

In GIS software such as ArcGIS, this functionality is called the Buffer tool - I'd like to replicate this in SAS:

http://pro.arcgis.com/en/pro-app/tool-reference/analysis/how-buffer-analysis-works.htm

1 ACCEPTED SOLUTION

Accepted Solutions
Darrell_sas
SAS Employee

Most of the work is done with the data itself.

I do not know how you shrink a state by a half mile all the way around.  You would have to know the direction to shrink it and such.

Just a suggestion, but how about a different option?  Put a half mile circle around each point.  Then treat each point in the circle as a point for GINSIDE.  If any point in the circle is outside of state, then the origional point is within a half mile from an edge.  It might take a while to run and you have a little coding to do.  For example:

 

example2.png

 

There is an example making circles per mile at:

http://support.sas.com/rnd/papers/#SGF2009

Then look for:  Tips and Tricks IV: More SAS/GRAPH Map Secrets

Under that is a link to the paper and the examples.  In the paper, it is the example on page 7.

In the examples, it is SASU2.sas.  The program 'circle' currently does annotate data, but you can modify it to do map data.

 

 

View solution in original post

7 REPLIES 7
ballardw
Super User

I suspect you mean that you used Proc Mapimport not GMap. The results are not actually Lat/long but X Y cartesian coordinates.

What do mean "for analysis"? Do you want to exclude locations within 0.5 miles of the border? What type of analysis? What size are you displaying this at? 0.5 miles is going to be very little difference if displaying the entire US.

 

And are you using SAS/GIS or the basic mapping procedures?

 

ashmai
SAS Employee

Thank you for the reply!  You are correct - I am using PROC MAPIMPORT to read in shapefiles of the states into SAS.

 

I have a series of addresses (lats/longs) where I am using PROG GINSIDE to place them into states.  However, if the address is within 0.5mi of a state boundary, I don't want it to be assigned a state.

 

For example, I have an address at (43.0001,-91.0001) and I need to figure out what state boundaries it is within.  But if this address lat/long is within 0.5mi of a state boundary, I don't want it assigned to a state.  

 

So I need to "clip" the boundaries inwards of the states by 0.5mi, and output a dataset of the boundaries where the boundaries are shrunk by 0.5mi

 

I think I am using the basic procedures... I have SAS9.4 Enterprise Guide.

ballardw
Super User

If you have the border data in terms of lat and long then you may want to look at the GEODIST function as that will return distance between to coordinates in Kilometers or miles. The fun part would be reducing the comparison set to only "reasonable" values so you didn't compare every location with all of the border segments.

 

I don't believe that moving the boundaries would result in the points not being included in plots. I think you would want to flag those problem records and remove drop the flagged ones for consideration.

A very crude, inefficient and possibly long running approach:

proc sql;
   create table ToFlag as
   select distinct Location.id,location.x,location.y
   from location, map
   where geodist(location.y,location.x, map.y, map.x,'M') <= 0.5;
quit;

where both the location and map boundary data sets have coordinates in either degrees or radians(set the option) would create a set you could compare the locations to for removal from the analysis. Location.id would be any variable or combination of variables that uniquely identify any point of interest in your address file.

 

 

Or if you had access to the Arcgis create the boundary set as reduced.

Darrell_sas
SAS Employee

Most of the work is done with the data itself.

I do not know how you shrink a state by a half mile all the way around.  You would have to know the direction to shrink it and such.

Just a suggestion, but how about a different option?  Put a half mile circle around each point.  Then treat each point in the circle as a point for GINSIDE.  If any point in the circle is outside of state, then the origional point is within a half mile from an edge.  It might take a while to run and you have a little coding to do.  For example:

 

example2.png

 

There is an example making circles per mile at:

http://support.sas.com/rnd/papers/#SGF2009

Then look for:  Tips and Tricks IV: More SAS/GRAPH Map Secrets

Under that is a link to the paper and the examples.  In the paper, it is the example on page 7.

In the examples, it is SASU2.sas.  The program 'circle' currently does annotate data, but you can modify it to do map data.

 

 

Rick_SAS
SAS Super FREQ

I like Darell's suggestion. I would wager that it you use just 8 points (N, S, E, W, NE, NW, SE, SW) around a point you will identify almost all of the observations that are within a mile of a state boundary. Out West (where many boundaries run N-S or E-W), you will probably identify 100%.  In the East (where boundaries might be defined by a river), I conjecture that the identification rate will still be extremely high.

ballardw
Super User

@Rick_SAS brings up a point I forgot, and should know better, the states with long "straight" borders would not necessary have enough boundary points to accurately get distance.

ashmai
SAS Employee

Thanks to all for the suggestions!

 

@ballardw Your point about states with straight borders is a great catch... I assume that a straight boundary would just have points at the vertices.

 

I think drawing a 0.5 radius circle around the address points will work, in conjunction with using PROC GINSIDE to determine if any of those points will fall in a different state.

 

Thank you everyone for your suggestions!

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1660 views
  • 3 likes
  • 4 in conversation