Announcement

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

  • -geoplot- Problem in doing a map with municipal level data

    Hi everyone,

    I would like to use the command -geoplot- at the municipal level in Spain. However, I obtained a very ugly graph, and I don't know why.
    Previously, I used this command to Provinces data, and it works well.

    But now, I don't understand what is going on.
    Here is my code:

    Code:
    *******Map at the municipal level:
    
    global stata "C:/Users/miduarte/Desktop/Ongoing_Projects/test_HolaLuz_Data/New_dataset_15112023/stata"
    global export_geopath "C:/Users/miduarte/Desktop/Ongoing_Projects/test_HolaLuz_Data/New_dataset_15112023/stata/1_export_contratos/data/mapping_data/lineas_limite/SHP_ETRS89"
    
    spshape2dta "${export_geopath}/recintos_autonomicas_inspire_peninbal_etrs89/recintos_autonomicas_inspire_peninbal_etrs89.shp", replace saving(Spain_auton)
    spshape2dta "${export_geopath}/recintos_provinciales_inspire_peninbal_etrs89/recintos_provinciales_inspire_peninbal_etrs89.shp", replace saving(Spain_provinc)
    spshape2dta "${export_geopath}/recintos_municipales_inspire_peninbal_etrs89/recintos_municipales_inspire_peninbal_etrs89.shp", replace saving(Spain_municip)
    
    spshape2dta "${export_geopath}/recintos_municipales_inspire_peninbal_etrs89/PCODE_2020_PT_SH.shp", replace saving(Spain_postalcodes)
    
    
    clear all
    cd ${export_geopath}
    
    use Spain_postalcodes, clear
    drop if CNTR_ID !="ES"
    sort POSTCODE
    rename POSTCODE sp_zipcode_str
    save Spain_postalcodes.dta, replace
    
    
    
    *1)Creation of Provincias limits
    geoframe create Spain_provinc, replace
    geoframe describe Spain_provinc    
    
    *2)Creation of Municipal limits
    geoframe create Spain_postalcodes, replace
    geoframe describe Spain_postalcodes    
    
    *3)Some data cleaning, if needed
    geoframe describe Spain_postalcodes_shp
    
    merge 1:1 sp_zipcode_str using `house_info_munic', keep(match) nogenerate
    save Spain_postalcodes, replace
    
    
    *4)Creation of CCAA limits
    geoframe create Spain_auton
    geoframe describe Spain_auton_shp
    
    *5)Creation of collapse connexion
    geoframe create "${stata}/1_export_contratos/data/mapping_data/house_info_collapse_municipalities", replace
    geoframe describe house_info_collapse_municipaliti
    
    
    geoplot ///
        (area Spain_postalcodes obs_by_zipcode_house_mun, color(tableau)) ///
        (line Spain_provinc, lwidth(0.4)) ///
        , tight legend(pos(9))
    My graph, where the colours have nothing to do with the data!
    Click image for larger version

Name:	Geoplot_Spain_Graph.png
Views:	1
Size:	72.4 KB
ID:	1734221




    Please, I need your help.
    Thank you so much in advance.

    Best,
    Michael

    Edit: By the way, is there a form I can put the Canary Islands next to my main map please, like a small nice box with Canary Islands near to the Iberian Peninsula, please? Thank you.

  • #2
    To me this looks like frame Spain_postalcodes only contains point data (e.g. centroids) and no data on shapes. Applying layer type area to point data will lead to funny results. You need to make sure that a shape frame containing the polygons of the relevant areas is linked to the Spain_postalcode frame.

    Comment


    • #3
      Hi Ben Jann,

      Thank you so much for your help and time !
      Best regards,

      Michael

      Comment

      Working...
      X