[R-sig-Geo] write.nb.gal doesn't include correct ID
Roger Bivand
Roger.Bivand at nhh.no
Mon Jul 12 14:25:40 CEST 2010
On Mon, 12 Jul 2010, Roger Bivand wrote:
> On Thu, 8 Jul 2010, Chris Fowler wrote:
>
>> I am trying to write a rather large neighborhood list to a .gal file using
>> the following code
>> write.nb.gal(Q1.nb, "Map
>> Data/subWeights.gal",oldstyle=FALSE,shpfile="submap.shp",ind="ind")
>>
>> where ind is an array of numbers representing FIPS codes at the census
>> tract level (I also tried it using "STFID" which is the same data as a
>> column in the shapefile submap.shp) while I don't get any errors, my .gal
>> file uses the sequential id number from the shapefile (a meaningless 1 to n
>> number assigned by ArcGIS in the creation of the shapefile). I have tried
>> (in ArcGIS) converting the number assigned by ArcGIS to my FIPS codes using
>> Field Calculator, but this doesn't seem to change anything. My concern is
>> that the problem is perhaps the length of the FIPS codes which are 10 or 11
>> digits each?
>>
>> Is there something that I am missing that will allow me to use the more
>> meaningful FIPS codes in the gal file?
>
>
> You must include more of your workflow. I suspect that the correct values are
> not being set when the "nb" object is created (synax and argument names may
> vary between functions). Please also explain which other software you are
> using - ArcGIS is by no means available to everybody, I for example have no
> access to this product.
>
> Work from a canned example, such as:
>
> library(spdep)
> example(nc.sids)
> nbs <- poly2nb(nc.sids, row.names=nc.sids$CNTY_ID)
> writeSpatialShape(nc.sids, "nc_sids.shp")
> write.nb.gal(nbs, "nc_sids.gal", oldstyle=FALSE, shpfile="nc_sids.shp",
> ind="CNTY_ID")
By the way, these files read correctly in OpenGeoDa (here 0.9.8.14,
Windows binary version running under Wine on Linux).
Roger
>
> and explain again what the problem is. By the way, Arc typically assigns a
> FID which is 0-based, the 1-based indices are the default in functions making
> "nb" objects when no alternative is given, so your analysis is more likely
> guessing than actually what is happening. Note that you may also run into
> problems with apparently numeric identifiers (like some FIPS) that begin with
> "0", you'll have to feel your way there.
>
> Hope this helps,
>
> Roger
>
>>
>> Thanks,
>>
>> Chris Fowler
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list