Announcement

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

  • Multiple point layers with spmap

    Dear Stata Community,

    I have a problem combining different point layers from the same file in one graph. I am using Stata 14 with the user written command "spmap".

    I have a dataset which includes coordinates for each single project, coordinates of their projectwise mean centers and their yearwise mean centers. Additionally I have the attribute dataset, obtained from the shapefile of the country, including information about average district population estimates and district capitals with their coordinates.

    I want to obtain two graphs: one with District Capitals, Single Projects and Yearly Mean Centers and another one with District Capitals, Single Projects and Project Mean Centers. Both maps should also include the information about the population estimate.

    These are the four maps which I want to combine to obtain two at the end.
    Click image for larger version

Name:	CompleteMap.png
Views:	1
Size:	85.3 KB
ID:	1370242

    Additionally, it would be great to include several legends explaining population size (as already included in the graph), size of single projects, size of project mean centers and yearly mean centers in one graph.

    Code:
    Code:
    /*District Capitals Map*/
    
    use "DRCongo_attr.dta", clear
    replace labeldistance_x=INSIDE_X+1.3
    replace labeldistance_y=INSIDE_Y+3
    spmap AVG_UN_E using "DRCongo_coord.dta", id(_ID) legend(position(7)) ///
    clnumber(5) clmethod(quantile)  fcolor(Blues) ocolor(black) osize(thin)  ///
    point(x(INSIDE_X) y(INSIDE_Y) size(*0.8) fcolor(white) ocolor(black) osize(*0.01)) ///
    label(x(labeldistance_x) y(INSIDE_Y) label(DIST_CAP) size(*0.5) position(0 6) length(21)) ///
    title(District Capitals) name(DistrictCapitals)
    graph export "DistrictCapitals.png", as(png) replace
    
    /*Singel Project Map*/
    
    use "DRCongo_attr.dta", clear
    spmap AVG_UN_E using "DRCongo_coord.dta", id(_ID) legend(position(7)) ///
    clnumber(5) clmethod(quantile) fcolor(Blues) ocolor(black) osize(thin)  ///
    point(data("DRC_Data.dta") x(x) y(y) size(*0.1) proportional(amount) fcolor(black) ocolor(black)     osize(*1))  ///
    title (Single Projects) name(SingleAidProjects)
    graph export "SingleProjects.png", as(png) replace
    
    /*Yearly Mean Centers Map*/
    use "DRCongo_attr.dta", clear
    spmap AVG_UN_E using "DRCongo_coord.dta", id(_ID) legend(position(7)) ///
    clnumber(5) clmethod(quantile) fcolor(Blues) ocolor(black) osize(thin)  ///
    point(data("DRC_Data.dta") x(y_mean_center_x) y(y_mean_center_y) proportional(y_mean_center_z)size(*0.5) fcolor(gold) ocolor(gold) osize(*0.01)) ///
    title(Yearly Mean Centers) name(YearlyMeanCenters)
    graph export "YearlyMeanCenters.png", as(png) replace
    
    /*Project Mean Centers Map*/
    use "DRCongo_attr.dta", clear
    spmap AVG_UN_E using "DRCongo_coord.dta", id(_ID) legend(position(7)) ///
    clnumber(5) clmethod(quantile)  fcolor(Blues) ocolor(black) osize(thin)  ///
    point(data("DRC_Data.dta") x(p_mean_center_x) y(p_mean_center_y) proportional(p_mean_center_z)size(*0.3) fcolor(green) ocolor(green) osize(*0.01)) ///
    title(Project Mean Centers) name(ProjectMeanCenters)
    graph export "ProjectMeanCenters.png", as(png) replace
    Is this even possible with spmap in stata?
    Thanks a lot.




  • #2
    Dear Savas,
    legend apart, with some data management it should be possible. The proper use of suboption by() of option point() allows you to specify as many point layers as you like. Full details in the spmap help file.
    Best wishes,
    Maurizio

    Comment


    • #3
      Maurizio Pisati,
      Trying to revive an old thread here to get a clarification on your last response. When you say, "legend apart" in #2, do you mean that it is not possible to include a legend for each distinct point layer? Also, do you have a working example I can look at? I have read the spmap helpfile multiple times and I am still not entirely sure how I can manage to get distinct colors, shapes, and properties (e.g. proportional and fixed sizes) for each layer in the same graph.
      All the best,
      Alvaro

      Comment


      • #4
        Maybe this can help

        https://www.techtips.surveydesign.co...iple-variables

        Comment

        Working...
        X