sql server - Dimension for geozones or Lat & Long in data warehouse -


i have dimplace dimension has name of place (manually entered user) , latitude , longitude of place (automatically captured). since places entered manually same place in there multiple time different names, additionally, 2 distinct places close each other.

we want able analyze mpg between 2 "places" want group them make larger area - i.e. using lat & long put various spellings of 1 location, distinct close locations, in 1 record.

i planning on making new dimension - dimplacegeozone. looking resource loading lat & long values mapped ... something?? maybe postal code, or city name? can find script load common dimensions (like dimtime) - love similar lat & long values in north america?

i've done similar in past... 1 stumbling block hit front 2 locations, straddling border physically closer 2 locations both in same area.

i got around creating "double grid" system causes each location fall 4 areas. way 2 locations share @ least 1 "area" know within range of each other.

here's example, covering of united states...

if object_id('tempdb..#latlngareas', 'u') not null  drop table #latlngareas; go       cte_lat (         select              t.n,             beglatrange = -37.9 + (t.n / 10.0),             endlatrange  = -37.7 + (t.n / 10.0)                     dbo.tfn_tally(1030, 0) t         ),     cte_lng (         select              t.n,             beglngrange = -159.7 + (t.n / 10.0),             endlngrange = -159.5 + (t.n / 10.0)                     dbo.tfn_tally(3050, 0) t         ) select      area_id = row_number() on (order lat.n, lng.n),     lat.beglatrange,      lat.endlatrange,      lng.beglngrange,      lng.endlngrange     #latlngareas     cte_lat lat     cross join cte_lng lng;   select      b3.branch_id,     b3.name,     b3.lat,     b3.lng,     lla.area_id     dbo.contactbranch b3    -- replace dimplace     join #latlngareas lla         on b3.lat between lla.beglatrange , lla.endlatrange         , b3.lng between lla.beglngrange , lla.endlngrange; 

hth, jason


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -