Example: dental hygienist

CREATING A ZIP-CODE MAP WITH

CREATING A ZIP-CODE MAP WITH COUNTY BORDERS AND CITY LABELSR achel PotterMSUGO ctober 20, 2016 OVERVIEWFrom this:To this (a pdf):proc mapimportproc gmapproc gprojectgoptionsods1. MAKE A DATASET OF ZIP code -LEVEL DATAREADY THE DATA FOR MAPPING/*coverage by zip code */datazipcovg;lengthzcta5ce10 $5.; ;zcta5ce10 = zip;run;proc format;valuecovgfmtLOW - < 'LOW' 'MEDIUM LOW' 'MEDIUM HIGH' HIGH = 'HIGH';run;2. MAKE A ZIP code MAPZIP code TABULATION AREAS (ZCTA)ZCTAs are generalized areal representations of Postal Service ZIP CodesThe Census Bureau creates ZCTAs by: Examining all addresses within a census block The most frequently occurring ZIP code within each block is assigned to the entire block If a block had addresses, but ZIP code frequencies were tied, it is assigned to the ZCTA with which it has the longest shared boundary Areas wi

CREATING A ZIP-CODE MAP WITH COUNTY BORDERS AND CITY LABELS Rachel Potter MSUG October 20, 2016

Tags:

  Code, Creating, Creating a zip code map

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of CREATING A ZIP-CODE MAP WITH

1 CREATING A ZIP-CODE MAP WITH COUNTY BORDERS AND CITY LABELSR achel PotterMSUGO ctober 20, 2016 OVERVIEWFrom this:To this (a pdf):proc mapimportproc gmapproc gprojectgoptionsods1. MAKE A DATASET OF ZIP code -LEVEL DATAREADY THE DATA FOR MAPPING/*coverage by zip code */datazipcovg;lengthzcta5ce10 $5.; ;zcta5ce10 = zip;run;proc format;valuecovgfmtLOW - < 'LOW' 'MEDIUM LOW' 'MEDIUM HIGH' HIGH = 'HIGH';run;2. MAKE A ZIP code MAPZIP code TABULATION AREAS (ZCTA)ZCTAs are generalized areal representations of Postal Service ZIP CodesThe Census Bureau creates ZCTAs by.

2 Examining all addresses within a census block The most frequently occurring ZIP code within each block is assigned to the entire block If a block had addresses, but ZIP code frequencies were tied, it is assigned to the ZCTA with which it has the longest shared boundary Areas without addresses are assigned to the surrounding ZCTA or merged into an adjacent ZCTA with which it has the longest shared boundary Blocks are aggregated to create larger (1 Slide 6PR(1 Potter, Rachel (DHHS), 7/22/2016 DOWNLOAD THE ZCTA THE FILES The naming convention is: <TIGER/Line>_<file version>_<state FIPS code >_<layer tag> A MAP DATASET/*convert the shapefile to a map dataset*/proc mapimportdatafile='T:\MCIR Data Studies\Geography\2010_ZCTA\ 'out=mi_zshp;idzcta5ce10;run;MAP THE DATASET proc gmapdata=zipcovgmap=mi_zshp;idzcta5ce10; choroizcovg / nolegend;formatizcovgcovgfmt.))

3 ;run; quit;But Michigan looks squished!And lines are missing!PROJECT THE MAP DATASETP rojecting is the process of converting coordinates from spherical (latitude and longitude) to gproject projects the latitude and longitude coordinates onto a two-dimensional planeminimizes distortion of area, distance, direction, and shapeproduces an output map dataset for use in proc gmapproc gmap is designed to plot points on a flat (two-dimensional) planeGPROJECT PROCEDURE*map is distorted - need to project;proc gprojectdata=mi_zshpdegrees eastlongout=mi_zshp_prj;idzcta5ce10;run.

4 Specifies that the units for X/Y coordinates are degreesSpecifies that the longitude (X) values increase to the the variable(s) in the input map dataset that identifies unit areasMAP THE PROJECTED DATASET proc gmapdata=zipcovgmap=mi_zshp_prjall;idzct a5ce10;choroizcovg / nolegend;formatizcovgcovgfmt.;run; quit;Specifies that generated maps will include all of the map areas from the map dataset, even if the response dataset does not include an observation for the map ADD COUNTY BORDERSGET A COUNTY MAPNo need to import!County is one of many SAS-supplied maps*View SAS-supplied maps;proc datasetslib=maps;quit;CREATE A COUNTY MAP LAYER?

5 Color=black value=empty; proc gmapdata= ;idcounty;chorocounty / nolegend;wherestate eq26;run; quit;/*map is backwards and distorted need to project*/proc gprojectdata= radians westlongout=mi_prj;wherestate eq26;idstate;run;/*map the projected data*/proc gmapdata=mi_prj (obs=1) map=mi_prj;idcounty;chorocounty / nolegend;run; quit;pattern;Michigan s FIPS codeThe defaultCREATE AN ANNOTATE DATA SET? observation in an annotate data set has complete instructions for drawing, or moving to draw, a graphicWhat to doWhere to do itHow to do itHOW TO CREATE AN ANNOTATE DATASET datami_cnty_anno;lengthfunction color $ 8;retainxsys ysys'2'color 'black'size 'a'fx fy function; (where=(state=26));bycounty segment; ;function = 'MOVE'; FX = X; FY = Y;end;else iffunction ^= ' 'thendo;ifX =.

6 Thendo;X=FX; Y=FY; output; function= ' '; end;elsefunction = 'DRAW';end;iffunction ^= ' 'thendo;output; ;X = FX; Y = FY; output; end;end;run; 2 means that the annotate coordinate system will be the same as the map, so they line the color and size of the line drawnDraw annotation after the mapRetain first X and first Y to connect the last point of each segment back to the firstSIMPLY PROJECT THE ANNOTATE DATA SET AND MAP? *simply project*/proc gprojectdata=mi_cnty_annoout=anno_county _prjdupok;idcounty;run;/*and map!*/proc gmapdata=zipcovgmap=mi_zshp_prjannotate= anno_county_prj;idzcta5ce10;choroizcovg / nolegend;formatizcovgcovgfmt.

7 ;run;quit;But they don t line up!IT TAKES A FEW STEPS TO FIX *1. convert eastlong degrees to westlong radians in ZCTA data*/datami_zshp_wr;setmi_zshp;x=atan(1 )/45* -1*x;y=atan(1)/45* y;run;/*2. add a flag to the county annotate dataset*/dataanno_county_flag;setmi_cnty _anno;anno_flag = 1;run;/*3. combine the ZCTA and the county annotate datasets*/datazshp_countyanno;setmi_zshp _wr anno_county_flag;run;/*4. project the datasets together*/proc gprojectdata=zshp_countyanno radians westlongout=zshp_countyanno_prjdupok;idz cta5ce10;run;/*5. split the projected data apart*/datazshp_prj countyanno_prj;setzshp_countyanno_prj;if anno_flag = 1then outputcountyanno_prj;else outputzshp_prj;run;/*6.

8 Make the map*/proc gmapdata=zipcovgmap=zshp_prjannotate=cou ntyanno_prj;idzcta5ce10;choroizcovg / nolegend;formatizcovgcovgfmt.;run;quit;A ZIP code MAP WITH COUNTY BORDERS!Counties and zip codes line up!(Can you see the county lines?)What about cities?4. ADD CITY LABELSCREATE AN ANNOTATE DATASET FOR LABELS dataanno_cities; lengthfunction color $8;retainxsys ysys'2'color 'orange'position '5'size 'a'x y function style text; (where=(state=26));lengthfunction color $8;/*convert westlong degrees to westlong radians */x=atan(1)/45* long;y=atan(1)/45* lat;anno_flag=2;function='label';style=' garamond amt/bold'; text=trim(left(city)).

9 Ifcity in ('Detroit','Grand Rapids','Warren','Lansing','AnnArbor', 'Flint','Kalamazoo','Marquette','Sault Sainte Marie', Escanaba ,'Menominee','Muskegon','Pontiac','Sagin aw','Traverse City',Ludington','Harbor Springs','Houghton','Lapeer','Jackson', 'Berrien Springs','Port Huron','Flint ,'Manistee','Grayling , 'Monroe , Owosso );run;COMBINE, PROJECT, SEPARATE/*combine, project, and separate*/datazshp_county_city;setmi_zsh p_wr anno_county_flag anno_cities;run;proc gprojectdata=zshp_county_cityout=zshp_co unty_city_prjdupok;idzcta5ce10;run;datam i_zshp anno_county anno_cities;setzshp_county_city_prj;ifan no_flag = 1then outputanno_county;else ifanno_flag = 2then outputanno_cities;else outputmi_zshp;run;MAKE THE MAPproc gmapdata=zipcovgmap=zshp_prjannotate=ann o_county;idzcta5ce10;choroizcovg / nolegend anno=anno_cities;formatizcovgcovgfmt.

10 ;run;quit;5. TWEAKS AND FINAL TOUCHESGRAPHICS OPTIONSIf you specify GOPTIONS (graphics options), they will override the default are global You can put them anywhere in your SAS program For them to affect output from a procedure they must execute before the procedureGOPTIONS are additive The graphics option remains in effect until you specify the option again in another GOPTIONS statement Use RESET= to reset the values, or end the SAS sessionSPECIFY THE GRAPHICS OPTIONS/* set goptions and produce map */goptions reset= all;*fill patterns for the map areas (sequentially increasing shades of green);pattern1 v=msc=cxe8edd5;pattern2 v=msc=cxbde57a;pattern3 v=msc=cx749938;pattern4 v=msc=cx264c14;*format titles and footnote;title font='Times New Roman'height= '43133142 Coverage by Zip code , 2016';title2 font='Times New Roman'height= 2'Children aged 19 through 35 Months';footnote font='Times New Roman'height= 'For MSUG Meeting';*specify parameters for the legend.


Related search queries