BookmarkSubscribeRSS Feed

The Many Uses of PROC GPROJECT: Clipping Data

Started Friday by
Modified Friday by
Views 69

In a previous article, I discussed how to use PROC GPROJECT to project and re-project spatial data. However, that’s not all that the GPROJECT procedure can be used for! In this article, I’ll discuss how you can use PROC GPROJECT to clip out a specific geographic extent from a larger dataset, allowing you to create precise maps that focus on a defined study area.

 

Why Clip Spatial Data?

 

Imagine you are working on a project focusing specifically on the northeast United States. You need to create a map highlighting this region, but you only have a map data set that covers the entire country. Rather than going back to the drawing board and trying to find a new map data set that focuses on just your study area, you can simply clip your existing map data set to a specific geographic extent.

GT_clip_01.png

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

 

Using the GPROJECT Procedure

 

When using the GPROJECT procedure to project spatial data, you use the PROJECT= option to specify what projection to use: Lambert, Albers, Gnomonic, or Proj4. However, there is a fifth option: none.

 

You can then use the LONGMIN=, LONGMAX=, LATMIN=, and LATMAX= options to specify the geographic extent that you want to clip. The latitude and longitude values that you provide here determine the rectangle that is clipped from the input data.

 

PROC GPROJECT DATA=input-mapdata-set   

                             

<OUT=output-map-data-set>     

                           

DEGREES                  

              

EASTLONG     

                           

PROJECT=none      

                         

LONGMIN=min-longitude    

                           

LONGMAX=max-longitude          

                      

LATMIN=min-latitude                 

               

LATMAX=max-latitude;                  

 

ID <id-variable(s)>;

 

RUN;  

 

 

Let’s look at an example. Imagine that I have a map data set covering the entire United States. Using the SGMAP procedure, I could create a map that looks like this:

GT_clip_02.png

However, I need to create a map focused on just the northeastern region of the country. To do so, I’ll use the LONGMIN, LONGMAX, LATMIN, and LATMAX options to define the region that I want to clip. I’ll specify the latitude parallels that define the northern and southern bounds of my study area, and the longitude values (or meridians) that define the eastern and western bounds. Because my input data set is unprojected, I’ll refer to unprojected latitude and longitude values in the GPROJECT procedure.

 

proc gproject data=states
              out=NE_States
              degrees eastlong
              project=none
              longmin=-80
              longmax=-60
              latmin=40
              latmax=75;
   id StateCode;
run;

 

This will create a clipped map data set, where the northern boundary is 75 degrees latitude, the southern boundary is 40 degrees latitude, the eastern boundary is -80 degrees longitude, and the western boundary is -60 degrees longitude.

GT_clip_03.png

This new, clipped map data set can then be used to create more precise maps, focused just on this particular study area.

 

Conclusion

 

When creating a map or performing spatial analysis, your map data set may not always line up exactly with your study area. However, using the GPROJECT procedure, it’s easy to trim or clip a map dataset to a specific geographic extent.

 

Tip and Tricks

 

  • You can combine the LATMIN, LATMAX, LONGMIN, and LONGMAX with another PROJECT= option instead of NONE to project a map data set at the same time as clipping it.
  • If you’re clipping a data set that’s already projected, make sure to use the latitude and longitude values used by that particular projection.

 

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
Friday
Updated by:
Contributors

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags