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: 1 hour 3 min ago

Convert map pdf in raster

9 hours 58 min ago
Hello,

Is it possible to convert a map im pdf to a raster?
Another question. I need to obtain a raster of land use and land cover of
Europe. Which site to choose?

Thanks,

Lara

        [[alternative HTML version deleted]]

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

Re: GWR Output Attributes

12 hours 50 min ago
On Tue, 26 Mar 2019, Roger Bivand wrote:

> On Tue, 26 Mar 2019, James Garrett wrote:
>
>>  Dear R-Sig-Geo List,
>>
>>  I am hoping to verify the output variables from a gwr model (package
>>  spgwr). I've searched through the archives and haven't been able to find
>>  exactly what a few are, although I have a strong guess from the package
>>  description:
>>
>>  SDF a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame
>>  object (see package "sp") with *fit.points, weights, GWR coefficient
>>  estimates, Rsquared, and coefficient standard errors in its "data" slot.*
>
> There is no need to guess. Help pages have examples. Run:
>
> library(spgwr)
> example(gwr)
> str(col.gauss)
> str(col.gauss$SDF)
> names(col.gauss$SDF)
>
> to examine the contents of the objects of the first run. Note that the rest
> of the example script shows why GWR is unreliable.
I've just used pkgdown to commit the processed help pages of spgwr to
R-Forge:

http://rspatial.r-forge.r-project.org/spgwr/reference/gwr.html#examples

is the rendered version of running example(gwr) yourself, and is less
effective because you can't play with the output.

Roger

>
> Don't guess, don't google or SO, just use the examples in the help pages
> actively, for example changing the formula or argument values to see what the
> arguments do. Do use alternative implementations to check your assumptions,
> such as GWmodel. Do read vignettes: vignette("GWR").
>
> Hope this helps,
>
> Roger
>
>
>>
>>  Is this correct?
>>  sum_w = sum of the weights
>>  Intrc = X Intercept
>>  gtVI(F) = GWR coefficient estimates of the X intercept
>>  gwr_e = gwr residuals
>>  pred = Y prediction
>>  localR2 = local R2.
>>
>>  I apologize if this is rudimentary. Thanks so much in advance,
>>
>>  James
>>
>>
>
>
--
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: GWR Output Attributes

13 hours 56 min ago
On Tue, 26 Mar 2019, James Garrett wrote:

> Dear R-Sig-Geo List,
>
> I am hoping to verify the output variables from a gwr model (package
> spgwr). I've searched through the archives and haven't been able to find
> exactly what a few are, although I have a strong guess from the package
> description:
>
> SDF a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame
> object (see package "sp") with *fit.points, weights, GWR coefficient
> estimates, Rsquared, and coefficient standard errors in its "data" slot.*
There is no need to guess. Help pages have examples. Run:

library(spgwr)
example(gwr)
str(col.gauss)
str(col.gauss$SDF)
names(col.gauss$SDF)

to examine the contents of the objects of the first run. Note that the
rest of the example script shows why GWR is unreliable.

Don't guess, don't google or SO, just use the examples in the help pages
actively, for example changing the formula or argument values to see what
the arguments do. Do use alternative implementations to check your
assumptions, such as GWmodel. Do read vignettes: vignette("GWR").

Hope this helps,

Roger


>
> Is this correct?
> sum_w = sum of the weights
> Intrc = X Intercept
> gtVI(F) = GWR coefficient estimates of the X intercept
> gwr_e = gwr residuals
> pred = Y prediction
> localR2 = local R2.
>
> I apologize if this is rudimentary. Thanks so much in advance,
>
> James
>
>
--
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

GWR Output Attributes

Mon, 03/25/2019 - 19:23
Dear R-Sig-Geo List,

I am hoping to verify the output variables from a gwr model (package
spgwr). I've searched through the archives and haven't been able to find
exactly what a few are, although I have a strong guess from the package
description:

 SDF a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame
object (see package "sp") with *fit.points, weights, GWR coefficient
estimates, Rsquared, and coefficient standard errors in its "data" slot.*

Is this correct?
sum_w = sum of the weights
Intrc = X Intercept
gtVI(F) = GWR coefficient estimates of the X intercept
gwr_e = gwr residuals
pred = Y prediction
localR2 = local R2.

I apologize if this is rudimentary. Thanks so much in advance,

James

--

*James Garrett*

Clemson University

Graduate Student, Forest Resources

School of Agricultural, Forest, and Environmental Sciences

Phone (334)-790-2483

Advisor: Dr. Skip Van Bloem

        [[alternative HTML version deleted]]

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

read error after mosaic_rasters

Mon, 03/25/2019 - 17:08
Hi,

I am using mosaic_rasters from gdalUtils to combine different raster files. More specifically, I am using the 12 tiles that cover Southern Africa from the well-known Hansen et al. (2013) forest map (1.1) that can be downloaded here: http://earthenginepartners.appspot.com/science-2013-global-forest/download_v1.1.html. I am using the tree cover, forest gain and forest loss data. All is working fine for the forest gain and forest loss files but I receive an error when combing the tree cover files (which are the largest).

Below you will find my code. Note that "tree_cover_files" is a vector that points towards the 12 tiles stored in a local folder. I am receiving the following error after some time:

Checking gdal_installation...
Scanning for GDAL installations...
Checking the gdalUtils_gdalPath option...
GDAL version 2.2.4
GDAL command being used: "C:\OSGeo4W64\bin\gdalbuildvrt.exe" -input_file_list "c:\Temp\RtmpkRd30l\file4687024480a.txt" "c:\Temp\RtmpkRd30l\file4684596162f.vrt"
Checking gdal_installation...
Scanning for GDAL installations...
Checking the gdalUtils_gdalPath option...
GDAL version 2.2.4
GDAL command being used: "C:\OSGeo4W64\bin\gdal_translate.exe" -of "GTiff" "c:\Temp\RtmpkRd30l\file4684596162f.vrt" "P:/globiom/Projects/ISWEL/data/forest/combined_tiles/tree_cover.tif"
Input file size is 120000, 1600000...10...20...30...40...
ERROR 1: TIFFFillStrip:Read error at scanline 39921; got 3204 bytes, expected 10047
ERROR 1: TIFFReadEncodedStrip() failed.
ERROR 1: P:/globiom/Projects/ISWEL/data/forest/tree_cover/Hansen_GFC2014_treecover2000_10S_030E.tif, band 1: IReadBlock failed at X offset 0, Y offset 39922
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 39922

I understand that this might be thread error, related to how the files are read and intermediate vrt file is constructed (https://github.com/mapnik/node-mapnik/issues/437 ) and could be solved by setting "VRT_SHARED_SOURCE" to 0. I tried to do this using setCPLConfigOption("VRT_SHARED_SOURCE", "0") in R but still receive the same error. Is this really the way to solve this or is the file perhaps corrupt (unlikely as this dataset is used by many people - I also downloaded them twice)? I hope somebody can give me advice on how to make this work.

Many thanks,
Michiel



# prepare and save template for mosaic
e <- extent(20, 40, -20, -10)
template <- raster(e)
proj4string(template) <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0") writeRaster(template, file = file.path(proj_path, "data/forest/combined_tiles/tree_cover.tif"), format="GTiff", overwrite = T)

# create mosaic
setCPLConfigOption("VRT_SHARED_SOURCE", "0") mosaic_rasters(gdalfile = tree_cover_files,
               dst_dataset = file.path(proj_path, "data/forest/combined_tiles/tree_cover.tif"), of="GTiff",
               verbose = T)
 


M. (Michiel) van Dijk, PhD
Research scholar | Ecosystems Services and Management (ESM) | International Institute for Applied Systems Analysis (IIASA) Senior researcher (out of office) | International Policy Division (IB) | Wageningen Economic Research

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

Re: R squared in lagsarlm

Thu, 03/21/2019 - 08:05
On Thu, 21 Mar 2019, Leonardo Matheus Servino wrote:

> When a linear regression is used, usually the degree of freedom, F-value,
> p-value are exposed, in text or in a table. In a lagsarlm, what parameters
> we should expose?
>

None of these make any sense in this case. This model is fitted by maximum
likelihood, so likelihood-based measures may be appropriate, but the model
is also non-linear in the spatial coefficient, so it is simply not like
OLS. However, you could represent OLS in its maximum likelihood form,
correcting the t-values not to subtract k. The provided measure is a
likelihood ratio test of the model fitted with and without the spatial
coefficient (equivalent to a test of the spatial coefficient). You can run
your own LR tests against other alternatives, and the Nagelkerke measure
is also likelihood-based. STSLS may provide other measures, but they are
not OLS-based either, being IV. Just because a supervisor or referee wants
the same measures as OLS, it doesn't mean they can get them. Certainly you
should avoid p-values as they give little guidance.

Roger

>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Livre
> de vírus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

--
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: R squared in lagsarlm

Thu, 03/21/2019 - 07:52
When a linear regression is used, usually the degree of freedom, F-value,
p-value are exposed, in text or in a table. In a lagsarlm, what parameters
we should expose?



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Livre
de vírus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

        [[alternative HTML version deleted]]

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

Re: R squared in lagsarlm

Thu, 03/21/2019 - 07:28
Do not post HTML-mail!

What do you mean by: "what parameters of SAR we should expose"? What do
you mean by SAR? Do you mean the SAR model (simultaneous autoregressive
model, a.k.a. the simultaneous spatial error model) or the SAR model
(spatial autoregressive model a.k.a. the simultaneous spatial lag model)?
If the spatial lag model, only ever report impacts, never report the
betas. Please be more precise.

Roger

On Thu, 21 Mar 2019, Leonardo Matheus Servino wrote:

> Thanks, and one more question: what parameters of SAR we should expose in
> articles?
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Livre
> de vírus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> Em qui, 21 de mar de 2019 às 10:09, Roger Bivand <[hidden email]>
> escreveu:
>
>> The Nagelkerke measure is optionally provided in the summary method:
>> Nagelkerke NJD (1991) A note on a general definition of the coefficient of
>> determination. Biometrika 78: 691-692.
>>
>> See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or
>> ?summary.sarlm.
>>
>> There is no "R squared" for these models, the likelihood ratio is a better
>> comparative measure.
>>
>> Roger
>>
>> On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:
>>
>>> Hello,
>>>
>>> I would like to know where I can find the Rsquared value in lagsarlm
>>>
>>> Thanks
>>>
>>>
>>
>> --
>> 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
>>
>
>
> --
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: R squared in lagsarlm

Thu, 03/21/2019 - 07:19
Thanks, and one more question: what parameters of SAR we should expose in
articles?

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Livre
de vírus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Em qui, 21 de mar de 2019 às 10:09, Roger Bivand <[hidden email]>
escreveu:

> The Nagelkerke measure is optionally provided in the summary method:
> Nagelkerke NJD (1991) A note on a general definition of the coefficient of
> determination. Biometrika 78: 691-692.
>
> See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or
> ?summary.sarlm.
>
> There is no "R squared" for these models, the likelihood ratio is a better
> comparative measure.
>
> Roger
>
> On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:
>
> > Hello,
> >
> > I would like to know where I can find the Rsquared value in lagsarlm
> >
> > Thanks
> >
> >
>
> --
> 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
>

--
Leonardo Matheus Servino
Pós-Graduação em Evolução e Diversidade
Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares
09606-070 São Bernardo do Campo - SP

        [[alternative HTML version deleted]]

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

Re: R squared in lagsarlm

Thu, 03/21/2019 - 07:09
The Nagelkerke measure is optionally provided in the summary method:
Nagelkerke NJD (1991) A note on a general definition of the coefficient of
determination. Biometrika 78: 691-692.

See https://r-spatial.github.io/spdep/reference/summary.sarlm.html or
?summary.sarlm.

There is no "R squared" for these models, the likelihood ratio is a better
comparative measure.

Roger

On Wed, 20 Mar 2019, Leonardo Matheus Servino wrote:

> Hello,
>
> I would like to know where I can find the Rsquared value in lagsarlm
>
> Thanks
>
>

--
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

Unsubscribe from your list

Thu, 03/21/2019 - 02:35
Dear Mr/Madam,
Please unsubscribe from your list.
Thank you in advance
Kind Regards
Nina Philipova

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

R squared in lagsarlm

Wed, 03/20/2019 - 11:51
Hello,

I would like to know where I can find the Rsquared value in lagsarlm

Thanks

--
Leonardo Matheus Servino
Pós-Graduação em Evolução e Diversidade
Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas

LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202

Rua Arcturus, 3. Jardim Antares
09606-070 São Bernardo do Campo - SP

        [[alternative HTML version deleted]]

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

Re: Reverse y-axis with geom_sf

Wed, 03/20/2019 - 09:50
>
> Date: Tue, 19 Mar 2019 15:13:37 +0100
> From: Edzer Pebesma <[hidden email]>
> To: [hidden email]
> Subject: Re: [R-sig-Geo] Reverse y-axis with geom_sf
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
>
> On 3/19/19 2:55 PM, Kent Johnson wrote:
>
> > Is there a way to invert the y axis while staying within sf (or possibly
> > sp?) The only answers I have found involve extracting the coordinates
> from
> > the sf objects and inverting or plotting from the raw data. Maybe by
> > creating a CRS with the correct orientation?
> >
> > For a very simple example with just a few vectors - the code below plots
> an
> > arrow pointing down; I would like to invert the y-axis so it points up.
> > library(sf)
> > library(ggplot2)
> > s1 <- rbind(c(9, 11), c(10, 10))
> > s2 <- rbind(c(11, 11), c(10, 10))
> > s3 <- rbind(c(10,14), c(10, 12), c(10,10))
> > mls <- st_multilinestring(list(s1,s2,s3))
> >
> > ggplot(mls) + geom_sf()
>
> You mean, like
>
> ggplot(mls * c(1, -1)) + geom_sf()
>
> ?
>
Yes, that might work well, with the addition of a correction to the axis
labels:
ggplot(mls * c(1, -1)) + geom_sf() +
  scale_y_continuous(labels=function(x) -x)

I have a raster background that will need some adjustment too, that should
be manageable.
Thanks!
Kent

Date: Tue, 19 Mar 2019 19:11:03 +0000
> From: =?UTF-8?B?SmVzw7pz?= <[hidden email]>
> To: Kent Johnson <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [R-sig-Geo] Reverse y-axis with geom_sf
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> You are welcome
>
> You could try converting sf to sp and  use the corresponding geoms
> (geom_polygon, geom_point..etc.)  plus coord_flip() or map the x and y
> aesthetics accordingly.
>
That, or just pulling the raw data out and plotting it directly, is kind of
a last resort. I would rather not have to do this level of data munging as
my actual data is moderately complex.

Thanks,
Kent

        [[alternative HTML version deleted]]

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

Re: Reverse y-axis with geom_sf

Tue, 03/19/2019 - 13:11
You are welcome

You could try converting sf to sp and  use the corresponding geoms
(geom_polygon, geom_point..etc.)  plus coord_flip() or map the x and y
aesthetics accordingly.

El mar., 19 mar. 2019 a las 18:55, Kent Johnson (<[hidden email]>)
escribió:

> On Tue, Mar 19, 2019 at 1:54 PM Jesús <[hidden email]> wrote:
>
>> Hi Kent
>> Did you try using the coord_flip function from ggplot?
>> Cheers
>> Jesús
>>
>
> Yes, I did, coord_flip() doesn't work with geom_sf():
>
> > ggplot(mls) + geom_sf() + coord_flip()
> Error: geom_sf() must be used with coord_sf()
>
> Thanks for the suggestion!
> Kent
>
>>
>> El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)
>> escribió:
>>
>>> Hi,
>>>
>>> I am working with data representing cells in a tissue sample with lines
>>> and
>>> polygonal regions defined in the same space. The cells and polygons are
>>> represented and manipulated as simple features objects and visualized
>>> using
>>> ggplot2 and geom_sf. Mostly this works very well. The problem is that the
>>> coordinate system of my data has the origin at the top left corner. For
>>> data with no CRS, geom_sf puts the origin at the bottom left so all my
>>> plots are inverted.
>>>
>>> Is there a way to invert the y axis while staying within sf (or possibly
>>> sp?) The only answers I have found involve extracting the coordinates
>>> from
>>> the sf objects and inverting or plotting from the raw data. Maybe by
>>> creating a CRS with the correct orientation?
>>>
>>> For a very simple example with just a few vectors - the code below plots
>>> an
>>> arrow pointing down; I would like to invert the y-axis so it points up.
>>> library(sf)
>>> library(ggplot2)
>>> s1 <- rbind(c(9, 11), c(10, 10))
>>> s2 <- rbind(c(11, 11), c(10, 10))
>>> s3 <- rbind(c(10,14), c(10, 12), c(10,10))
>>> mls <- st_multilinestring(list(s1,s2,s3))
>>>
>>> ggplot(mls) + geom_sf()
>>>
>>> Thank you for any help,
>>> Kent Johnson
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> [hidden email]
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>>
>> --
>> Jesús
>>
>
--
Jesús

        [[alternative HTML version deleted]]

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

Re: Reverse y-axis with geom_sf

Tue, 03/19/2019 - 12:54
On Tue, Mar 19, 2019 at 1:54 PM Jesús <[hidden email]> wrote:

> Hi Kent
> Did you try using the coord_flip function from ggplot?
> Cheers
> Jesús
>

Yes, I did, coord_flip() doesn't work with geom_sf():

> ggplot(mls) + geom_sf() + coord_flip()
Error: geom_sf() must be used with coord_sf()

Thanks for the suggestion!
Kent

>
> El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)
> escribió:
>
>> Hi,
>>
>> I am working with data representing cells in a tissue sample with lines
>> and
>> polygonal regions defined in the same space. The cells and polygons are
>> represented and manipulated as simple features objects and visualized
>> using
>> ggplot2 and geom_sf. Mostly this works very well. The problem is that the
>> coordinate system of my data has the origin at the top left corner. For
>> data with no CRS, geom_sf puts the origin at the bottom left so all my
>> plots are inverted.
>>
>> Is there a way to invert the y axis while staying within sf (or possibly
>> sp?) The only answers I have found involve extracting the coordinates from
>> the sf objects and inverting or plotting from the raw data. Maybe by
>> creating a CRS with the correct orientation?
>>
>> For a very simple example with just a few vectors - the code below plots
>> an
>> arrow pointing down; I would like to invert the y-axis so it points up.
>> library(sf)
>> library(ggplot2)
>> s1 <- rbind(c(9, 11), c(10, 10))
>> s2 <- rbind(c(11, 11), c(10, 10))
>> s3 <- rbind(c(10,14), c(10, 12), c(10,10))
>> mls <- st_multilinestring(list(s1,s2,s3))
>>
>> ggplot(mls) + geom_sf()
>>
>> Thank you for any help,
>> Kent Johnson
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
> --
> Jesús
>
        [[alternative HTML version deleted]]

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

Re: Reverse y-axis with geom_sf

Tue, 03/19/2019 - 11:54
Hi Kent
Did you try using the coord_flip function from ggplot?
Cheers
Jesús


El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<[hidden email]>)
escribió:

> Hi,
>
> I am working with data representing cells in a tissue sample with lines and
> polygonal regions defined in the same space. The cells and polygons are
> represented and manipulated as simple features objects and visualized using
> ggplot2 and geom_sf. Mostly this works very well. The problem is that the
> coordinate system of my data has the origin at the top left corner. For
> data with no CRS, geom_sf puts the origin at the bottom left so all my
> plots are inverted.
>
> Is there a way to invert the y axis while staying within sf (or possibly
> sp?) The only answers I have found involve extracting the coordinates from
> the sf objects and inverting or plotting from the raw data. Maybe by
> creating a CRS with the correct orientation?
>
> For a very simple example with just a few vectors - the code below plots an
> arrow pointing down; I would like to invert the y-axis so it points up.
> library(sf)
> library(ggplot2)
> s1 <- rbind(c(9, 11), c(10, 10))
> s2 <- rbind(c(11, 11), c(10, 10))
> s3 <- rbind(c(10,14), c(10, 12), c(10,10))
> mls <- st_multilinestring(list(s1,s2,s3))
>
> ggplot(mls) + geom_sf()
>
> Thank you for any help,
> Kent Johnson
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Jesús

        [[alternative HTML version deleted]]

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

Re: Reverse y-axis with geom_sf

Tue, 03/19/2019 - 08:13


On 3/19/19 2:55 PM, Kent Johnson wrote:
> Hi,
>
> I am working with data representing cells in a tissue sample with lines and
> polygonal regions defined in the same space. The cells and polygons are
> represented and manipulated as simple features objects and visualized using
> ggplot2 and geom_sf. Mostly this works very well. The problem is that the
> coordinate system of my data has the origin at the top left corner. For
> data with no CRS, geom_sf puts the origin at the bottom left so all my
> plots are inverted.
>
> Is there a way to invert the y axis while staying within sf (or possibly
> sp?) The only answers I have found involve extracting the coordinates from
> the sf objects and inverting or plotting from the raw data. Maybe by
> creating a CRS with the correct orientation?
>
> For a very simple example with just a few vectors - the code below plots an
> arrow pointing down; I would like to invert the y-axis so it points up.
> library(sf)
> library(ggplot2)
> s1 <- rbind(c(9, 11), c(10, 10))
> s2 <- rbind(c(11, 11), c(10, 10))
> s3 <- rbind(c(10,14), c(10, 12), c(10,10))
> mls <- st_multilinestring(list(s1,s2,s3))
>
> ggplot(mls) + geom_sf() You mean, like

ggplot(mls * c(1, -1)) + geom_sf()

?

>
> Thank you for any help,
> Kent Johnson
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

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

pEpkey.asc (2K) Download Attachment

Reverse y-axis with geom_sf

Tue, 03/19/2019 - 07:55
Hi,

I am working with data representing cells in a tissue sample with lines and
polygonal regions defined in the same space. The cells and polygons are
represented and manipulated as simple features objects and visualized using
ggplot2 and geom_sf. Mostly this works very well. The problem is that the
coordinate system of my data has the origin at the top left corner. For
data with no CRS, geom_sf puts the origin at the bottom left so all my
plots are inverted.

Is there a way to invert the y axis while staying within sf (or possibly
sp?) The only answers I have found involve extracting the coordinates from
the sf objects and inverting or plotting from the raw data. Maybe by
creating a CRS with the correct orientation?

For a very simple example with just a few vectors - the code below plots an
arrow pointing down; I would like to invert the y-axis so it points up.
library(sf)
library(ggplot2)
s1 <- rbind(c(9, 11), c(10, 10))
s2 <- rbind(c(11, 11), c(10, 10))
s3 <- rbind(c(10,14), c(10, 12), c(10,10))
mls <- st_multilinestring(list(s1,s2,s3))

ggplot(mls) + geom_sf()

Thank you for any help,
Kent Johnson

        [[alternative HTML version deleted]]

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

Calculating weighted spatial means globally across grid cells using NetCDF file

Mon, 03/18/2019 - 09:00
Hi there,
I am currently working on a project that involves climate model data stored in a NetCDF file. I am currently trying to calculate "weighted" spatial annual "global" averages for precipitation. I need to do this for each of the 95 years of global precipitation data that I have. The idea would be to somehow apply weights to each grid cell by using the cosine of its latitude (which means latitude grid cells at the equator would have a weight of 1 (i.e. the cosine of 0 degrees is 1), and the poles would have a value of 1 (as the cosine of 90 is 1)). Then, I would be in a position to calculate annual weighted averages based on averaging each grid cell. 
I have an idea how to do this conceptually, but I am not sure where to begin writing a script in R to apply the weights across all grid cells and then average these for each of the 95 years. I would greatly appreciate any help with this, or any resources that may be helpful!!!
At the very least, I have opened the .nc file and read-in the NetCDF variables, as shown below:
ncfname<-"MaxPrecCCCMACanESM2rcp45.nc"
Prec<-raster(ncfname)
print(Prec)
Model<-nc_open(ncfname)
get<-ncvar_get(Model,"onedaymax")longitude<-ncvar_get(Model, "lon")
latitude<-ncvar_get(Model, "lat")
Year<-ncvar_get(Model, "Year")

Additionally, let's say that I wanted to create a time series of these newly derived weighted averaged for a specific location or region, the following code that I previously used to show trends over the 95 years for one-day maximum precipitation works, but I would just need to change it slightly to use the annual weighted means? :
r_brick<-brick(get, xmn=min(latitude), xmx=max(latitude), ymn=min(longitude), ymx=max(longitude), crs=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs+ towgs84=0,0,0"))
r_brick<-flip(t(r_brick), direction='y')
randompointlon<-13.178
randompointlat<--59.548
Hope<-extract(r_brick, SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')
df<-data.frame(year=seq(from=1, to=95, by=1), Precipitation=t(Hope))
ggplot(data=df, aes(x=Year, y=Precipitation, group=1))+geom_line()+ggtitle("One-day maximum precipitation (mm/day) trend for Barbados for CanESM2 RCP4.5")


Also, if it helps, here is what the .nc file contains:

3 variables (excluding dimension variables):
        double onedaymax[lon,lat,time]   (Contiguous storage)  
            units: mm/day
        double fivedaymax[lon,lat,time]   (Contiguous storage)  
            units: mm/day
        short Year[time]   (Contiguous storage)  

     3 dimensions:
        time  Size:95
        lat  Size:64
            units: degree North
        lon  Size:128
            units: degree East
Again, any assistance would be extremely valuable with this! I look forward to your response!

        [[alternative HTML version deleted]]

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

Re: Correlograms of Moran's I with progressive Bonferroni correction

Mon, 03/18/2019 - 07:59
Hi Roger,

According to the book "Numerical Ecology" by Legendre&Legendre in 2012, a
progressive (sequential) Bonferroni correction is a modified version of
Bonferroni correction, where the Bonferroni-corrected level is computed for
each distance class separately instead of using a consistent level for all
distance classes. This is done by using for each distance class the number
of tests actually performed up to that distance class. For example, if we
have 10 distance classes, and we use a=0.05 as a probability level, then
the adjusted a (a') for the first distance class is a'=a/1=0.05, for the
second distance class is a'=a/2=0.025 ... for the 10th distance class is
a'=a/10=0.005.

I've checked the mpmcorrelogram package, it seems that this package is for
creating multivariate correlograms. But what I hope to get is correlograms
of autocorrelation over one variate (e.g. Moran's I).

Hope this is clearer. Thank you for your help.

Mingke

On Mon, Mar 18, 2019 at 5:41 AM Roger Bivand <[hidden email]> wrote:

> On Sun, 17 Mar 2019, Mingke Li wrote:
>
> > Dear list,
> >
> > I am trying to generate a correlogram of Moran's I, with symbols showing
> if
> > the coefficient is significant or not after the progressive Bonferroni
> > correction. Now I'm using the "correlog" function in the package ncf to
> > calculate the coefficients among all distance classes. I symbolized the
> > dots in the plot to show if they are significant or not (after
> progressive
> > Bonferroni correction), say, open circles for non-significant
> coefficients,
> > and solid circles for significant coefficients.
>
> Explain what you mean here by progressive Bonferroni correction, please.
> Could you rather see what is done in the mpmcorrelogram package, and
> report back if it makes sense?
>
> Roger
>
> >
> > These are the codes I used in R:
> >
> >> correlog.L2.2014new <- correlog(Grid.2014.all$Lng, Grid.2014.all$Lat,
> > Grid.2014.all$L2_Average,latlon = T, na.rm=T, increment=5, resamp=200)
> >> for (i in list(1:length(correlog.L2.2014new$p))) {
> >  correlog.L2.2014new$adjp[i]=correlog.L2.2014new$p[i]*i
> > }
> >> plot(correlog.L2.2014new$correlation[1:80], type="b", cex=1.5, lwd=1.5,
> > ylim=c(-0.1,0.7),
> >     pch=ifelse(((correlog.L2.2014new$adjp>0.05)),1,16),
> >     xlab="Distance (km)", ylab="Moran's I", cex.lab=2, cex.axis=1.5);
> > abline(h=0)
> >
> > I also found the function "sp.correlogram" in the package spdep to make
> the
> > correlogram with Bonferroni correction.
> >
> > Now I have three questions:
> >
> > 1. Can I set a "up-limit" to the "correlog" function? For example, if I
> > just need the first 80 distance classes to generate the graph (as shown
> in
> > the plot code), is it possible to let the "correlog" function skip the
> rest
> > distance classes to save the computation time?
> >
> > 2. Is my code of generating p values after the progressive Bonferroni
> > correction correct? If not, how should I fix it?
> >
> > 3. Now I'm kind of correcting the p value manually based on my
> > understanding of progressive Bonferroni correction. Is there any function
> > in any R packages for creating correlograms with progressive Bonferroni
> > correction? "sp.correlogram"  has a parameter setting "p.adj.method" but
> it
> > seems do not have a progressive Bonferroni correction option?
> >
> > I just start to work with the correlograms recently; any advice or
> > solutions are welcome. Thank you in advance!
> >
> > Erin
> >
> >       [[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
>
        [[alternative HTML version deleted]]

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

Pages