Subscribe to R-sig-geo feed
This is an archive for R-sig-geo, not a forum. It is not possible to post through Nabble - you may not start a new thread nor follow up an existing thread. If you wish to post, but are not subscribed to the list through the list homepage, subscribe first (through the list homepage, not via Nabble) and post from your subscribed email address. Until 2015-06-20, subscribers could post through Nabble, but policy has been changed as too many non-subscribers misunderstood the interface.
Updated: 52 min 11 sec ago

Re: Impacts code after gstslshet

Sat, 01/05/2019 - 09:48
Run install.packages("sphet", repos="http://R-Forge.R-project.org") for
Linux/OSX source install or Windows binary install of the development
version of sphet, and please report back if this resolves the problem.

Roger

On Sat, 5 Jan 2019, Roger Bivand wrote:

> On Fri, 4 Jan 2019, Veron M. Izon via R-sig-Geo wrote:
>
>>  Hi,
>>
>>  My name is Germán Izón. I am currently working on a project in which I am
>>  estimating a SARAR specification using the gstslshet function. After
>>  estimating this model I tried estimating the marginal effects using the
>>  impacts function but I get the following error: “Error in
>>  spdep::intImpacts(rho = rho, beta = beta, P = P, n = n, mu = mu, :
>>  argument "evalues" is missing, with no default”. I get the same message
>>  using the columbus data. I do not get this error after estimating a
>>  spatial lag model (e.g., lagsarlm). I would truly appreciate any help with
>>  this. Thank you!
>
> Had you provided the output of sessionInfo(), it would be easier to say. My
> guess is that you are using sphet 1.7, and spdep 0.8-1. The use of
> eigenvalues in impacts measures was presented by Gianfranco Piras at the
> Spatial Econometrics meeting in June 2018, and implemented in spdep and
> sphet, but sphet has not been released since then. I just bumped the version
> number of sphet on R-Forge to 1.7-2, and hope that it will let you run
> install.packages("sphet", repos="http://R-Forge.R-project.org"), which is not
> possible at the moment (see https://r-forge.r-project.org/R/?group_id=477).
> If you can install the development version of sphet from source, check it out
> by:
>
> svn checkout svn://svn.r-forge.r-project.org/svnroot/sphet/
>
> and run R CMD build sphet, then R CMD INSTALL that .tar.gz file.
>
> Roger
>
>>
>>  Germán
>>
>>  _______________________________________________
>>  R-sig-Geo mailing list
>>  [hidden email]
>>  https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway

Re: Impacts code after gstslshet

Sat, 01/05/2019 - 09:19
On Fri, 4 Jan 2019, Veron M. Izon via R-sig-Geo wrote:

> Hi,
>
> My name is Germán Izón. I am currently working on a project in which I
> am estimating a SARAR specification using the gstslshet function. After
> estimating this model I tried estimating the marginal effects using the
> impacts function but I get the following error: “Error in
> spdep::intImpacts(rho = rho, beta = beta, P = P, n = n, mu = mu, :
> argument "evalues" is missing, with no default”. I get the same message
> using the columbus data. I do not get this error after estimating a
> spatial lag model (e.g., lagsarlm). I would truly appreciate any help
> with this. Thank you! Had you provided the output of sessionInfo(), it would be easier to say.
My guess is that you are using sphet 1.7, and spdep 0.8-1. The use of
eigenvalues in impacts measures was presented by Gianfranco Piras at the
Spatial Econometrics meeting in June 2018, and implemented in spdep and
sphet, but sphet has not been released since then. I just bumped the
version number of sphet on R-Forge to 1.7-2, and hope that it will let you
run install.packages("sphet", repos="http://R-Forge.R-project.org"), which
is not possible at the moment (see
https://r-forge.r-project.org/R/?group_id=477). If you can install the
development version of sphet from source, check it out by:

svn checkout svn://svn.r-forge.r-project.org/svnroot/sphet/

and run R CMD build sphet, then R CMD INSTALL that .tar.gz file.

Roger

>
> Germán
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway

Impacts code after gstslshet

Fri, 01/04/2019 - 16:10
Hi,
 
My name is Germán Izón. I am currently working on a project in which I am estimating a SARAR specification using the gstslshet function. After estimating this model I tried estimating the marginal effects using the impacts function but I get the following error: “Error in spdep::intImpacts(rho = rho, beta = beta, P = P, n = n, mu = mu,  : argument "evalues" is missing, with no default”. I get the same message using the columbus data. I do not get this error after estimating a spatial lag model (e.g., lagsarlm). I would truly appreciate any help with this. Thank you!
 
Germán

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: how to get an attribute from a raster layer

Sat, 12/29/2018 - 13:04
Where did you search? My google search for "getZ package raster" found it easily. If you have loaded the raster package, then the command ?getZ brings up the manual page:

> library(raster)
Loading required package: sp
> ?getZ

--------------------------------------
David L. Carlson
Department of Anthropology
Texas A&M University


-----Original Message-----
From: R-sig-Geo [mailto:[hidden email]] On Behalf Of Antonio Silva
Sent: Friday, December 28, 2018 10:39 AM
To: Ben Tupper <[hidden email]>
Cc: R-mailing list <[hidden email]>
Subject: Re: [R-sig-Geo] how to get an attribute from a raster layer

Dear Ben

Thanks again. I didn't find this function in my search.

Happy new year to all.

Antonio Olinto

Em sex, 28 de dez de 2018 às 13:19, Ben Tupper <[hidden email]>
escreveu:

> Hi,
>
> You are looking for raster::getZ() but be aware that the Z value can be of
> any type - in this case I would guess it is a Date class so you will need
> to cast it to character using format() to get a label you desire.
>
>
> https://www.rdocumentation.org/packages/raster/versions/2.8-4/topics/z-values
>
>
> Cheers,
> Ben
>
> On Dec 28, 2018, at 10:04 AM, Antonio Silva <[hidden email]> wrote:
>
> Dear list members
>
> I need help to do something that should be easy but I could not execute.
>
> I just want to plot a raster layer and use "z-value" as the title.
>
> rst.data[[1]]
> class       : RasterLayer
> band        : 1  (of  4  bands)
> dimensions  : 33, 45, 1485  (nrow, ncol, ncell)
> resolution  : 0.25, 0.25  (x, y)
> extent      : -50.25, -39, -29, -20.75  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> data source : /mnt/.../dataset-sss-ssd-rep-monthly_2016-11-12_sos.nc
> names       : X2016.11.15.1
> z-value     : 2016-11-15
> zvar        : sos
>
> Is it possible to extract the z-value value directly (2016-11-15)?
>
> The best I could do was
>
> plot(rst.data[[1]],main=substr(names(rst.data[[1]]),2,11))
>
> Thanks a lot
>
> Antonio Olinto
> Fisheries Institute
> São Paulo, Brazil
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 60 Bigelow Drive, P.O. Box 380
> East Boothbay, Maine 04544
> http://www.bigelow.org
>
> Ecological Forecasting: https://eco.bigelow.org/
>
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: how to get an attribute from a raster layer

Fri, 12/28/2018 - 10:39
Dear Ben

Thanks again. I didn't find this function in my search.

Happy new year to all.

Antonio Olinto

Em sex, 28 de dez de 2018 às 13:19, Ben Tupper <[hidden email]>
escreveu:

> Hi,
>
> You are looking for raster::getZ() but be aware that the Z value can be of
> any type - in this case I would guess it is a Date class so you will need
> to cast it to character using format() to get a label you desire.
>
>
> https://www.rdocumentation.org/packages/raster/versions/2.8-4/topics/z-values
>
>
> Cheers,
> Ben
>
> On Dec 28, 2018, at 10:04 AM, Antonio Silva <[hidden email]> wrote:
>
> Dear list members
>
> I need help to do something that should be easy but I could not execute.
>
> I just want to plot a raster layer and use "z-value" as the title.
>
> rst.data[[1]]
> class       : RasterLayer
> band        : 1  (of  4  bands)
> dimensions  : 33, 45, 1485  (nrow, ncol, ncell)
> resolution  : 0.25, 0.25  (x, y)
> extent      : -50.25, -39, -29, -20.75  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> data source : /mnt/.../dataset-sss-ssd-rep-monthly_2016-11-12_sos.nc
> names       : X2016.11.15.1
> z-value     : 2016-11-15
> zvar        : sos
>
> Is it possible to extract the z-value value directly (2016-11-15)?
>
> The best I could do was
>
> plot(rst.data[[1]],main=substr(names(rst.data[[1]]),2,11))
>
> Thanks a lot
>
> Antonio Olinto
> Fisheries Institute
> São Paulo, Brazil
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 60 Bigelow Drive, P.O. Box 380
> East Boothbay, Maine 04544
> http://www.bigelow.org
>
> Ecological Forecasting: https://eco.bigelow.org/
>
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: how to get an attribute from a raster layer

Fri, 12/28/2018 - 09:19
Hi,

You are looking for raster::getZ() but be aware that the Z value can be of any type - in this case I would guess it is a Date class so you will need to cast it to character using format() to get a label you desire.

https://www.rdocumentation.org/packages/raster/versions/2.8-4/topics/z-values


Cheers,
Ben
> On Dec 28, 2018, at 10:04 AM, Antonio Silva <[hidden email]> wrote:
>
> Dear list members
>
> I need help to do something that should be easy but I could not execute.
>
> I just want to plot a raster layer and use "z-value" as the title.
>
> rst.data[[1]]
> class       : RasterLayer
> band        : 1  (of  4  bands)
> dimensions  : 33, 45, 1485  (nrow, ncol, ncell)
> resolution  : 0.25, 0.25  (x, y)
> extent      : -50.25, -39, -29, -20.75  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> data source : /mnt/.../dataset-sss-ssd-rep-monthly_2016-11-12_sos.nc
> names       : X2016.11.15.1
> z-value     : 2016-11-15
> zvar        : sos
>
> Is it possible to extract the z-value value directly (2016-11-15)?
>
> The best I could do was
>
> plot(rst.data[[1]],main=substr(names(rst.data[[1]]),2,11))
>
> Thanks a lot
>
> Antonio Olinto
> Fisheries Institute
> São Paulo, Brazil
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/






        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

how to get an attribute from a raster layer

Fri, 12/28/2018 - 09:04
Dear list members

I need help to do something that should be easy but I could not execute.

I just want to plot a raster layer and use "z-value" as the title.

rst.data[[1]]
class       : RasterLayer
band        : 1  (of  4  bands)
dimensions  : 33, 45, 1485  (nrow, ncol, ncell)
resolution  : 0.25, 0.25  (x, y)
extent      : -50.25, -39, -29, -20.75  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : /mnt/.../dataset-sss-ssd-rep-monthly_2016-11-12_sos.nc
names       : X2016.11.15.1
z-value     : 2016-11-15
zvar        : sos

Is it possible to extract the z-value value directly (2016-11-15)?

The best I could do was

plot(rst.data[[1]],main=substr(names(rst.data[[1]]),2,11))

Thanks a lot

Antonio Olinto
Fisheries Institute
São Paulo, Brazil

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: get data from nc file

Thu, 12/27/2018 - 11:15
Thanks for you nice idea and code Ben. I will use them for sure.

Have a wonderful 2019. All the best

Antonio Olinto
Fisheries Institute
Brazil


Em qua, 26 de dez de 2018 às 22:01, Ben Tupper <[hidden email]>
escreveu:

> Hi,
>
> .  I don't think there is any other way as the attributes are sort of
> buried in the string; that's unfortunate.  I guess you could at least make
> a reusable function assuming you'll be doing this again or looking to pull
> other attributes.  Something like this...
>
>
> #' Extract one of the GLobal Attributes of a TRMM NetCDF as a named vector
> #'
> #' @param nc the ncdf4 object
> #' @param name the name of the global attribute
> #' @param sep the separator used to delimit fields in the attribute
> #' @return named character vector of attributes
> nc_att_split <- function(nc, name = "FileHeader", sep = ";\n"){
>
>         a1 <- ncdf4::ncatt_get(nc, 0)[[name[1]]]
>         if (is.null(a1)) return(a1)
>
>         a2 <- strsplit(a1,";\n", fixed = TRUE)[[1]]
>         aa <- strsplit(a2, "=", fixed = TRUE)
>
>         x <- sapply(aa,
>                 function(s) x = if(length(s) <= 1) "" else s[2]
>                 )
>         names(x) <- sapply(aa,
>                 function(s) x = if(length(s) <= 1) "unknown" else s[1]
>                 )
>
>         x
> }
>
>
> nc <- ncdf4::nc_open("3B43.20080101.7A.HDF.nc")
> x <- nc_att_split(nc)
> as.Date(x[['StartGranuleDateTime']], format = "%Y-%m-%dT%H:%M:%OSZ")
> [1] "2008-01-01"
>
>
> Cheers,
> Ben
>
> > On Dec 26, 2018, at 3:42 PM, Antonio Silva <[hidden email]>
> wrote:
> >
> > Dear list members
> >
> > I downloaded some nc files with precipitation data from
> > https://pmm.nasa.gov/data-access/downloads/trmm (Level 3 3B43:
> > Multisatellite Precipitation). For the image link see the global
> attribute
> > "history" (below).
> >
> > With ncdf4::nc_open I cloud open the file (nc.data <- nc_open("
> > 3B43.20080101.7A.HDF.nc")
> >
> > I want to extract the "StartGranuleDateTime" but it is inside the global
> > attribute FileHeader (see below).
> >
> > With ncatt_get(nc.data,0,"FileHeader")$value I got
> > [1]
> >
> "AlgorithmID=3B43;\nAlgorithmVersion=3B43_7.0;\nFileName=3B43.20080101.7A.HDF;\nGenerationDateTime=2012-11-29T19:12:01.000Z;\nStartGranuleDateTime=2008-01-01T00:00:00.000Z;\nStopGranuleDateTime=2008-01-31T23:59:59.999Z;\nGranuleNumber=;\nNumberOfSwaths=0;\nNumberOfGrids=1;\nGranuleStart=;\nTimeInterval=MONTH;\nProcessingSystem=PPS;\nProductVersion=7A;\nMissingData=;\n"
> >
> > Is there any way to extract only the string "2008-01-01T00:00:00.000Z"?
> >
> > The best I could do was
> >
> as.Date(substr(strsplit(ncatt_get(nc.data,0,"FileHeader")$value,";\n")[[1]][5],22,45),"%Y-%m-%dT%H:%M:%OSZ")
> >
> > but probably, I suppose, there must be a more direct way of getting the
> > data. I appreciate any suggestions.
> >
> > Best regards,
> >
> > Antonio Olinto
> > Fisheries Institute
> > Brazil
> >
> > nc.data
> > File 3B43.20080101.7A.HDF.nc (NC_FORMAT_CLASSIC):
> >
> >     1 variables (excluding dimension variables):
> >        float precipitation[nlat,nlon]
> >            units: mm/hr
> >            coordinates: nlon nlat
> >            _FillValue: -9999.900390625
> >
> >     2 dimensions:
> >        nlon  Size:33
> >            long_name: longitude
> >            standard_name: longitude
> >            units: degrees_east
> >        nlat  Size:41
> >            long_name: latitude
> >            standard_name: latitude
> >            units: degrees_north
> >
> >    5 global attributes:
> >        Grid.GridHeader: BinMethod=ARITHMETIC_MEAN;
> > Registration=CENTER;
> > LatitudeResolution=0.25;
> > LongitudeResolution=0.25;
> > NorthBoundingCoordinate=50;
> > SouthBoundingCoordinate=-50;
> > EastBoundingCoordinate=180;
> > WestBoundingCoordinate=-180;
> > Origin=SOUTHWEST;
> >
> >        FileHeader: AlgorithmID=3B43;
> > AlgorithmVersion=3B43_7.0;
> > FileName=3B43.20080101.7A.HDF;
> > GenerationDateTime=2012-11-29T19:12:01.000Z;
> > StartGranuleDateTime=2008-01-01T00:00:00.000Z;
> > StopGranuleDateTime=2008-01-31T23:59:59.999Z;
> > GranuleNumber=;
> > NumberOfSwaths=0;
> > NumberOfGrids=1;
> > GranuleStart=;
> > TimeInterval=MONTH;
> > ProcessingSystem=PPS;
> > ProductVersion=7A;
> > MissingData=;
> >
> >        FileInfo: DataFormatVersion=m;
> > TKCodeBuildVersion=1;
> > MetadataVersion=m;
> > FormatPackage=HDF Version 4.2 Release 4, January 25, 2009;
> > BlueprintFilename=TRMM.V7.3B43.blueprint.xml;
> > BlueprintVersion=BV_13;
> > TKIOVersion=1.6;
> > MetadataStyle=PVL;
> > EndianType=LITTLE_ENDIAN;
> >
> >        GridHeader: BinMethod=ARITHMETIC_MEAN;
> > Registration=CENTER;
> > LatitudeResolution=0.25;
> > LongitudeResolution=0.25;
> > NorthBoundingCoordinate=50;
> > SouthBoundingCoordinate=-50;
> > EastBoundingCoordinate=180;
> > WestBoundingCoordinate=-180;
> > Origin=SOUTHWEST;
> >
> >        history: 2018-12-26 17:57:56 GMT Hyrax-1.13.4
> >
> https://disc2.gesdisc.eosdis.nasa.gov:443/opendap/TRMM_L3/TRMM_3B43.7/2008/3B43.20080101.7A.HDF.nc?precipitation[604:636][3:43],nlat[3:43],nlon[604:636]
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 60 Bigelow Drive, P.O. Box 380
> East Boothbay, Maine 04544
> http://www.bigelow.org
>
> Ecological Forecasting: https://eco.bigelow.org
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: get data from nc file

Wed, 12/26/2018 - 18:01
Hi,

Yikes.  I don't think there is any other way as the attributes are sort of buried in the string; that's unfortunate.  I guess you could at least make a reusable function assuming you'll be doing this again or looking to pull other attributes.  Something like this...


#' Extract one of the GLobal Attributes of a TRMM NetCDF as a named vector
#'
#' @param nc the ncdf4 object
#' @param name the name of the global attribute
#' @param sep the separator used to delimit fields in the attribute
#' @return named character vector of attributes
nc_att_split <- function(nc, name = "FileHeader", sep = ";\n"){
       
        a1 <- ncdf4::ncatt_get(nc, 0)[[name[1]]]
        if (is.null(a1)) return(a1)
       
        a2 <- strsplit(a1,";\n", fixed = TRUE)[[1]]
        aa <- strsplit(a2, "=", fixed = TRUE)
       
        x <- sapply(aa,
                function(s) x = if(length(s) <= 1) "" else s[2]
                )
        names(x) <- sapply(aa,
                function(s) x = if(length(s) <= 1) "unknown" else s[1]
                )
       
        x
}


nc <- ncdf4::nc_open("3B43.20080101.7A.HDF.nc")
x <- nc_att_split(nc)
as.Date(x[['StartGranuleDateTime']], format = "%Y-%m-%dT%H:%M:%OSZ")
[1] "2008-01-01"


Cheers,
Ben

> On Dec 26, 2018, at 3:42 PM, Antonio Silva <[hidden email]> wrote:
>
> Dear list members
>
> I downloaded some nc files with precipitation data from
> https://pmm.nasa.gov/data-access/downloads/trmm (Level 3 3B43:
> Multisatellite Precipitation). For the image link see the global attribute
> "history" (below).
>
> With ncdf4::nc_open I cloud open the file (nc.data <- nc_open("
> 3B43.20080101.7A.HDF.nc")
>
> I want to extract the "StartGranuleDateTime" but it is inside the global
> attribute FileHeader (see below).
>
> With ncatt_get(nc.data,0,"FileHeader")$value I got
> [1]
> "AlgorithmID=3B43;\nAlgorithmVersion=3B43_7.0;\nFileName=3B43.20080101.7A.HDF;\nGenerationDateTime=2012-11-29T19:12:01.000Z;\nStartGranuleDateTime=2008-01-01T00:00:00.000Z;\nStopGranuleDateTime=2008-01-31T23:59:59.999Z;\nGranuleNumber=;\nNumberOfSwaths=0;\nNumberOfGrids=1;\nGranuleStart=;\nTimeInterval=MONTH;\nProcessingSystem=PPS;\nProductVersion=7A;\nMissingData=;\n"
>
> Is there any way to extract only the string "2008-01-01T00:00:00.000Z"?
>
> The best I could do was
> as.Date(substr(strsplit(ncatt_get(nc.data,0,"FileHeader")$value,";\n")[[1]][5],22,45),"%Y-%m-%dT%H:%M:%OSZ")
>
> but probably, I suppose, there must be a more direct way of getting the
> data. I appreciate any suggestions.
>
> Best regards,
>
> Antonio Olinto
> Fisheries Institute
> Brazil
>
> nc.data
> File 3B43.20080101.7A.HDF.nc (NC_FORMAT_CLASSIC):
>
>     1 variables (excluding dimension variables):
>        float precipitation[nlat,nlon]
>            units: mm/hr
>            coordinates: nlon nlat
>            _FillValue: -9999.900390625
>
>     2 dimensions:
>        nlon  Size:33
>            long_name: longitude
>            standard_name: longitude
>            units: degrees_east
>        nlat  Size:41
>            long_name: latitude
>            standard_name: latitude
>            units: degrees_north
>
>    5 global attributes:
>        Grid.GridHeader: BinMethod=ARITHMETIC_MEAN;
> Registration=CENTER;
> LatitudeResolution=0.25;
> LongitudeResolution=0.25;
> NorthBoundingCoordinate=50;
> SouthBoundingCoordinate=-50;
> EastBoundingCoordinate=180;
> WestBoundingCoordinate=-180;
> Origin=SOUTHWEST;
>
>        FileHeader: AlgorithmID=3B43;
> AlgorithmVersion=3B43_7.0;
> FileName=3B43.20080101.7A.HDF;
> GenerationDateTime=2012-11-29T19:12:01.000Z;
> StartGranuleDateTime=2008-01-01T00:00:00.000Z;
> StopGranuleDateTime=2008-01-31T23:59:59.999Z;
> GranuleNumber=;
> NumberOfSwaths=0;
> NumberOfGrids=1;
> GranuleStart=;
> TimeInterval=MONTH;
> ProcessingSystem=PPS;
> ProductVersion=7A;
> MissingData=;
>
>        FileInfo: DataFormatVersion=m;
> TKCodeBuildVersion=1;
> MetadataVersion=m;
> FormatPackage=HDF Version 4.2 Release 4, January 25, 2009;
> BlueprintFilename=TRMM.V7.3B43.blueprint.xml;
> BlueprintVersion=BV_13;
> TKIOVersion=1.6;
> MetadataStyle=PVL;
> EndianType=LITTLE_ENDIAN;
>
>        GridHeader: BinMethod=ARITHMETIC_MEAN;
> Registration=CENTER;
> LatitudeResolution=0.25;
> LongitudeResolution=0.25;
> NorthBoundingCoordinate=50;
> SouthBoundingCoordinate=-50;
> EastBoundingCoordinate=180;
> WestBoundingCoordinate=-180;
> Origin=SOUTHWEST;
>
>        history: 2018-12-26 17:57:56 GMT Hyrax-1.13.4
> https://disc2.gesdisc.eosdis.nasa.gov:443/opendap/TRMM_L3/TRMM_3B43.7/2008/3B43.20080101.7A.HDF.nc?precipitation[604:636][3:43],nlat[3:43],nlon[604:636]
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

get data from nc file

Wed, 12/26/2018 - 14:42
Dear list members

I downloaded some nc files with precipitation data from
https://pmm.nasa.gov/data-access/downloads/trmm (Level 3 3B43:
Multisatellite Precipitation). For the image link see the global attribute
"history" (below).

With ncdf4::nc_open I cloud open the file (nc.data <- nc_open("
3B43.20080101.7A.HDF.nc")

I want to extract the "StartGranuleDateTime" but it is inside the global
attribute FileHeader (see below).

With ncatt_get(nc.data,0,"FileHeader")$value I got
[1]
"AlgorithmID=3B43;\nAlgorithmVersion=3B43_7.0;\nFileName=3B43.20080101.7A.HDF;\nGenerationDateTime=2012-11-29T19:12:01.000Z;\nStartGranuleDateTime=2008-01-01T00:00:00.000Z;\nStopGranuleDateTime=2008-01-31T23:59:59.999Z;\nGranuleNumber=;\nNumberOfSwaths=0;\nNumberOfGrids=1;\nGranuleStart=;\nTimeInterval=MONTH;\nProcessingSystem=PPS;\nProductVersion=7A;\nMissingData=;\n"

Is there any way to extract only the string "2008-01-01T00:00:00.000Z"?

The best I could do was
as.Date(substr(strsplit(ncatt_get(nc.data,0,"FileHeader")$value,";\n")[[1]][5],22,45),"%Y-%m-%dT%H:%M:%OSZ")

but probably, I suppose, there must be a more direct way of getting the
data. I appreciate any suggestions.

Best regards,

Antonio Olinto
Fisheries Institute
Brazil

nc.data
File 3B43.20080101.7A.HDF.nc (NC_FORMAT_CLASSIC):

     1 variables (excluding dimension variables):
        float precipitation[nlat,nlon]
            units: mm/hr
            coordinates: nlon nlat
            _FillValue: -9999.900390625

     2 dimensions:
        nlon  Size:33
            long_name: longitude
            standard_name: longitude
            units: degrees_east
        nlat  Size:41
            long_name: latitude
            standard_name: latitude
            units: degrees_north

    5 global attributes:
        Grid.GridHeader: BinMethod=ARITHMETIC_MEAN;
Registration=CENTER;
LatitudeResolution=0.25;
LongitudeResolution=0.25;
NorthBoundingCoordinate=50;
SouthBoundingCoordinate=-50;
EastBoundingCoordinate=180;
WestBoundingCoordinate=-180;
Origin=SOUTHWEST;

        FileHeader: AlgorithmID=3B43;
AlgorithmVersion=3B43_7.0;
FileName=3B43.20080101.7A.HDF;
GenerationDateTime=2012-11-29T19:12:01.000Z;
StartGranuleDateTime=2008-01-01T00:00:00.000Z;
StopGranuleDateTime=2008-01-31T23:59:59.999Z;
GranuleNumber=;
NumberOfSwaths=0;
NumberOfGrids=1;
GranuleStart=;
TimeInterval=MONTH;
ProcessingSystem=PPS;
ProductVersion=7A;
MissingData=;

        FileInfo: DataFormatVersion=m;
TKCodeBuildVersion=1;
MetadataVersion=m;
FormatPackage=HDF Version 4.2 Release 4, January 25, 2009;
BlueprintFilename=TRMM.V7.3B43.blueprint.xml;
BlueprintVersion=BV_13;
TKIOVersion=1.6;
MetadataStyle=PVL;
EndianType=LITTLE_ENDIAN;

        GridHeader: BinMethod=ARITHMETIC_MEAN;
Registration=CENTER;
LatitudeResolution=0.25;
LongitudeResolution=0.25;
NorthBoundingCoordinate=50;
SouthBoundingCoordinate=-50;
EastBoundingCoordinate=180;
WestBoundingCoordinate=-180;
Origin=SOUTHWEST;

        history: 2018-12-26 17:57:56 GMT Hyrax-1.13.4
https://disc2.gesdisc.eosdis.nasa.gov:443/opendap/TRMM_L3/TRMM_3B43.7/2008/3B43.20080101.7A.HDF.nc?precipitation[604:636][3:43],nlat[3:43],nlon[604:636]

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: error when trying to use RStudio within GRASS

Sun, 12/23/2018 - 12:42
On Sun, 23 Dec 2018, Sarah Goslee wrote:

> Hi Carlos,
>
> "This error does not show when using R instead of RStudio."
>
> Then you probably need to use RStudio help channels. You *might* get lucky
> here, but this is an R help list, not RStudio help.

Maybe also try https://lists.osgeo.org/mailman/listinfo/grass-stats, which
has a recent thread on this topic. I just tried Win10/GRASS 7.4/RStudio,
and had no trouble either running rgrass7::initGRASS() in RStudio started
on its own, or running rgrass::parseGRASS() in rstudio started in RStudio
started from the console command line inside GRASS. Consider following up
the thread on that list.

Roger

>
> Sarah
>
> On Sun, Dec 23, 2018 at 7:44 AM Carlos Rodríguez <[hidden email]>
> wrote:
>
>> Hi guys,
>>
>> I have the following error when using Rstudio within GRASS 7.2.2
>> (stand-alone version) in Windows 10:
>>
>>
>>
>> Location Spearfish_60
>>
>>> points <- readVECT("archsites")
>>
>> Error in if (get("SYS", envir = .GRASS_CACHE) == "WinNat" && nchar(WN_bat)
>> ==  :
>>
>>   missing value where TRUE/FALSE needed
>>
>>
>>> traceback()
>>
>> 7: parseGRASS(cmd, legacyExec = legacyExec)
>>
>> 6: doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd =
>> echoCmd,
>>
>>        legacyExec = legacyExec)
>>
>> 5: execGRASS("v.in.ogr", flags = ifelse(ignore.stderr, c("f", "quiet"),
>>
>>        "f"), intern = TRUE, ignore.stderr = ignore.stderr)
>>
>> 4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
>>
>>        remove.duplicates = remove.duplicates, ignore.stderr =
>> ignore.stderr,
>>
>>        pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
>>
>>        with_c = with_c)
>>
>> 3: tryCatchList(expr, classes, parentenv, handlers)
>>
>> 2: tryCatch({
>>
>>        stopifnot(is.logical(plugin) || is.null(plugin))
>>
>>        stopifnot(is.logical(ignore.stderr))
>>
>>        if (missing(layer))
>>
>>            layer <- "1"
>>
>>        layer <- as.character(layer)
>>
>>        stopifnot(is.logical(with_c))
>>
>>        if (!is.null(driver) && driver == "GRASS")
>>
>>            plugin <- TRUE
>>
>>        if (!requireNamespace("rgdal", quietly = TRUE)) {
>>
>>            stop("rgdal not available")
>>
>>        }
>>
>>        if (is.null(plugin)) {
>>
>>            ogrD <- rgdal::ogrDrivers()$name
>>
>>            plugin <- "GRASS" %in% ogrD
>>
>>        }
>>
>>        if (plugin) {
>>
>>            res <- .read_vect_plugin(vname = vname, layer = layer,
>>
>>                type = type, ignore.stderr = ignore.stderr, pointDropZ =
>> pointDropZ,
>>
>>                mapset = mapset)
>>
>>        }
>>
>>        else {
>>
>>            res <- .read_vect_non_plugin(vname = vname, layer = layer,
>>
>>                type = type, remove.duplicates = remove.duplicates,
>>
>>                ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
>>
>>                driver = driver, with_prj = with_prj, with_c = with_c)
>>
>>        }
>>
>>    }, finally = {
>>
>>        if (get.suppressEchoCmdInFuncOption()) {
>>
>>            tull <- set.echoCmdOption(inEchoCmd)
>>
>>        }
>>
>>    })
>>
>> 1: readVECT("archsites")
>>
>>
>>
>>
>>
>> This error does not show when using R instead of RStudio. I’ve searched
>> around and tried to implement the fixes proposed for similar issues
>> (unsuccessfully).  I feel that it might be a very simple issue, but I am
>> stuck and I will appreciate any help. Here the Sys.getenv() and
>> sessionInfo(), in case there are needed.
>>
>>
>>
>>
>>> Sys.getenv()
>>
>> __COMPAT_LAYER              RunAsAdmin DetectorsWin7
>>
>> ADSK_CLM_WPAD_PROXY_CHECK   FALSE
>>
>> ALLUSERSPROFILE             C:\ProgramData
>>
>> APPDATA                     C:\Users\...\AppData\Roaming
>>
>> CLICOLOR_FORCE              1
>>
>> CommonProgramFiles          C:\Program Files\Common Files
>>
>> CommonProgramFiles(x86)     C:\Program Files (x86)\Common Files
>>
>> CommonProgramW6432          C:\Program Files\Common Files
>>
>> COMPUTERNAME
>>
>> ComSpec                     C:\WINDOWS\system32\cmd.exe
>>
>> DISPLAY                     :0
>>
>> DriverData                  C:\Windows\System32\Drivers\DriverData
>>
>> FP_NO_HOST_CHECK            NO
>>
>> GDAL_DATA                   C:/Program Files/R/R-3.5.1/library/rgdal/gdal
>>
>> GEODA_GDAL_DATA             C:\Program Files\GeoDa Software\data
>>
>> GEODA_OGR_DRIVER_PATH       C:\Program Files\GeoDa Software
>>
>> GFORTRAN_STDERR_UNIT        -1
>>
>> GFORTRAN_STDOUT_UNIT        -1
>>
>> GRASS_MESSAGE_FORMAT        text
>>
>> GRASS_PAGER                 cat
>>
>> HOME                        C:/Users/…/Documents
>>
>> HOMEDRIVE                   C:
>>
>> HOMEPATH                    \Users\...
>>
>> JRI_HOME
>> C:\Users\...\Documents\R\win-library\3.4\rJava\jri
>>
>> LOCALAPPDATA                C:\Users\...\AppData\Local
>>
>> LOGONSERVER                 \\...
>>
>> MSYS2_ENV_CONV_EXCL         R_ARCH
>>
>> NUMBER_OF_PROCESSORS        8
>>
>> OneDrive                    C:\Users\...\OneDrive
>>
>> OS                          Windows_NT
>>
>> PATH                        C:\Program
>>
>>
>> Files\R\R-3.5.1\bin\x64;C:\Rtools\bin;C:\ProgramData\Oracle\Java\javapath;c:\Rtools\gcc-4.6.3\bin;C:\Program
>>
>>                             Files (x86)\Intel\iCLS Client\;C:\Program
>>
>>                             Files\Intel\iCLS
>>
>>
>> Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
>>
>>                             Files\Intel\Intel(R) Management Engine
>>
>>                             Components\DAL;C:\Program Files\Intel\Intel(R)
>>
>>                             Management Engine Components\IPT;C:\Program
>> Files
>>
>>                             (x86)\Intel\Intel(R) Management Engine
>>
>>                             Components\DAL;C:\Program Files
>> (x86)\Intel\Intel(R)
>>
>>                             Management Engine Components\IPT;C:\Program
>> Files
>>
>>                             (x86)\ATI
>> Technologies\ATI.ACE\Core-Static;C:\Program
>>
>>                             Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program
>>
>>                             Files\Git\cmd;C:\Program Files
>>
>>                             (x86)\Skype\Phone\;C:\Program
>>
>>                             Files\R\R-3.5.1\bin\x64;C:\Program
>>
>>
>> Files\RStudio\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program
>>
>>                             Files (x86)\Calibre2\;C:\Program
>>
>>                             Files\Intel\WiFi\bin\;C:\Program Files\Common
>>
>>                             Files\Intel\WirelessCommon\;C:\Users\...
>> \AppData\Local\Microsoft\WindowsApps
>>
>> PATHEXT
>>  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
>>
>> PROCESSOR_ARCHITECTURE      AMD64
>>
>> PROCESSOR_IDENTIFIER        Intel64 Family 6 Model 60 Stepping 3,
>> GenuineIntel
>>
>> PROCESSOR_LEVEL             6
>>
>> PROCESSOR_REVISION          3c03
>>
>> ProgramData                 C:\ProgramData
>>
>> ProgramFiles                C:\Program Files
>>
>> ProgramFiles(x86)           C:\Program Files (x86)
>>
>> ProgramW6432                C:\Program Files
>>
>> PROJ_LIB                    C:/Program Files/R/R-3.5.1/library/rgdal/proj
>>
>> PSModulePath
>> C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
>>
>> PUBLIC                      C:\Users\Public
>>
>> R_ARCH                      /x64
>>
>> R_COMPILED_BY               gcc 4.9.3
>>
>> R_DOC_DIR                   C:/PROGRA~1/R/R-35~1.1/doc
>>
>> R_HOME                      C:/PROGRA~1/R/R-35~1.1
>>
>> R_LIBS_USER                 C:\Program Files\R\R-3.5.1\library
>>
>> R_MAP_DATA_DIR              C:/Program
>> Files/R/R-3.5.1/library/maps/mapdata/
>>
>> R_MAP_DATA_DIR_WORLD        C:/Program
>> Files/R/R-3.5.1/library/maps/mapdata/
>>
>> R_USER                      C:/Users/…/Documents
>>
>> RCRAN                       C:\Program Files\R\R-3.5.1\bin\x64
>>
>> RMARKDOWN_MATHJAX_PATH      C:/Program Files/RStudio/resources/mathjax-26
>>
>> RS_LOCAL_PEER               \\.\pipe\30976-rsession
>>
>> RS_RPOSTBACK_PATH           C:/Program Files/RStudio/bin/rpostback
>>
>> RS_SHARED_SECRET            63341846741
>>
>> RSTUDIO                     1
>>
>> RSTUDIO_CONSOLE_COLOR       256
>>
>> RSTUDIO_CONSOLE_WIDTH       80
>>
>> RSTUDIO_MSYS_SSH            C:/Program Files/RStudio/bin/msys-ssh-1000-18
>>
>> RSTUDIO_PANDOC              C:/Program Files/RStudio/bin/pandoc
>>
>> RSTUDIO_SESSION_PORT        30976
>>
>> RSTUDIO_USER_IDENTITY       …
>>
>> RSTUDIO_WINUTILS            C:/Program Files/RStudio/bin/winutils
>>
>> SystemDrive                 C:
>>
>> SystemRoot                  C:\WINDOWS
>>
>> TEMP                        C:\Users\...\AppData\Local\Temp
>>
>> TERM                        xterm-256color
>>
>> TMP                         C:\Users\...\AppData\Local\Temp
>>
>> USERDOMAIN                  …
>>
>> USERDOMAIN_ROAMINGPROFILE   …
>>
>> USERNAME                    …
>>
>> USERPROFILE                 C:\Users\...
>>
>> windir                      C:\WINDOWS
>>
>>
>>
>>
>>
>>> sessionInfo()
>>
>> R version 3.5.1 (2018-07-02)
>>
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>
>> Running under: Windows >= 8 x64 (build 9200)
>>
>>
>>
>> Matrix products: default
>>
>>
>>
>> locale:
>>
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>> States.1252
>>
>> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>>
>>
>> [5] LC_TIME=English_United States.1252
>>
>>
>>
>> attached base packages:
>>
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>>
>>
>> other attached packages:
>>
>>  [1] dbscan_1.1-2        rgdal_1.3-4         geostatsp_1.7.2
>>  Matrix_1.2-14
>>
>>  [5] raster_2.6-7        maptools_0.9-3      maps_3.3.0
>> spatstat_1.56-1
>>
>>  [9] rpart_4.1-13        nlme_3.1-137        spatstat.data_1.3-1
>> rgrass7_0.1-10
>>
>> [13] XML_3.98-1.16       sp_1.3-1
>>
>>
>>
>>
>>
>>
>>
>> Thanks in advance,
>>
>>
>>
>> William
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> --
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway

Re: error when trying to use RStudio within GRASS

Sun, 12/23/2018 - 07:06
Hi Carlos,

"This error does not show when using R instead of RStudio."

Then you probably need to use RStudio help channels. You *might* get lucky
here, but this is an R help list, not RStudio help.

Sarah

On Sun, Dec 23, 2018 at 7:44 AM Carlos Rodríguez <[hidden email]>
wrote:

> Hi guys,
>
> I have the following error when using Rstudio within GRASS 7.2.2
> (stand-alone version) in Windows 10:
>
>
>
> Location Spearfish_60
>
> > points <- readVECT("archsites")
>
> Error in if (get("SYS", envir = .GRASS_CACHE) == "WinNat" && nchar(WN_bat)
> ==  :
>
>   missing value where TRUE/FALSE needed
>
>
> > traceback()
>
> 7: parseGRASS(cmd, legacyExec = legacyExec)
>
> 6: doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd =
> echoCmd,
>
>        legacyExec = legacyExec)
>
> 5: execGRASS("v.in.ogr", flags = ifelse(ignore.stderr, c("f", "quiet"),
>
>        "f"), intern = TRUE, ignore.stderr = ignore.stderr)
>
> 4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
>
>        remove.duplicates = remove.duplicates, ignore.stderr =
> ignore.stderr,
>
>        pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
>
>        with_c = with_c)
>
> 3: tryCatchList(expr, classes, parentenv, handlers)
>
> 2: tryCatch({
>
>        stopifnot(is.logical(plugin) || is.null(plugin))
>
>        stopifnot(is.logical(ignore.stderr))
>
>        if (missing(layer))
>
>            layer <- "1"
>
>        layer <- as.character(layer)
>
>        stopifnot(is.logical(with_c))
>
>        if (!is.null(driver) && driver == "GRASS")
>
>            plugin <- TRUE
>
>        if (!requireNamespace("rgdal", quietly = TRUE)) {
>
>            stop("rgdal not available")
>
>        }
>
>        if (is.null(plugin)) {
>
>            ogrD <- rgdal::ogrDrivers()$name
>
>            plugin <- "GRASS" %in% ogrD
>
>        }
>
>        if (plugin) {
>
>            res <- .read_vect_plugin(vname = vname, layer = layer,
>
>                type = type, ignore.stderr = ignore.stderr, pointDropZ =
> pointDropZ,
>
>                mapset = mapset)
>
>        }
>
>        else {
>
>            res <- .read_vect_non_plugin(vname = vname, layer = layer,
>
>                type = type, remove.duplicates = remove.duplicates,
>
>                ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
>
>                driver = driver, with_prj = with_prj, with_c = with_c)
>
>        }
>
>    }, finally = {
>
>        if (get.suppressEchoCmdInFuncOption()) {
>
>            tull <- set.echoCmdOption(inEchoCmd)
>
>        }
>
>    })
>
> 1: readVECT("archsites")
>
>
>
>
>
> This error does not show when using R instead of RStudio. I’ve searched
> around and tried to implement the fixes proposed for similar issues
> (unsuccessfully).  I feel that it might be a very simple issue, but I am
> stuck and I will appreciate any help. Here the Sys.getenv() and
> sessionInfo(), in case there are needed.
>
>
>
>
> > Sys.getenv()
>
> __COMPAT_LAYER              RunAsAdmin DetectorsWin7
>
> ADSK_CLM_WPAD_PROXY_CHECK   FALSE
>
> ALLUSERSPROFILE             C:\ProgramData
>
> APPDATA                     C:\Users\...\AppData\Roaming
>
> CLICOLOR_FORCE              1
>
> CommonProgramFiles          C:\Program Files\Common Files
>
> CommonProgramFiles(x86)     C:\Program Files (x86)\Common Files
>
> CommonProgramW6432          C:\Program Files\Common Files
>
> COMPUTERNAME
>
> ComSpec                     C:\WINDOWS\system32\cmd.exe
>
> DISPLAY                     :0
>
> DriverData                  C:\Windows\System32\Drivers\DriverData
>
> FP_NO_HOST_CHECK            NO
>
> GDAL_DATA                   C:/Program Files/R/R-3.5.1/library/rgdal/gdal
>
> GEODA_GDAL_DATA             C:\Program Files\GeoDa Software\data
>
> GEODA_OGR_DRIVER_PATH       C:\Program Files\GeoDa Software
>
> GFORTRAN_STDERR_UNIT        -1
>
> GFORTRAN_STDOUT_UNIT        -1
>
> GRASS_MESSAGE_FORMAT        text
>
> GRASS_PAGER                 cat
>
> HOME                        C:/Users/…/Documents
>
> HOMEDRIVE                   C:
>
> HOMEPATH                    \Users\...
>
> JRI_HOME
> C:\Users\...\Documents\R\win-library\3.4\rJava\jri
>
> LOCALAPPDATA                C:\Users\...\AppData\Local
>
> LOGONSERVER                 \\...
>
> MSYS2_ENV_CONV_EXCL         R_ARCH
>
> NUMBER_OF_PROCESSORS        8
>
> OneDrive                    C:\Users\...\OneDrive
>
> OS                          Windows_NT
>
> PATH                        C:\Program
>
>
> Files\R\R-3.5.1\bin\x64;C:\Rtools\bin;C:\ProgramData\Oracle\Java\javapath;c:\Rtools\gcc-4.6.3\bin;C:\Program
>
>                             Files (x86)\Intel\iCLS Client\;C:\Program
>
>                             Files\Intel\iCLS
>
>
> Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
>
>                             Files\Intel\Intel(R) Management Engine
>
>                             Components\DAL;C:\Program Files\Intel\Intel(R)
>
>                             Management Engine Components\IPT;C:\Program
> Files
>
>                             (x86)\Intel\Intel(R) Management Engine
>
>                             Components\DAL;C:\Program Files
> (x86)\Intel\Intel(R)
>
>                             Management Engine Components\IPT;C:\Program
> Files
>
>                             (x86)\ATI
> Technologies\ATI.ACE\Core-Static;C:\Program
>
>                             Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program
>
>                             Files\Git\cmd;C:\Program Files
>
>                             (x86)\Skype\Phone\;C:\Program
>
>                             Files\R\R-3.5.1\bin\x64;C:\Program
>
>
> Files\RStudio\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program
>
>                             Files (x86)\Calibre2\;C:\Program
>
>                             Files\Intel\WiFi\bin\;C:\Program Files\Common
>
>                             Files\Intel\WirelessCommon\;C:\Users\...
> \AppData\Local\Microsoft\WindowsApps
>
> PATHEXT
>  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
>
> PROCESSOR_ARCHITECTURE      AMD64
>
> PROCESSOR_IDENTIFIER        Intel64 Family 6 Model 60 Stepping 3,
> GenuineIntel
>
> PROCESSOR_LEVEL             6
>
> PROCESSOR_REVISION          3c03
>
> ProgramData                 C:\ProgramData
>
> ProgramFiles                C:\Program Files
>
> ProgramFiles(x86)           C:\Program Files (x86)
>
> ProgramW6432                C:\Program Files
>
> PROJ_LIB                    C:/Program Files/R/R-3.5.1/library/rgdal/proj
>
> PSModulePath
> C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
>
> PUBLIC                      C:\Users\Public
>
> R_ARCH                      /x64
>
> R_COMPILED_BY               gcc 4.9.3
>
> R_DOC_DIR                   C:/PROGRA~1/R/R-35~1.1/doc
>
> R_HOME                      C:/PROGRA~1/R/R-35~1.1
>
> R_LIBS_USER                 C:\Program Files\R\R-3.5.1\library
>
> R_MAP_DATA_DIR              C:/Program
> Files/R/R-3.5.1/library/maps/mapdata/
>
> R_MAP_DATA_DIR_WORLD        C:/Program
> Files/R/R-3.5.1/library/maps/mapdata/
>
> R_USER                      C:/Users/…/Documents
>
> RCRAN                       C:\Program Files\R\R-3.5.1\bin\x64
>
> RMARKDOWN_MATHJAX_PATH      C:/Program Files/RStudio/resources/mathjax-26
>
> RS_LOCAL_PEER               \\.\pipe\30976-rsession
>
> RS_RPOSTBACK_PATH           C:/Program Files/RStudio/bin/rpostback
>
> RS_SHARED_SECRET            63341846741
>
> RSTUDIO                     1
>
> RSTUDIO_CONSOLE_COLOR       256
>
> RSTUDIO_CONSOLE_WIDTH       80
>
> RSTUDIO_MSYS_SSH            C:/Program Files/RStudio/bin/msys-ssh-1000-18
>
> RSTUDIO_PANDOC              C:/Program Files/RStudio/bin/pandoc
>
> RSTUDIO_SESSION_PORT        30976
>
> RSTUDIO_USER_IDENTITY       …
>
> RSTUDIO_WINUTILS            C:/Program Files/RStudio/bin/winutils
>
> SystemDrive                 C:
>
> SystemRoot                  C:\WINDOWS
>
> TEMP                        C:\Users\...\AppData\Local\Temp
>
> TERM                        xterm-256color
>
> TMP                         C:\Users\...\AppData\Local\Temp
>
> USERDOMAIN                  …
>
> USERDOMAIN_ROAMINGPROFILE   …
>
> USERNAME                    …
>
> USERPROFILE                 C:\Users\...
>
> windir                      C:\WINDOWS
>
>
>
>
>
> > sessionInfo()
>
> R version 3.5.1 (2018-07-02)
>
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> Running under: Windows >= 8 x64 (build 9200)
>
>
>
> Matrix products: default
>
>
>
> locale:
>
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252
>
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>
>
> [5] LC_TIME=English_United States.1252
>
>
>
> attached base packages:
>
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
>
>
> other attached packages:
>
>  [1] dbscan_1.1-2        rgdal_1.3-4         geostatsp_1.7.2
>  Matrix_1.2-14
>
>  [5] raster_2.6-7        maptools_0.9-3      maps_3.3.0
> spatstat_1.56-1
>
>  [9] rpart_4.1-13        nlme_3.1-137        spatstat.data_1.3-1
> rgrass7_0.1-10
>
> [13] XML_3.98-1.16       sp_1.3-1
>
>
>
>
>
>
>
> Thanks in advance,
>
>
>
> William
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Sarah Goslee (she/her)
http://www.sarahgoslee.com

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

error when trying to use RStudio within GRASS

Sun, 12/23/2018 - 06:44
Hi guys,

I have the following error when using Rstudio within GRASS 7.2.2 (stand-alone version) in Windows 10:



Location Spearfish_60

> points <- readVECT("archsites")

Error in if (get("SYS", envir = .GRASS_CACHE) == "WinNat" && nchar(WN_bat) ==  :

  missing value where TRUE/FALSE needed


> traceback()

7: parseGRASS(cmd, legacyExec = legacyExec)

6: doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd = echoCmd,

       legacyExec = legacyExec)

5: execGRASS("v.in.ogr", flags = ifelse(ignore.stderr, c("f", "quiet"),

       "f"), intern = TRUE, ignore.stderr = ignore.stderr)

4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,

       remove.duplicates = remove.duplicates, ignore.stderr = ignore.stderr,

       pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,

       with_c = with_c)

3: tryCatchList(expr, classes, parentenv, handlers)

2: tryCatch({

       stopifnot(is.logical(plugin) || is.null(plugin))

       stopifnot(is.logical(ignore.stderr))

       if (missing(layer))

           layer <- "1"

       layer <- as.character(layer)

       stopifnot(is.logical(with_c))

       if (!is.null(driver) && driver == "GRASS")

           plugin <- TRUE

       if (!requireNamespace("rgdal", quietly = TRUE)) {

           stop("rgdal not available")

       }

       if (is.null(plugin)) {

           ogrD <- rgdal::ogrDrivers()$name

           plugin <- "GRASS" %in% ogrD

       }

       if (plugin) {

           res <- .read_vect_plugin(vname = vname, layer = layer,

               type = type, ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,

               mapset = mapset)

       }

       else {

           res <- .read_vect_non_plugin(vname = vname, layer = layer,

               type = type, remove.duplicates = remove.duplicates,

               ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,

               driver = driver, with_prj = with_prj, with_c = with_c)

       }

   }, finally = {

       if (get.suppressEchoCmdInFuncOption()) {

           tull <- set.echoCmdOption(inEchoCmd)

       }

   })

1: readVECT("archsites")

 

 

This error does not show when using R instead of RStudio. I’ve searched around and tried to implement the fixes proposed for similar issues (unsuccessfully).  I feel that it might be a very simple issue, but I am stuck and I will appreciate any help. Here the Sys.getenv() and sessionInfo(), in case there are needed.




> Sys.getenv()

__COMPAT_LAYER              RunAsAdmin DetectorsWin7

ADSK_CLM_WPAD_PROXY_CHECK   FALSE

ALLUSERSPROFILE             C:\ProgramData

APPDATA                     C:\Users\...\AppData\Roaming

CLICOLOR_FORCE              1

CommonProgramFiles          C:\Program Files\Common Files

CommonProgramFiles(x86)     C:\Program Files (x86)\Common Files

CommonProgramW6432          C:\Program Files\Common Files

COMPUTERNAME              

ComSpec                     C:\WINDOWS\system32\cmd.exe

DISPLAY                     :0

DriverData                  C:\Windows\System32\Drivers\DriverData

FP_NO_HOST_CHECK            NO

GDAL_DATA                   C:/Program Files/R/R-3.5.1/library/rgdal/gdal

GEODA_GDAL_DATA             C:\Program Files\GeoDa Software\data

GEODA_OGR_DRIVER_PATH       C:\Program Files\GeoDa Software

GFORTRAN_STDERR_UNIT        -1

GFORTRAN_STDOUT_UNIT        -1

GRASS_MESSAGE_FORMAT        text

GRASS_PAGER                 cat

HOME                        C:/Users/…/Documents

HOMEDRIVE                   C:

HOMEPATH                    \Users\...

JRI_HOME                    C:\Users\...\Documents\R\win-library\3.4\rJava\jri

LOCALAPPDATA                C:\Users\...\AppData\Local

LOGONSERVER                 \\...

MSYS2_ENV_CONV_EXCL         R_ARCH

NUMBER_OF_PROCESSORS        8

OneDrive                    C:\Users\...\OneDrive

OS                          Windows_NT

PATH                        C:\Program

                            Files\R\R-3.5.1\bin\x64;C:\Rtools\bin;C:\ProgramData\Oracle\Java\javapath;c:\Rtools\gcc-4.6.3\bin;C:\Program

                            Files (x86)\Intel\iCLS Client\;C:\Program

                            Files\Intel\iCLS

                            Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program

                            Files\Intel\Intel(R) Management Engine

                            Components\DAL;C:\Program Files\Intel\Intel(R)

                            Management Engine Components\IPT;C:\Program Files

                            (x86)\Intel\Intel(R) Management Engine

                            Components\DAL;C:\Program Files (x86)\Intel\Intel(R)

                            Management Engine Components\IPT;C:\Program Files

                            (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program

                            Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program

                            Files\Git\cmd;C:\Program Files

                            (x86)\Skype\Phone\;C:\Program

                            Files\R\R-3.5.1\bin\x64;C:\Program

                            Files\RStudio\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program

                            Files (x86)\Calibre2\;C:\Program

                            Files\Intel\WiFi\bin\;C:\Program Files\Common

                            Files\Intel\WirelessCommon\;C:\Users\... \AppData\Local\Microsoft\WindowsApps

PATHEXT                     .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

PROCESSOR_ARCHITECTURE      AMD64

PROCESSOR_IDENTIFIER        Intel64 Family 6 Model 60 Stepping 3, GenuineIntel

PROCESSOR_LEVEL             6

PROCESSOR_REVISION          3c03

ProgramData                 C:\ProgramData

ProgramFiles                C:\Program Files

ProgramFiles(x86)           C:\Program Files (x86)

ProgramW6432                C:\Program Files

PROJ_LIB                    C:/Program Files/R/R-3.5.1/library/rgdal/proj

PSModulePath                C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\

PUBLIC                      C:\Users\Public

R_ARCH                      /x64

R_COMPILED_BY               gcc 4.9.3

R_DOC_DIR                   C:/PROGRA~1/R/R-35~1.1/doc

R_HOME                      C:/PROGRA~1/R/R-35~1.1

R_LIBS_USER                 C:\Program Files\R\R-3.5.1\library

R_MAP_DATA_DIR              C:/Program Files/R/R-3.5.1/library/maps/mapdata/

R_MAP_DATA_DIR_WORLD        C:/Program Files/R/R-3.5.1/library/maps/mapdata/

R_USER                      C:/Users/…/Documents

RCRAN                       C:\Program Files\R\R-3.5.1\bin\x64

RMARKDOWN_MATHJAX_PATH      C:/Program Files/RStudio/resources/mathjax-26

RS_LOCAL_PEER               \\.\pipe\30976-rsession

RS_RPOSTBACK_PATH           C:/Program Files/RStudio/bin/rpostback

RS_SHARED_SECRET            63341846741

RSTUDIO                     1

RSTUDIO_CONSOLE_COLOR       256

RSTUDIO_CONSOLE_WIDTH       80

RSTUDIO_MSYS_SSH            C:/Program Files/RStudio/bin/msys-ssh-1000-18

RSTUDIO_PANDOC              C:/Program Files/RStudio/bin/pandoc

RSTUDIO_SESSION_PORT        30976

RSTUDIO_USER_IDENTITY       …

RSTUDIO_WINUTILS            C:/Program Files/RStudio/bin/winutils

SystemDrive                 C:

SystemRoot                  C:\WINDOWS

TEMP                        C:\Users\...\AppData\Local\Temp

TERM                        xterm-256color

TMP                         C:\Users\...\AppData\Local\Temp

USERDOMAIN                  …

USERDOMAIN_ROAMINGPROFILE   …

USERNAME                    …

USERPROFILE                 C:\Users\...

windir                      C:\WINDOWS

 

 

> sessionInfo()

R version 3.5.1 (2018-07-02)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows >= 8 x64 (build 9200)

 

Matrix products: default

 

locale:

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252  

[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                        

[5] LC_TIME=English_United States.1252  

 

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base    

 

other attached packages:

 [1] dbscan_1.1-2        rgdal_1.3-4         geostatsp_1.7.2     Matrix_1.2-14    

 [5] raster_2.6-7        maptools_0.9-3      maps_3.3.0          spatstat_1.56-1  

 [9] rpart_4.1-13        nlme_3.1-137        spatstat.data_1.3-1 rgrass7_0.1-10    

[13] XML_3.98-1.16       sp_1.3-1          

 

 

 

Thanks in advance,

 

William
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: R Help

Fri, 12/21/2018 - 07:07
Dear Esu,

you can probably solve these tasks using sf package, which uses bit
different way of representing spatial objects compared to the sp object.
Below you'll find an example for the North Carolina dataset. Keep in mind
that calculating area and perimeter depends on your coordinate system (i.e.
you can use projection that works better for calculating areas, or
distances; check the area/perimeter columns in nc dataset versus the output
of the functions below).
Package lwgeom is for the st_perimeter() function, and I converted it to
equidistant projection, since st_perimeter() doesn't like lat/long data.
Spatial objects of sp class you can convert to simple feature using
st_as_sf() function.

Hope it helps,
Mirza.

library(sf)
library(lwgeom)

nc <- st_read(system.file("shape/nc.shp", package="sf"))
nc <- st_transform(nc, crs = "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0
+y_0=0 +a=6371007 +b=6371007 +units=m +no_defs")

my_area <- st_area(nc)
my_centroid_x = st_coordinates(st_centroid(nc))[, 1]
my_centroid_y = st_coordinates(st_centroid(nc))[, 2]
my_perimeter = st_perimeter(nc)

On Fri, Dec 21, 2018 at 1:34 PM Andres Diaz Loaiza <[hidden email]>
wrote:

> Dear Esu,
>
> About your question there is huge literature already written.
>
> I recommend to read the sp package manual.
>
> An example for extract the coordinates you can  find it here:
>
>
> https://gis.stackexchange.com/questions/43543/how-to-calculate-polygon-centroids-in-r-for-non-contiguous-shapes
>
> If you want to see how works the function remember that r is an open source
> code and you can find the original functions over the binaries repositories
> or compressed packages.
>
> All the best,
>
> Andres
>
>
> On Thu, 20 Dec 2018 at 22:58, Esu Esu via R-sig-Geo <
> [hidden email]>
> wrote:
>
> > Dear All,
> > I am new to R-programming. I have question if anyone can help me with:Q:
> > how can I create functions in R to compute the area (A), centroid (Cx and
> > Cy) and perimeter (P) of a polygon list .  I want to write R functions to
> > compute these quantities for individual polygons, as well asan overall
> > function to take a polygon list and return a data frame with four columns
> > and the samenumber of rows as polygons in the list.  Each quantity
> > should correspond to each column. it is (sp) class object.
> > Hope to find any suggestion or answer
> >  RegardsMuhsien
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> --
> Andrés D.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
*Mirza Čengić*

*Junior Researcher | Department of Environmental Science*
Radboud University | Heyendaalseweg 135
6525 AJ Nijmegen | The Netherlands

+31 657020823 | +38761908392
Skype: mirzacengic
<https://www.linkedin.com/in/mirzacengic>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: R Help

Fri, 12/21/2018 - 06:33
Dear Esu,

About your question there is huge literature already written.

I recommend to read the sp package manual.

An example for extract the coordinates you can  find it here:

https://gis.stackexchange.com/questions/43543/how-to-calculate-polygon-centroids-in-r-for-non-contiguous-shapes

If you want to see how works the function remember that r is an open source
code and you can find the original functions over the binaries repositories
or compressed packages.

All the best,

Andres


On Thu, 20 Dec 2018 at 22:58, Esu Esu via R-sig-Geo <[hidden email]>
wrote:

> Dear All,
> I am new to R-programming. I have question if anyone can help me with:Q:
> how can I create functions in R to compute the area (A), centroid (Cx and
> Cy) and perimeter (P) of a polygon list .  I want to write R functions to
> compute these quantities for individual polygons, as well asan overall
> function to take a polygon list and return a data frame with four columns
> and the samenumber of rows as polygons in the list.  Each quantity
> should correspond to each column. it is (sp) class object.
> Hope to find any suggestion or answer
>  RegardsMuhsien
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Andrés D.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: [FORGED] R Help

Thu, 12/20/2018 - 16:47

On 12/21/18 10:56 AM, Esu Esu via R-sig-Geo wrote:

> Dear All,
> I am new to R-programming.

Learn to crawl before you start trying to walk or run.  Study some of
the many R tutorials that are available.

> I have question if anyone can help me with:Q: how can I create functions in R to compute the area
> (A), centroid (Cx and Cy) and perimeter (P) of a polygon list .  I want to write R functions to
> compute these quantities for individual polygons, as well asan overall function to take a polygon
> list and return a data frame with four columns and the samenumber of rows as polygons in the list.
> Each quantity should correspond to each column. it is (sp) class object. > Hope to find any suggestion or answer

The spatstat package will enable you to do all this pretty easily.  See

     ?centroid.owin
     ?perimeter
     ?area.owin

You will need to convert your polygons to objects of class "owin".  The
as.owin() function should handle this for you.

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: R Help

Thu, 12/20/2018 - 16:08
Package rgeos is a good starting point.

Esu Esu via R-sig-Geo <[hidden email]> escreveu no dia quinta,
20/12/2018 à(s) 21:58:

> Dear All,
> I am new to R-programming. I have question if anyone can help me with:Q:
> how can I create functions in R to compute the area (A), centroid (Cx and
> Cy) and perimeter (P) of a polygon list .  I want to write R functions to
> compute these quantities for individual polygons, as well asan overall
> function to take a polygon list and return a data frame with four columns
> and the samenumber of rows as polygons in the list.  Each quantity
> should correspond to each column. it is (sp) class object.
> Hope to find any suggestion or answer
>  RegardsMuhsien
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

R Help

Thu, 12/20/2018 - 15:56
Dear All,
I am new to R-programming. I have question if anyone can help me with:Q: how can I create functions in R to compute the area (A), centroid (Cx and Cy) and perimeter (P) of a polygon list .  I want to write R functions to compute these quantities for individual polygons, as well asan overall function to take a polygon list and return a data frame with four columns and the samenumber of rows as polygons in the list.  Each quantity should correspond to each column. it is (sp) class object. 
Hope to find any suggestion or answer 
 RegardsMuhsien 
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: writeRaster: BSQ despite BIL is requested

Wed, 12/19/2018 - 07:45
Thanks Roger,

Just to summarize, not only the hdr files are correct, the hdr files
are consistent with the ordering in the data files:

require(rgdal)
require(raster)
m <- matrix(rep(10,20),ncol=5)
b <- brick(raster(m),raster(10*m),raster(100*m))
b
writeRaster(b, file="bwrast", format="ENVI", datatype="INT2U",
            bandorder="BIL", overwrite=TRUE)

writes a correct BSQ file, despite having requested BIL order

writeRaster(b, file="bwrast2", format="ENVI", datatype="INT2U",
            options="INTERLEAVE=BIL", overwrite=TRUE)

writes a correct BIL file (and this is a useful solution, thanks).

I tend to think that the fact that writeRaster() ignores
bandorder="BIL" is a bug.

Agus
(mi R is using Loaded GDAL runtime: GDAL 2.3.2, released 2018/09/21)

On Wed, Dec 19, 2018 at 11:52 AM Roger Bivand <[hidden email]> wrote:
>
> On Wed, 19 Dec 2018, Agustin Lobo wrote:
>
> > I do
> >
> > writeRaster(testin,
> > file="testin",format="ENVI",datatype="INT2U",bandorder="BIL",overwrite=TRUE)
> >
> > but get an image with BSQ order
> > (rda object: https://www.dropbox.com/s/or5h7yb9nd52e94/testin.rda?dl=0)
>
> Which version of GDAL is under all of this? It doesn't matter here, but
> might have mattered.
>
> raster::writeRaster() puts interleave = bsq in the *.hdr files. "BIP" and
> does not seem to do anything. However:
>
> writeGDAL(as(testin, "SpatialGridDataFrame"), fname="testinsp.envi",
> drivername="ENVI", type="UInt16", options="INTERLEAVE=BIL",
> setStatistics=TRUE)
>
> yields interleave = bil in the *.hdr file. Using the same route, I get:
>
> writeRaster(testin, file="testin", format="ENVI", datatype="INT2U",
> options="INTERLEAVE=BIL", overwrite=TRUE)
>
> with interleave = bil in the *.hdr file. I'm not sure where
> raster::writeRaster() drops the options definitions given in bandorder=,
> maybe ENVI is not a 'native' file format?
>
> Hope this helps,
>
> Roger
>
>
> > Thanks
> > Agus
> >
> > R version 3.5.0 (2018-04-23)
> > Platform: x86_64-pc-linux-gnu (64-bit)
> > Running under: Debian GNU/Linux buster/sid
> >
> > Matrix products: default
> > BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
> > LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0
> >
> > locale:
> > [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
> > LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
> > LC_MONETARY=en_GB.UTF-8
> > [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C
> >               LC_ADDRESS=C               LC_TELEPHONE=C
> > [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > other attached packages:
> > [1] raster_2.7-15 rgdal_1.3-6   sp_1.3-1
> >
> >
> > Agus
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; e-mail: [hidden email]
> https://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: writeRaster: BSQ despite BIL is requested

Wed, 12/19/2018 - 04:51
On Wed, 19 Dec 2018, Agustin Lobo wrote:

> I do
>
> writeRaster(testin,
> file="testin",format="ENVI",datatype="INT2U",bandorder="BIL",overwrite=TRUE)
>
> but get an image with BSQ order
> (rda object: https://www.dropbox.com/s/or5h7yb9nd52e94/testin.rda?dl=0)

Which version of GDAL is under all of this? It doesn't matter here, but
might have mattered.

raster::writeRaster() puts interleave = bsq in the *.hdr files. "BIP" and
does not seem to do anything. However:

writeGDAL(as(testin, "SpatialGridDataFrame"), fname="testinsp.envi",
drivername="ENVI", type="UInt16", options="INTERLEAVE=BIL",
setStatistics=TRUE)

yields interleave = bil in the *.hdr file. Using the same route, I get:

writeRaster(testin, file="testin", format="ENVI", datatype="INT2U",
options="INTERLEAVE=BIL", overwrite=TRUE)

with interleave = bil in the *.hdr file. I'm not sure where
raster::writeRaster() drops the options definitions given in bandorder=,
maybe ENVI is not a 'native' file format?

Hope this helps,

Roger


> Thanks
> Agus
>
> R version 3.5.0 (2018-04-23)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Debian GNU/Linux buster/sid
>
> Matrix products: default
> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0
>
> locale:
> [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
> LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
> LC_MONETARY=en_GB.UTF-8
> [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C
>               LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] raster_2.7-15 rgdal_1.3-6   sp_1.3-1
>
>
> Agus
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway

Pages