Announcement

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

  • visualise firm location using map

    Dear Users,
    I prepared the point map of firm location (2 headquarters and 5 subsidiaries) using the code below and have two questions. (1) how could I present firm headquarters and subsidiaries differently on the map, say triangles for headquarters and dots for subsidiaries (they are currently all triangles)? (2) Why is the map so small and how could I make it larger? Thank you very much for your time and help. Lynn.

    Code:
    clear
    
    input clon clat
    
    -86.82805 33.527872
    -86.260844 32.331872
    -149.7621 61.1919
    -147.56838 64.81859
    -112.08791 33.494514
    -114.08271 35.285985
    -92.294471 34.766541
    
    end
    
    rename clon _X
    
    rename clat _Y
    
    save location, replace
    
    /*******/
    
    copy "https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_county_500k.zip" "cb_2018_us_county_500k.zip", replace
    
    unzipfile "cb_2018_us_county_500k.zip", replace
    
    shp2dta using cb_2018_us_county_500k, data("us-attr.dta") coord("us-coord.dta") genid(id) replace
    
    use "us-attr.dta", clear
    
    spmap using "us-coord.dta" if STATEFP!="15" & STATEFP!="60" & STATEFP!="66" & STATEFP!="69" & STATEFP!="72" & STATEFP!="78", id(id) point(data("location.dta") x(_X) y(_Y) shape(triangle) size(*0.5) fcolor(red) ocolor(white) osize(vvthin))
    
    graph save Graph.gph, replace

  • #2
    Hi Lynn,

    In order to get different shapes based on whether a location is a headquarters or a subsidiary, you will need a column identifying each observation as such. Here is a possible example:

    Code:
    input clon clat firmtype
    -86.82805 33.527872 1
    -86.260844 32.331872 1
    -149.7621 61.1919 1
    -147.56838 64.81859 1
    -112.08791 33.494514 1
    -114.08271 35.285985 2
    -92.294471 34.766541 2
    end
    Once you have that column, you can modify your code by adding a by() function call inside the point() function call, then listing the shapes, sizes, and colors for the different kinds of points:

    Code:
    spmap using "us-coord.dta" if STATEFP!="15" & STATEFP!="60" & STATEFP!="66" & STATEFP!="69" & STATEFP!="72" & STATEFP!="78", id(id) point(data("location.dta") by(firmtype) x(_X) y(_Y) shape(triangle circle) size(*5 *5) fcolor(red blue) ocolor(white) osize(vvthin))
    Note that I have made the size of each shape much larger in this plot so that they are easy to see.

    As to why the map is so small: the problem is that your projection of the US is wrapping around the world, with most of the US appearing on the left, and the "tail" of Alaska appearing on the right side of the map. You should be able to fix this by manipulating the "extent" of the map. Unfortunately, I haven't been able to find a way to do this with -spmap-. As I said in your last thread, I prefer other specialized software for this kind of problem. I'm wondering if Jared Greathouse has any insight about how to do this.

    Comment


    • #3
      I'm not at my computer, so I've only one question: are all companies on the US mainland?

      I'll look at this in a few when I'm at my laptop

      Comment


      • #4
        No, it looks like 2 locations are in Alaska.

        Comment


        • #5
          Thank you very much, Daniel for the code. It works perfectly.
          @Jared Greathouse there are two firms in Alaska. When Alaska is included, I can see on the far right something which looks like the land belonging to Alaska so Daniel is right (the map becomes much larger when Alaska is excluded). Please have a look and help me with this.
          Many thanks to you both.

          Comment

          Working...
          X