Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Variable id not found in a spmap command

    Hello Stata users;

    I'm working with some mapping data, my goal is to draw the map of the French city of Marseille by hoods ("quartiers" in French). After uploading the shapefile with extension files .shp .shx .dbf .mif and transforming those files using the shp2dta command like so: shp2dta using quartiers_marseille, database(mardb) coordinates(marcoord) genid(id) gencentroids(centroids)
    I've tried using the spmap to draw the map using the command: spmap using marcoord, id(id)
    But I've got the following error:
    variable id not found
    (error in option id())
    r(111);

    Any help please on what happened? I've tried to write my commands in the right way, but it didn't work.

    I put both "marcoord" and "mardb" datasets in here:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int id float(x_centroids y_centroids) str5 DEPCO str27 NOM_CO str20 NOM_QUA
      1 5.376901 43.29786 "13201" "Marseille 1er Arrondissemen" "BELSUNCE"            
      2 5.383356 43.29871 "13201" "Marseille 1er Arrondissemen" "CHAPITRE"            
      3 5.379644 43.29749 "13201" "Marseille 1er Arrondissemen" "NOAILLES"            
      4 5.375418 43.29458 "13201" "Marseille 1er Arrondissemen" "OPERA"               
      5 5.388295 43.30672 "13201" "Marseille 1er Arrondissemen" "SAINT CHARLES"       
      6 5.385136  43.2947 "13201" "Marseille 1er Arrondissemen" "THIERS"              
      7 5.357541 43.32348 "13202" "Marseille 2e Arrondissemen"  "ARENC"               
      8 5.371046 43.30347 "13202" "Marseille 2e Arrondissemen"  "GRANDS CARMES"       
      9 5.367668 43.29829 "13202" "Marseille 2e Arrondissemen"  "HOTEL DE VILLE"      
     10 5.366148  43.3019 "13202" "Marseille 2e Arrondissemen"  "LA JOLIETTE"         
     11 5.386287 43.31004 "13203" "Marseille 3e Arrondissemen"  "BELLE DE MAI"        
     12 5.377646   43.305 "13203" "Marseille 3e Arrondissemen"  "SAINT LAZARE"        
     13  5.37654 43.31624 "13203" "Marseille 3e Arrondissemen"  "SAINT MAURON"        
     14 5.372447 43.30923 "13203" "Marseille 3e Arrondissemen"  "LA VILETTE"          
     15 5.405298 43.30001 "13204" "Marseille 4e Arrondissemen"  "LA BLANCARDE"        
     16  5.40401 43.31058 "13204" "Marseille 4e Arrondissemen"  "LES CHARTREUX"       
     17 5.396551 43.31133 "13204" "Marseille 4e Arrondissemen"  "CHUTES LAVIE"        
     18 5.396853 43.30347 "13204" "Marseille 4e Arrondissemen"  "CINQ AVENUES"        
     19 5.398931 43.28808 "13205" "Marseille 5e Arrondissemen"  "BAILLE"              
     20 5.393495 43.29639 "13205" "Marseille 5e Arrondissemen"  "LE CAMAS"            
     21 5.392835 43.28997 "13205" "Marseille 5e Arrondissemen"  "LA CONCEPTION"       
     22  5.40739  43.2939 "13205" "Marseille 5e Arrondissemen"  "SAINT PIERRE"        
     23 5.383463 43.28275 "13206" "Marseille 6e Arrondissemen"  "CASTELLANE"          
     24 5.387746 43.28378 "13206" "Marseille 6e Arrondissemen"  "LODI"                
     25 5.385843 43.29537 "13206" "Marseille 6e Arrondissemen"  "NOTRE DAME DU MONT"  
     26 5.374393 43.28767 "13206" "Marseille 6e Arrondissemen"  "PALAIS DE JUSTICE"   
     27 5.380224  43.2923 "13206" "Marseille 6e Arrondissemen"  "PREFECTURE"          
     28 5.375741 43.28167 "13206" "Marseille 6e Arrondissemen"  "VAUBAN"              
     29 5.361489  43.2798 "13207" "Marseille 7e Arrondissemen"  "BOMPARD"             
     30 5.352798  43.2818 "13207" "Marseille 7e Arrondissemen"  "ENDOUME"             
     31 5.303927 43.27582 "13207" "Marseille 7e Arrondissemen"  "ENDOUME"             
     32 5.358453 43.29119 "13207" "Marseille 7e Arrondissemen"  "LE PHARO"            
     33 5.368083 43.27603 "13207" "Marseille 7e Arrondissemen"  "ROUCAS BLANC"        
     34 5.361599 43.28827 "13207" "Marseille 7e Arrondissemen"  "SAINT LAMBERT"       
     35 5.368612 43.29188 "13207" "Marseille 7e Arrondissemen"  "SAINT VICTOR"        
     36 5.380628  43.2546 "13208" "Marseille 8e Arrondissemen"  "BONNEVEINE"          
     37 5.365038 43.20957 "13208" "Marseille 8e Arrondissemen"  "LES GOUDES"          
     38 5.365876 43.23077 "13208" "Marseille 8e Arrondissemen"  "MONTREDON"           
     39 5.380263 43.27489 "13208" "Marseille 8e Arrondissemen"  "PERIER"              
     40 5.374781 43.26645 "13208" "Marseille 8e Arrondissemen"  "LA PLAGE"            
     41 5.380114 43.24037 "13208" "Marseille 8e Arrondissemen"  "POINTE ROUGE"        
     42 5.392333 43.27681 "13208" "Marseille 8e Arrondissemen"  "LE ROUET"            
     43 5.389297 43.27124 "13208" "Marseille 8e Arrondissemen"  "SAINT GINIEZ"        
     44 5.391942 43.25717 "13208" "Marseille 8e Arrondissemen"  "SAINTE ANNE"         
     45 5.383745 43.24564 "13208" "Marseille 8e Arrondissemen"  "VIELLE CHAPELLE"     
     46 5.425403 43.22423 "13209" "Marseille 9e Arrondissemen"  "LES BAUMETTES"       
     47 5.419815   43.258 "13209" "Marseille 9e Arrondissemen"  "LE CABOT"            
     48 5.498749 43.24941 "13209" "Marseille 9e Arrondissemen"  "CARPIAGNE"           
     49 5.405588 43.25027 "13209" "Marseille 9e Arrondissemen"  "MAZARGUES"           
     50 5.432154 43.25477 "13209" "Marseille 9e Arrondissemen"  "LA PANOUSE"          
     51 5.443738 43.23008 "13209" "Marseille 9e Arrondissemen"  "LE REDON"            
     52 5.400274 43.22258 "13209" "Marseille 9e Arrondissemen"  "SORMIOU"             
     53 5.405945 43.26515 "13209" "Marseille 9e Arrondissemen"  "SAINTE MARGUERITE"   
     54 5.480592 43.22711 "13209" "Marseille 9e Arrondissemen"  "VAUFREGES"           
     55 5.405954 43.27883 "13210" "Marseille 10e Arrondissemen" "LA CAPELETTE"        
     56 5.396543 43.28426 "13210" "Marseille 10e Arrondissemen" "MENPENTI"            
     57 5.419351 43.28088 "13210" "Marseille 10e Arrondissemen" "PONT DE VIVAUX"      
     58 5.439543 43.27478 "13210" "Marseille 10e Arrondissemen" "SAINT LOUP"          
     59 5.434581 43.26831 "13210" "Marseille 10e Arrondissemen" "SAINT TRONC"         
     60 5.414375  43.2887 "13210" "Marseille 10e Arrondissemen" "LA TIMONE"           
     61 5.495137 43.30434 "13211" "Marseille 11e Arrondissemen" "LES ACCATES"         
     62 5.478012 43.26869 "13211" "Marseille 11e Arrondissemen" "LA BARASSE"          
     63 5.512353 43.30611 "13211" "Marseille 11e Arrondissemen" "LES CAMOINS"         
     64 5.524814 43.30146 "13211" "Marseille 11e Arrondissemen" "EOURES"              
     65 5.500752 43.27398 "13211" "Marseille 11e Arrondissemen" "LA MILLIERE"         
     66 5.438583 43.29194 "13211" "Marseille 11e Arrondissemen" "LA POMME"            
     67 5.463475 43.28379 "13211" "Marseille 11e Arrondissemen" "SAINT MARCEL"        
     68 5.502676 43.29027 "13211" "Marseille 11e Arrondissemen" "SAINT MENET"         
     69 5.510454 43.31458 "13211" "Marseille 11e Arrondissemen" "LA TREILLE"          
     70 5.451209 43.28072 "13211" "Marseille 11e Arrondissemen" "LA VALBARELLE"       
     71  5.48202 43.30186 "13211" "Marseille 11e Arrondissemen" "LA VALENTINE"        
     72 5.446886 43.30135 "13212" "Marseille 12e Arrondissemen" "LES CAILLOLS"        
     73 5.430836 43.30269 "13212" "Marseille 12e Arrondissemen" "LA FOURRAGERE"       
     74 5.424855 43.31754 "13212" "Marseille 12e Arrondissemen" "MONTOLIVET"          
     75 5.417419 43.30507 "13212" "Marseille 12e Arrondissemen" "SAINT BARNABE"       
     76 5.422461 43.29524 "13212" "Marseille 12e Arrondissemen" "SAINT JEAN DU DESERT"
     77 5.442114 43.31341 "13212" "Marseille 12e Arrondissemen" "SAINT JULIEN"        
     78 5.465236 43.31084 "13212" "Marseille 12e Arrondissemen" "LES TROIS LUCS"      
     79 5.441883 43.34846 "13213" "Marseille 13e Arrondissemen" "CHATEAU-GOMBERT"     
     80 5.445263 43.33598 "13213" "Marseille 13e Arrondissemen" "LA CROIX ROUGE"      
     81 5.414587 43.32478 "13213" "Marseille 13e Arrondissemen" "MALPASSE"            
     82 5.454298 43.36347 "13213" "Marseille 13e Arrondissemen" "LES MEDECINS"        
     83 5.422811 43.36702 "13213" "Marseille 13e Arrondissemen" "LES MOURETS"         
     84 5.449547 43.32539 "13213" "Marseille 13e Arrondissemen" "LES OLIVES"          
     85 5.439467  43.3746 "13213" "Marseille 13e Arrondissemen" "PALAMA"              
     86 5.428925 43.33022 "13213" "Marseille 13e Arrondissemen" "LA ROSE"             
     87 5.415683 43.33308 "13213" "Marseille 13e Arrondissemen" "SAINT JEROME"        
     88 5.405382   43.322 "13213" "Marseille 13e Arrondissemen" "SAINT JUST"          
     89 5.423645 43.34607 "13213" "Marseille 13e Arrondissemen" "SAINT MITRE"         
     90 5.377398 43.33549 "13214" "Marseille 14e Arrondissemen" "LES ARNAVAUX"        
     91 5.385315 43.32094 "13214" "Marseille 14e Arrondissemen" "BON SECOURS"         
     92 5.376554 43.32684 "13214" "Marseille 14e Arrondissemen" "LE CANET"            
     93 5.405933 43.35743 "13214" "Marseille 14e Arrondissemen" "LE MERLAN"           
     94 5.395409 43.32689 "13214" "Marseille 14e Arrondissemen" "SAINT BARTHELEMY"    
     95 5.385281 43.35223 "13214" "Marseille 14e Arrondissemen" "SAINT JOSEPH"        
     96 5.394574 43.34508 "13214" "Marseille 14e Arrondissemen" "SAINTE MARTHE"       
     97 5.377403  43.3618 "13215" "Marseille 15e Arrondissemen" "LES AYGALADES"       
     98 5.368459 43.36633 "13215" "Marseille 15e Arrondissemen" "LES BORELS"          
     99 5.361439 43.33403 "13215" "Marseille 15e Arrondissemen" "LA CABUCELLE"        
    100 5.349664 43.34151 "13215" "Marseille 15e Arrondissemen" "LA CALADE"           
    end
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int _ID double(_X _Y)
    1                  .                  .
    1  5.380856775927551  43.29924078834906
    1 5.3808679158636705  43.29912264625696
    1  5.380876550706992  43.29903335854674
    1  5.380879278538391  43.29900989911447
    1   5.38093171822054  43.29848945863387
    1  5.380962980465962 43.298291675571676
    1  5.381028720436312  43.29785463985826
    1  5.381068981993911  43.29760626005435
    1   5.38085658524801  43.29753534147385
    1  5.380252413519702  43.29731645628707
    1  5.380103581299191  43.29726303575837
    1  5.379316864180179 43.296979767583764
    1   5.37887358436889  43.29680773125176
    1  5.378584653860122  43.29670339405117
    1  5.378234476922681  43.29657790459047
    1   5.37804685627234 43.296510035377956
    1  5.377845472321413 43.296437068843964
    1  5.377811715569122  43.29642521195167
    1   5.37768071547582  43.29638579543205
    1  5.376838144642631  43.29609203911496
    1   5.37607226730925  43.29583528908276
    1   5.37577980191024  43.29573462228314
    1  5.375432395318872  43.29561626296586
    1  5.375266226752961  43.29556051718375
    1   5.37498637047907 43.295466770950966
    1  5.374567763229692  43.29532477447417
    1  5.374424050550532  43.29527573379945
    1  5.374326442372831  43.29571796357636
    1  5.374318001299751 43.295752347887245
    1  5.374301795171229 43.295927298138466
    1  5.374293687287541  43.29596977486435
    1    5.3742869585113  43.29601582117387
    1  5.374264596767553  43.29607121062956
    1  5.374224686151844  43.29617918388846
    1  5.374186200740101  43.29626192665745
    1   5.37411556053764  43.29634177590066
    1   5.37406966096144  43.29639408250734
    1  5.374036858305591 43.296435301752666
    1  5.373642704546531  43.29691734381535
    1  5.372985029344862  43.29773276026976
    1  5.372592627064621  43.29816796164247
    1 5.3717976923959005  43.29915197889027
    1  5.371606568210871 43.299388365634066
    1   5.37195123600601 43.299379901992644
    1  5.372021334054052 43.299376563625756
    1  5.372084795733471  43.29936167123218
    1    5.3721583280502  43.29935195759857
    1  5.372357394253781 43.299338588523774
    1  5.372603019654902  43.29931879716967
    1 5.3731255282224515  43.29929022608277
    1  5.373157803321621  43.29938581442928
    1  5.373179916165051 43.299414127994645
    1  5.373219338300519  43.29944386142308
    1    5.3732993494243  43.29947180358615
    1  5.374239096772743  43.29964105796208
    1 5.3743284390053505 43.299656194783665
    1   5.37445078268696 43.300083694131665
    1  5.374595862726791 43.300584491826754
    1  5.374621429899801  43.30066672767285
    1  5.374681885960781 43.300848094060676
    1  5.374753487657542 43.301060714647775
    1  5.374801234761151  43.30120276141916
    1  5.374809806716381 43.301231372245276
    1  5.374820646862772 43.301285132509676
    1  5.374970197136931 43.301325945181155
    1  5.375020610021952  43.30141303489165
    1  5.374890760859712 43.301611182556364
    1  5.375099312879241  43.30158860039208
    1  5.375246410531822 43.301599767449666
    1 5.3755644792075215 43.301633275927486
    1   5.37599096226882 43.301666200211656
    1 5.3762860930211325  43.30168131135367
    1  5.376241785509122  43.30204137550986
    1  5.376314266592802  43.30206588125746
    1  5.376413610686161  43.30211130574017
    1  5.376614440477421  43.30220327732406
    1  5.376734587243182  43.30227803329276
    1  5.376898981560352  43.30235001614338
    1   5.37727417682698  43.30251365989437
    1  5.377841894686561 43.302773864466175
    1    5.3778782658232  43.30278926387766
    1  5.378665412310241  43.30314093416696
    1  5.378961940990881  43.30327930427418
    1  5.379220910322182 43.303045009931566
    1  5.379332972404442  43.30292374617476
    1  5.379404918824231  43.30284566433166
    1  5.379453769950731  43.30277529069208
    1 5.3794583234701525  43.30276619068037
    1  5.379494039979001  43.30270600592187
    1 5.3795497646795605  43.30259318201516
    1 5.3796847432596415  43.30207182381688
    1  5.379717254529892  43.30199371004588
    1 5.3797485038037305  43.30188502486146
    1   5.37984236226712 43.301561666785666
    1  5.379861887357971  43.30149733856907
    1  5.379883831269712  43.30146175632235
    1  5.379913533096211  43.30143500300737
    1  5.379929092356832 43.301423860689255
    1 5.3799887123896415  43.30140544832417
    end


  • #2
    Looks like Stata can't find the id variable, but you clearly have defined the id variable in the first dataset. That suggests the id variable may not be in memory when you run the spmap command. Which file do you have loaded into memory when you run the command? It should be the mardb loaded into memory, since you ask for the coordinates file with the using command.

    Comment


    • #3
      Daniel Schaefer Thanks for the clarification. Yeah, I guess you were right, I was confused between the "marcoord" and the "mardb" datasets, so I was running the spmap on the dataset that doesn't have the id variable in it. Thanks for the help, I've solved my problem.

      Comment

      Working...
      X