52
ObjectAcontainsEntireObject
B
ObjectAcontainsObjectB
ObjectBwithinObjectA
ObjectAcontainsObjectB
ObjectBwithinObjectA
ObjectBentirelyWithinObjectA
ObjectAintersectsObjectB
ObjectBintersectsObjectA
Ineachcase,objectAcontainsobjectBbecausethecentroidofobjectBisinsidetheboundaryofobject
A.However,inthecasesattheleftandinthemiddle,partofobjectBisoutsidetheboundaryofobject
A.OnlyinthecasetotherightisallofobjectBinsideobjectA.Onlyinthiscasecouldweassert"object
AContainsEntireObjectB"or"ObjectBEntirelyWithinObjectA."Further,ifAcontainsentireB,then
AcontainsB,andIfAisentirelywithinBthenAiswithinB.
MapInfoProfessionalcanperformasimpleContainsorWithincomparisonmorerapidlythanaContains
EntireorEntirelyWithin.Therefore,unlessyouareabsolutelysurethatobjectsarecompletelyinside
otherobjects,youshoulduseContainsandWithinratherthanContainsEntireorEntirelyWithin.
Geographicoperatorsprovideawayofjoiningtables.Whentherearenocolumnsinthetablesonwhich
youcanbaseyourjoin,youcanuseageographicaloperatortospecifythejoin(intheWhereCondition
field).IfyouwanttoperformaquerythatinvolvesbothaCitiestableandaStatestable,youcanjoin
thetablesusingeitherofthefollowingexpressions:
1. Cities.objwithinStates.obj
2. States.objcontainsCities.obj
Ineithercase,MapInfoProfessionalfindsthecitieswithineachstateandthenassociatesarowfora
citywiththerowforthestatethatcontainsit.InthesameSQLSelectquery,youcouldalsouseaggregate
functionstocountthenumberofcitiesperstateortosummarizecity-baseddataonastatewidebasis.
Whenyouhaveatableofcountiesandoneofcustomers,wherecountiesarepolygonsandcustomers
arepoints,youcouldspecifyageographicjoinusingeitherofthefollowinggeographicexpressions:
1. Customer.objwithinCounty.obj
2. County.objcontainsCustomer.obj
Geographicoperatorsareparticularlyusefulinconjunctionwithsubselects.
TheHelpSystemcontainsthisrelatedtopic:
• PerformingSubselects
JoiningTwoorMoreTables
Typically,youstoreyourinformationinseveraldifferenttables.Youhaveyourowndatafiles,andyou
mayalsohavevariousdatabasesofstatisticalinformationthatyoupurchasedfromMapInfoProfessional.
SQLSelectallowsyoutocreaterelationaljoinssothatyoucanbringinformationfromthesevarious
tablestogetherintoasingleresultstable.
Whenyouwanttojointwotables,youmustdeterminewhetheroneofthecolumnsinthefirsttable
containsvaluesthatmatchoneofthecolumnsinthesecondtable.Imaginethatyouhaveatableof
countiesthathasdemographicinformation--thepopulationofpeopleinvariousageranges,ethnicgroups,
andoccupationalcategoriesineachcounty.Youmayalsohaveadatabasecontaininginformationabout
customerorders.Youwanttoexaminethesetwotablesandseeifcertainkindsoforderscomefrom
countieshavingcertaindemographiccharacteristics.Perhapsyouwanttoselectcountiesaccordingto
combinationsofordersanddemographiccharacteristics.Todothisyouhavetobeabletojointhetwo
tables.
Supposethecountiestablecontainsthenameofthecounty.Similarly,oneofthecolumnsintheorder
tablecontainsthenameofthecountyinwhichtheorderoriginated.Thus,thesetwotableshaveone
fieldincommon,thecountyname.MapInfoProfessionalcanusethatcommonfieldtojointhetwotables.
255
MapInfoProfessionalUserGuide
Chapter9:SelectingandQueryingData
71
County
Customer
Order#
Pop_1990
Pop_1980
CountyName
Foster
Francis
478001
27,135
23,789
Foster
Foster
James
478002
34,846
35,456
Williamette
Mason
Wickwire
478003
151,201
147,101
Mason
CountiesTableOrdersTable
WithintheSQLSelectdialogbox,youusetheWhereConditionfieldtotellMapInfoProfessionalhow
tojointhetwotables.TheSQLSelectdialogboxmightlooklikethis:
Select Columns:
*
From Tables:
Counties, Orders
Where Condition:
Counties.CountyName = Orders.County
Theorderofthetablenames(intheFromTablesfield)isimportant.Ifbothtablescontainmapobjects,
theresultstablewillonlyretainthemapobjectsfromthefirsttablelistedintheFromTablesfield.
Furthermore,whenthequeryiscomplete,MapInfoProfessionalautomaticallyselectssomeorallofthe
rowsfromwhichevertableislistedfirstintheFromTablesfield.Thus,intheprecedingexample,MapInfo
ProfessionalwillselectsomeoralloftherowsfromtheCountiestable.Theresultstablewillalsoinclude
datacopiedfromtheOrderstable,buttheOrderstablewillnotbeselectedperse.
Whenyoujointwotables,thenumberofrowsintheresultstabledependsonhowwellthetwotables
matchup.SupposeyouhaveanOrderstablewith10,000rows,andyoujointheOrderstabletothe
Statestable,whichhasfiftyrows.Theresultstablemaycontainasmanyas10,000rows.However,if
someoftherowsintheOrderstablefailtomatchanyoftherowsintheStatestable,theresultstable
willcontainfewerthan10,000rows.Thus,if400oftherowsintheOrderstabledonothaveastate
name(perhapsduetodata-entryerrors),andiftherelationaljoinreliesonthestatename,theresults
tablemayonlycontain9,600rows.
YoucanuseUpdateColumntomodifytheresultsofanSQLSelectmulti-tablejoin.Whenyouwantto
updateacolumninonetablewithinformationfromanothertable,youcan:
1. JointhetableswithSQLSelect.
2. UseUpdateColumnonSelection.Theupdateautomaticallytakeseffectintheappropriatebase
table.
3. Formoreinformation,seePerformingOuterJoinsandUsingtheInstrFunctiontoFindDatainthe
HelpSystem.
FindingDuplicateValuesinaColumn
Oftendataisenteredintotablesbymanydifferentusers.Sometimesdataisrepeated,orthereiscommon
informationinseveraldifferentrecords.Thissectionexplainshowtofindallrowsinatablethat,fora
givencolumn,shareavaluewithanotherrow.ThisisaccomplishedbyperformingtwoSQLSelect
statements.
ThefirstSQLSelectstatementproducesaquerytablewithtwocolumns.Thefirstcolumnisalistofall
uniquevaluesinthedatacolumnandthesecondcolumnliststhenumberoftimesthateachunique
valueoccurs.ThesecondSQLstatementcompareseachdatacolumnvaluewithallrowsintheQuery
tablewherethecountisgreaterthanone.
Inthenextexample,thereisatableEMPLOYEEthathastwocolumnsId_NumandName.
Tofindtheduplicatevalues,performthetwoSQLSelects,modifyingthemwhereindicated.
1. OntheQuerymenu,clickSQLSelectandfillintheSQLSelectdialogbox.
• SelectColumns:ID_Num,Count(*)
• fromTables:EMPLOYEE
• GroupbyColumns:1
MapInfoProfessional12.5
256
QueryingYourDatainMapInfoProfessional
40
• OrderbyColumns:2 desc
• intoTableNamed:Selection
SubstitutethenameofyourdatacolumnforID_NumandthenameofyourtableforEMPLOYEE.The
number1intheGroupByColumnsboxwillgrouptherowbyID_Num(thefirstcolumn).The2Desc
intheOrderbyColumnsboxwillarrangetherecordsindescendingorderbasedonthevaluesin
thecount(*)field(thesecondcolumn).
ThisSQLSelectstatementreturnsaquerytablewithtwocolumns.Thefirstcolumncontainsevery
identificationnumberpossessedbyatleastoneemployee.Thesecondcolumncontainsthenumber
ofemployeesthathavethatidentificationnumber.Therowsaresortedbythenumberofemployees
thathaveeachidnumber(forexample,thecount).
2. OntheQuerymenu,clickSQLSelectandfillinthedialogbox.
Also,changeEMPLOYEEtothenameofyourtableandID_Numtothenameofyourdatacolumn.
Intheexample,theSQLstatementreturnsaquerytablecontainingalloftherowsfromEMPLOYEE
withduplicateddatacolumnvalues.ThewhereconditionselectsallrowsfromEMPLOYEEthathave
anidentificationnumberthatisthesameasoneoftheIDnumbersintheCount_By_IDquerytable.This
sub-selectfindsallidentificationnumbersthatoccurmorethanonce.
CalculatingtheDistancetoaFixedPoint
InMapInfoProfessionalitispossibletocalculatethedistancefromonepointtoanother.Thisexample
showshowtocalculatethedistancefromafixedpointtoeverypointinageocodedtableandstorethe
resultinanothertable.
1. Determinethelocationofthefixedpoint.Tofindthepositionofasymbolonthemap,double-click
thesymbolwiththeSelecttool.Inthisexample,theXvalueis-101.697209andtheYvalueis
35.550036.
2. OntheQuerymenu,clickSQLSelectandfillintheSQLSelectdialogbox,substitutingyourXand
Yvaluesforthevaluesmentionedabove
AsinthepreviousSQLquery,replaceEMPLOYEEwiththenameofyourtable,andLNameandFName
withthenameoftherelevantcolumnfromyourtable.
• SelectColumns:LName, FName, Distance(-101.679209, 35.550036,
CentroidX(obj), CentroidY(obj), "mi") "Dist"
• fromTables:EMPLOYEE
• intoTableNamed:CUSTDIST
3. ClickOK.Theresultingquerytablecontainslastnamesandfirstnamesplusanewcolumncalled
DISTANCEwhichrecordsthedistancebetweenthefixedlocation(-101.697209,36.550036)and
thepointassociatedwitheachrowofthetable.
4. Tosavetheresultsinapermanenttable,ontheFilemenu,clickSaveCopyAs,andsavethe
CUSTDISTtable.
5. ForinstructionsonenteringSQLqueriesusingtheExpertbutton,seetheHelpSystem.
257
MapInfoProfessionalUserGuide
Chapter9:SelectingandQueryingData
24
10
Creating Thematic and Other
Themed Maps
Thematicmappingisapowerfulwaytoanalyzeandvisualizeyourdata.Yougive
graphicformtoyourdatasothatyoucanseeitonamap.Patternsandtrends
thatarealmostimpossibletodetectinlistsofdatarevealthemselvesclearlywhen
youusethematicshadingtodisplaythedataonamap.
YoucancreatethematicmapswithMapInfoProfessionalusingthefollowing
methods:rangesofvalues,graduatedsymbols,dotdensity,individualvalues,
barandpiechartsandcontinuousgrid.Therearealsoseveralvariationsonand
optionswithinthesemethods,suchasbivariatethematicmappingandinflection
point,thatgiveyouevenmorewaystoanalyzeyourdata.
ForclarificationoftheusesofthematicmapsinMapInfoProfessional,seeMapInfo
ProfessionalinActionintheHelpSystem.
TheHelpSystemalsocontainstheserelatedtopics:
• BivariateThematicMapping
• Workingwith3DandPrismMaps
Inthissection:
• MapInfoProfessionalinAction . . . . . . . . . . . . . . . . . . . .260
• UsingThematicMappingtoAnalyzeInformation . . . . .260
• CreatingaThematicMap . . . . . . . . . . . . . . . . . . . . . . . . .273
• ChangingtheDisplayParametersofaMap . . . . . . . . .278
• UpdatingColumnsusingThematicMapping . . . . . . . . .280
• WorkingwithGridSurfaceMaps . . . . . . . . . . . . . . . . . . .286
27
MapInfo Professional in Action
Sinceyouhaveallthetoolsyouneedtomakeeffectiveandusefulmaps,itistimetotalkaboutwhat
makesamapeffectiveanduseful.Whateveryouneedyourmaptosay,whetheritistoconveyinformation,
calculatedistancesbetweenhealthcareprovidersandtheirpatients,orgetacountofthenumberof
customersthatlivewithinagivenradiusofanoutletlocation,MapInfoProfessionalcanhelpyoudothat.
Bymakingselectionsfromyourtable,youcanextractinformationfromsetsandsubsetsofyourdataor
seepatternsanddistributions,gettinganswerstosuchquestionsas:Whichofmycustomersbought
morethan$5000ofequipment?Whichofmycustomersislocatedwithina200mileradiusofmy
warehouse?Whichofmycustomersboughtmorethan$5000ofequipmentandislocatedwithina200
mileradiusofmywarehouse?Formoreonselecting,seeSelectingYourDatainMapInfoProfessional,
andQueryingYourDatainMapInfoProfessional.
MapInfoProfessionalreferstothisgroupingoflikeinformationasthematicmapping.
• Foranexample,seeCanYouGiveMeanExampleintheHelpSystem.
Using Thematic Mapping to Analyze Information
Thematicmappingistheprocessofenhancingyourmapaccordingtoaparticulartheme.Atthe
cornerstoneofthethemeisthedatainyourtable.Themesrepresentyourdatawithshadesofcolor,fill
patterns,symbols,barandpiecharts,andgrids.
WithMapInfoProfessional,youcreatedifferentthematicmapsbyassigningthesecolors,patterns,or
symbolstomapobjectsaccordingtospecificvaluesinyourtable.MapInfoProfessional'sbarandpie
chartsallowyoutomakedatacomparisonsforeachrecord.Gridsallowyoutoseecontinuouschange
ofyourdataacrossanarea.
Thethematicmapfeatureusesawizardmadeupofaseriesofthreedialogboxestohelpyouchoose
thetypeofthematicmapyouwant,thetable(s)andfieldsthatwillbeusedtoconstructthemap,anda
varietyofoptionstocustomizeyourmap.
MapInfoProfessional12.5
260
MapInfoProfessionalinAction
Documents you may be interested
Documents you may be interested