Announcement

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

  • Using the geoframe command to link shapefiles with data on area-level attributes

    I am using Stata version 19.5 for Windows

    I am trying to use geoframe to prepare data for geoplot in Stata, to graph zip codes in two Missouri counties, shaded by the percentage of adults in poverty.

    I was able to use the spshape2dta command to import the shapefile into Stata format

    Code:
    spshape2dta "C:/Users/garthr/Documents/Garth/GRANTS/__EH/GTH/Geocoding/shapefiles/ZCTA/stl_city_county_zips_shape", replace saving(boundaries)
    
    
    (importing .shp file)
    (importing .dbf file)
    (creating _ID spatial-unit id)
    (creating _CX coordinate)
    (creating _CY coordinate)
    
    file boundaries_shp.dta created
    file boundaries.dta created


    I was then able to use geoframe to create frames for the shapefile:

    Code:
    geoframe create boundaries, replace
    
    (creating frame boundaries from boundaries.dta)
    (creating frame boundaries_shp from boundaries_shp.dta)
    
    Frame name: boundaries [make current]
    Frame type: attribute
    Feature type: <none>
    Number of obs: 78
    Unit ID: _ID
    Coordinates: _CX _CY
    Linked shape frame: boundaries_shp
    .
    Next, I created a geoframe for the zip code level poverty data. The Stata dataset includes a 5-character zip code identifier (geoid), poverty level (pov_cat), and centroid info (longitude, latitude)

    Code:
    geoframe create poverty, noshp type(attribute) coordinates(longitude latitude) replace
    
    (creating frame poverty from poverty.dta)
    
    Frame name: poverty [make current]
    Frame type: attribute
    Feature type: <none>
    Number of obs: 118
    Unit ID: <none>
    Coordinates: longitude latitude
    Linked shape frame: <none>
    I have not been able to figure out how to link these files together for graphing with geoplot, I experimented with
    geoframe link, copy and spjoin but could not figure how to do this.

    I confess that I am brand new to geoframe. Any help would be much apprecated.

    Thanks, Garth

  • #2
    I have not done a lot with geoframe but:

    1. Assuming you have a common identifier between boundaries.dta and poverty.dta (such as geoid), you could either

    a) merge poverty.dta into boundaries.dta in the usual Stata way, or
    b) use frame and geoframe commands, e.g. geoframe copy

    Have a look at Ben Jann 's recent presentation on geoplot here:
    https://repec.sowi.unibe.ch/varia/ge...ssels-2025.pdf

    See especially slides 23-25. It looks like he is doing something similar to what you want to do.

    2. If there is no common identifier but you have the zip code centroids in your poverty dataset, you could try a spatial join using geoframe spjoin or geoframe collapse.

    Comment

    Working...
    X