Announcement

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

  • spatial analysis - spgrid error - "block should be at least 1"

    I am trying to conduct spatial point pattern analyses in Stata, and am receiving an error while trying to use the command: spgrid in Stata SE v12.
    The error reads: "block should be at least 1" r(498)

    Here is my code - the error appears when I run the spgrid command:

    shp2dta using StudyAreaBoundaryPolygon, database(studyarea) coordinates(coords) replace

    use coords.dta, clear
    gen id = _n
    spmap using coords.dta, id(id) fcolor(eggshell) split
    save coords, replace

    spgrid using coords.dta, resolution(w500) dots compress unit(meters) cells("cells.dta") ///
    points("points.dta") mapid(spgrid_mapid) replace


    I can't figure out what is wrong… the spmap command correctly draws my study area boundary (which actually consists of 3 polygons) and when I try to use spgrid to generate a two-dimensional grid, the error appears.

    The dataset "coords.dta" contains 4 variables, 1 is basically _n, then there are X and Y coordinates, and the final variable indicates which polygon the coordinates belong to (1, 2, or 3).

    Any ideas?

    I'd like to continue on and use 'spkde' after I create the grid, but am stuck at this step with this error.

    Appreciate any help or ideas…
    ~Karen

    Last edited by Karen H; 29 Aug 2015, 19:26.

  • #2
    My problem was with the "resolution" option… I specified it in meters, but my coordinates were in lat/long. Problem resolved.

    Comment


    • #3
      Hi Karen,
      You're working with spatial econometrics, right?
      Actually, you know give me some idea about how to import weight matrix with format .gwt in STATA?

      Thank you.

      Comment


      • #4
        Hi Karen, what code did you replaced with, can you elaborate a bit more?

        Comment


        • #5
          Hi Karen and other members,

          I have the same problem. Stata displays the following message


          -> Setting up full grid...
          block should be at least 1



          I think that I have coordinates in my data (it shows for _X _Y the following -82.028211 9.1304977). I Would appreciate if you could explain us, how you solve it?

          Thanks

          Comment


          • #6
            Hello everybody. I have had the same problem and I could solve it. Just remove "unit" and "resolution" options and use xdim or ydim. Example:

            spgrid using "coords.dta", xdim(100) ///
            cells("Cells.dta") ///
            points("Points.dta") replace ///
            dots compress

            Comment

            Working...
            X