Announcement

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

  • Spatial Dataset Not Valid Base Map Yielding SPMAP Issue

    Hi all,

    Below are spatial data for Switzerland, which I downloaded as shp and then converted to .dta:
    Code:
    shp2dta using "$data/ch_100km.shp", database(CHE.dta) coor(CHEcoor.dta) genid(_ID) replace
    
    use "$data/ch_100km_shp.dta", clear
    flag was coded to determine any duplicates, which have all been deleted:
    Code:
    bys _ID _X _Y: keep if _N==_n
    
    g flag=cond(_ID[_n]==_ID[_n-1] & _X[_n]==_X[_n-1] & _Y[_n]==_Y[_n-1],1,0)
    When I try to run the following,
    Code:
    spmap using CHE.dta, id(_ID) poly(data(CHE.dta) fcolor(red))
    I get the error message "File CHE.dta is not a valid basemap dataset", which I really do not understand as in this dataset, it is the case that _ID uniquely identifies the polygons making up the base map.

    I may have made a big mistake somewhere. Could someone let me know where I've gone wrong?

    Code:
    clear
    input byte _ID double(_X _Y) float flag
     1 3900000 2500000 0
     1 3900000 2600000 0
     1 4000000 2500000 0
     1 4000000 2600000 0
     1       .       . 0
     2 4000000 2500000 0
     2 4000000 2600000 0
     2 4100000 2500000 0
     2 4100000 2600000 0
     2       .       . 0
     3 4000000 2600000 0
     3 4000000 2700000 0
     3 4100000 2600000 0
     3 4100000 2700000 0
     3       .       . 0
     4 4000000 2700000 0
     4 4000000 2800000 0
     4 4100000 2700000 0
     4 4100000 2800000 0
     4       .       . 0
     5 4100000 2500000 0
     5 4100000 2600000 0
     5 4200000 2500000 0
     5 4200000 2600000 0
     5       .       . 0
     6 4100000 2600000 0
     6 4100000 2700000 0
     6 4200000 2600000 0
     6 4200000 2700000 0
     6       .       . 0
     7 4100000 2700000 0
     7 4100000 2800000 0
     7 4200000 2700000 0
     7 4200000 2800000 0
     7       .       . 0
     8 4200000 2500000 0
     8 4200000 2600000 0
     8 4300000 2500000 0
     8 4300000 2600000 0
     8       .       . 0
     9 4200000 2600000 0
     9 4200000 2700000 0
     9 4300000 2600000 0
     9 4300000 2700000 0
     9       .       . 0
    10 4200000 2700000 0
    10 4200000 2800000 0
    10 4300000 2700000 0
    10 4300000 2800000 0
    10       .       . 0
    11 4300000 2500000 0
    11 4300000 2600000 0
    11 4400000 2500000 0
    11 4400000 2600000 0
    11       .       . 0
    12 4300000 2600000 0
    12 4300000 2700000 0
    12 4400000 2600000 0
    12 4400000 2700000 0
    12       .       . 0
    13 4300000 2700000 0
    13 4300000 2800000 0
    13 4400000 2700000 0
    13 4400000 2800000 0
    13       .       . 0

  • #2
    The shape file is what contains coordinates - in your case "CHEcoor.dta". So you want

    Code:
    spmap using CHEcoor.dta, ...
    Don't interfere with the shape file in any kind of way.
    Last edited by Andrew Musau; 18 Aug 2023, 02:31.

    Comment


    • #3
      Thanks Andrew!

      Comment

      Working...
      X