On Fri, 8 Jan 2021, Allin Cottrell wrote:
On Fri, 8 Jan 2021, Sven Schreiber wrote:
> Am 08.01.2021 um 15:22 schrieb Stefano:
>> I have a little feature request inspired by the new geomapping function.
>> Assume a spatial dataset including info from a shape file. Now we can
>> easily produce maps, but to carry out spatial autocorrelation and
>> spatial regression analysis we need a spatial weight matrix. Considering
>> that all the coordinates info is included in the shape files, it would
>> be nice to be able to recover the coordinates of the centroids of the
>> units as an extra pair of variables. Then distance-based spatial weight
>> matrices can be easily constructed by the user with his preferred
>> formula (or using a contributed function taking the series with the
>> coordinates as inputs - I can volunteer for that, it'd be at most 10
>> lines of code :-) )
>> bye
>> Stefano
>
> Hi, I like the idea but at first sight it looks like a job for a
> (contributed) hansl function (package). Also, what's the consensus way
> of deriving the "centroid" from a polygon?
Yep, nice idea. Unfortunately one further difficulty: the geographical units
of interest in a geojson or shape file may be composed of multiple polygons.
However, I think the existing function geoplot_translate_feature() in
geoplot.inp might contain some helpful code.
In truth, the GeoJSON format also provides an object type that we
currently ignore, that is the "point" type (see
https://tools.ietf.org/html/rfc7946#section-3.1.2). It is possible that
some maps out there come already equipped with "reference points"
(centroids, or capitals, or whatever) that one could conceivably use for
the purpose of computing distances; however, figuring out how to use that
information is by no means a trivial task.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------