Announcement

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

  • geoplot: select or clip

    I reveived the following private message on statalist:

    In geoplot, I have a map of Brazil (from the IBGE) with 26 states and 5500 municipalities. [...] I want to do my analysis for one state at a time. When I load the map, I have the whole country, but I want eliminate (clip) all the states except the one I'm working on. How can I do that?
    Here's my answer:

    To plot just one state, simply use the if qualifier in geoplot. Example

    Code:
    local url http://fmwww.bc.edu/repec/bocode/i/
    geoframe create regions `url'Italy-RegionsData.dta, id(id) coord(xcoord ycoord) shp(Italy-RegionsCoordinates.dta)
    geoplot (area regions if region=="Umbria", fcolor(AntiqueWhite)) ///
            (label regions region if region=="Umbria") ///
            , tight
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	35.4 KB
ID:	1786355


    Alternatively, you can also use geoframe select to create a frame that contains the data of that state only and then use this frame in geoplot. Example:

    Code:
    frame regions: geoframe select if region=="Umbria", into(Umbria)
    geoplot (area Umbria, fcolor(AntiqueWhite)) ///
            (label Umbria region) ///
            , tight
    (same result as above)

    If you want to generate a plot that clips the surrounding sates, rather than omitting them, you can use geoframe rclip to create a frame with the clipped data. Example:

    Code:
    frame regions: geoframe query bbox if region=="Umbria", pad(30)
    frame regions: geoframe rclip r(limits), into(Umbria2)
    geoplot (area Umbria2, fcolor(AntiqueWhite*.5)) ///
            (area Umbria2 if region=="Umbria", fcolor(AntiqueWhite)) ///
            (label Umbria2 region if region=="Umbria", psty(p2)) ///
            , tight background(water)
    Click image for larger version

Name:	Graph3.png
Views:	1
Size:	47.4 KB
ID:	1786356

    ben
Working...
X