x cd /pub/data/georef/Tools; %let pgm=mogeo_mapsheets; filename pgm "&pgm..sas"; *---Use the plmaps.mocornerpts set which defines the lat-long "bounding obx" coords for all PB pdf maps files for Missouri and the sf1.mogeos set to generate georef.mogeo_mapsheets which is a tool for linking Missouri geographic codes with the appropriate URL/map sheet. J. Blodgett, OSEDA, Oct. 2001. Creates: georef.mogeomaplinks : small set with key linkages: geo_id to map_id, indexed by geo_id georef.mogeos_with_maplinks (view) has geo ids and data from plmaps.cornerpts, including URL. Generates the web reports in /pub/reports/geography/mosf1_pbmaplinks . ---------------------------------------- ---*; *<----See cnvt_cornerpts.sas in plmaps/Tools for details of how input set was created from raw cornerpoints file from Bureau---; libname user '/SAS_temp/userb'; libname georef '/pub/data/georef'; libname plmaps '/pub/plmaps'; libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; /*<=========================Comment out===================================== *---Extract data from the geoheaders that is sub-county and code those first---; data subcogeos; set sf12000.mogeos(keep=sumlev geo_id geocode intptlat intptlon county); where county ne ' ' and sumlev gt '050'; run; proc sort data=subcogeos; by county; run; *---Encoding step: Read the geographic headers data and determine on which map sheet(s) the internal point is located. Points that are on inset maps can be assigned to a "parent" sheet as well as the primary inset sheet.---*; data mogeomaplinks(keep=geo_id map_id cell parentmap_id county sumlev geocode); set subcogeos; by county; length cell $2; label cell='Cell within map'; *--values for this variable are based on a 3 x 3 breakdown of map sheet and we assign it values such as "NW" to indicate "NorthWest" - upper left, "NC" - upper center, "NE" - upper right, "W" - middle left, "C" middle center, "E" middle right, and SW SC and SE for the 3 lower cells-; array _minlat(199) _temporary_; array _minlong(199) _temporary_; array _maxlat(199) _temporary_; array _maxlong(199) _temporary_; *<---Store the extrema coords for all sheets in a county--; array _inset(199) _temporary_; array _mapid(199) _temporary_; array _cellcodes(3,3) $2 _temporary_ ("SW","W ","NW", "S ", "C ", "N ", "SE", "E ", "NE"); if first.county then do; _i=0; do until(allcorners_read); link read_corner; _i + 1; _minlat(_i)=minlat; _maxlat(_i)=maxlat; _minlong(_i)=minlong; _maxlong(_i)=maxlong; _inset(_i)=inset; _mapid(_i)=map_id; end; _ncorners=_i; retain _ncorners; drop _ncorners; file log; put _ncorners ' corner points entries loaded for county ' county $county.; end; *--first.county do group to load cornerpoints data arrays--; *---the extrema and _inset arrays are loaded for the county. Now we take each mogeos obs and try to see which of these "bounding boxes" the internal point for the geo. fits.--; map_id=0; parentmap_id=0; do _i=1 to _ncorners; _inbox = (_minlong(_i) <= intptlon <= _maxlong(_i)) and (_minlat(_i) <= intptlat <= _maxlat(_i)); if _inbox then do; if _inset(_i) then parentmap_id=map_id; map_id=_mapid(_i); _index=_i; *<--save index to table so we can access extrema values when we output and assign cell-; if _inset(_i) then do; link output; return; end; end; end; *--Reaching this point means we have looked for a map sheet and did NOT find it on an inset map. But if we did find it on a regular map that is fine. What we flag here is the case where we did not find it on ANY map-; if map_id <= 0 then do; put '****Error: geocode ' geocode +1 sumlev= geo_id= ' not assigned to any map sheet***'; _nomap+1; if _nomap ge 20 then abort abend; drop _nomap; end; link output; return; output: _nout+1; drop _nout; *--assign the cell variable which further pinpoints the location on the map of the center point using a 3 x 3 division of the map area into a tic-tac-toe division--; _minx=_minlong(_index); _maxx=_maxlong(_index); _cellwidth=(_maxx - _minx) /3; _relx=intptlon - _minx; if _relx < _cellwidth then _ix=1; else if _relx < 2*_cellwidth then _ix=2; else _ix=3; _miny=_minlat (_index); _maxy=_maxlat (_index); _cellwidth=(_maxy - _miny) /3; _rely=intptlat - _miny; if _rely < _cellwidth then _iy=1; else if _rely < 2*_cellwidth then _iy=2; else _iy=3; cell= _cellcodes(_ix,_iy); if _nout le 50 then put / _all_; output; return; read_corner: *---Read data from the plmaps corner points data set for loading into the _temporary_ arrays---; set plmaps.mocornerpts(keep=map_id minlat maxlat minlong maxlong inset county rename=(county=_county) where=(inset ne .) ); by _county; drop _county minlat maxlat minlong maxlong inset; allcorners_read = last._county; return; run; proc sort data=mogeomaplinks out=georef.mogeomaplinks(index=(geo_id) label='Links from mogeos to mocornerpts'); by geo_id; run; *-------------Create the view that will go from the geocode to the URL for the pb map-----------------*; data georef.mogeos_with_maplinks(label="Links sf1.mogeos to pb map URLs")/view=georef.mogeos_with_maplinks; length URL $100; merge '/pub/data/georef/mogeomaplinks'(in=inlinks) '/pub/data/sf12000/mogeos' (in=ingeos) ; by geo_id; if inlinks; _mapid=map_id; set '/pub/plmaps/mocornerpts'(keep=basepath path filename) point=_mapid; URL=basepath||trim(path)||trim(filename)||'#pagemode=none'; label URL='URL of pdf map file at MSDIS'; drop basepath path ; run; proc print data=georef.mogeos_with_maplinks(obs=40 keep=url cell sumlev county geocode); title2 'georef.mogeos_with_maplinks - Selected Variables'; run; *--create the non-block-level subset of mogeos_with_maplinks----; data maplinks(index=(county)); set georef.mogeos_with_maplinks; where sumlev not in ('101','150','140'); if substr(geocode,6,1)='-'; length county $5; county=substr(geocode,1,5); geocode=substr(geocode,7); *--remove the county part-; if '29001' <= county <= '29510'; geocode=tranwrd(geocode,'----','-'); *--replace 4 dashes in geoocode with 1--; run ; ===========================End commented out================================ */ options ls=155; * ods listing close; ods html close; title 'Geographic Reference Report: Linking Geographic Areas to PB Map Series (Online pdf Files)'; title2 'Includes All Sub-County Geography on 2000 Summary File 1 Down to Split Block Group Level'; footnote '
'; %let oseda=http://oseda.missouri.edu; %let mcdcurl=https://mcdc.missouri.edu; %let mcdc=Missouri Census Data Center; footnote2 "