Re: [R-sig-Geo] Spatial join/intersection in R

2019-04-30 Thread Tom Philippi
Roozbeh--

What do you want to have happen with those points? Given the units in your
figure, you could unambiguously assign them to the upper-right by adding a
small value (0.01) to both the X and Y coordinates of your points.
Whether that is a sensible thing to do depends on what your data are.

How or why do the points fall exactly on your polygon boundaries?  What
process puts them exactly on the polygon (grid cell) boundaries?  It
appears your polygon boundaries are a grid at multiples of 0.05, although
not all potential cells in a rectangle are shown.  Are there many other
points not on polygon boundaries not shown in your figure, or are points
only along grid lines?  If the latter, does it make sense to assign them to
_polygons_ rather than line segments?

If you're doing a sample draw or measuring locations with only a few
decimal points of accuracy, and generating your polygon boundaries at exact
multiples of 0.05, then it might make sense to shift all of your points +
1/10th of your point location resolution so that their coordinates never
fall on polygon boundaries.  There _might_ be situations where instead of
always adding (shifting up and right), you should randomly add or subtract
in each direction for each point, but I'm stuck viewing this as points in
sTomample units so I can't think of such a case.

Tom
.

On Tue, Apr 30, 2019 at 7:18 PM Roozbeh Valavi <
rval...@student.unimelb.edu.au> wrote:

> Dear members,
>
> I want to do a spatial join/intersection in R. The problem is that some of
> my points are lying exactly at the border of the adjacent polygons (see the
> figure attached). So these points are either falling in both or none of the
> polygons! Is there any way to avoid this?
>
> Thanks in advance.
> Roozbeh
>
>
> [image: image.png]
>
>
>
> --
> *Roozbeh Valavi*
> PhD Candidate
> The Quantitative & Applied Ecology Group 
> School of BioSciences | Faculty of Science
> The University of Melbourne, VIC 3010, Australia
> Mobile: +61 423 283 238
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Spatial join/intersection in R

2019-04-30 Thread Roozbeh Valavi
Dear members,

I want to do a spatial join/intersection in R. The problem is that some of
my points are lying exactly at the border of the adjacent polygons (see the
figure attached). So these points are either falling in both or none of the
polygons! Is there any way to avoid this?

Thanks in advance.
Roozbeh


[image: image.png]



-- 
*Roozbeh Valavi*
PhD Candidate
The Quantitative & Applied Ecology Group 
School of BioSciences | Faculty of Science
The University of Melbourne, VIC 3010, Australia
Mobile: +61 423 283 238
___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] raster - units assignment error in reading NetCDF4

2019-04-30 Thread Edzer Pebesma
It looks like this is a curvilinear grid; you could read & plot it with

library(stars)
r = read_stars("L8_OLI_2017_03_18_00_09_19_093086_L2R.nc", curvilinear =
c("lon", "lat"))
plot(r[1], border = NA)

Printing r shows the units of each of the variables. The plotting takes
a while because the data grid is not aligned with the pixel grid of the
plotting device.


On 4/30/19 12:43 PM, Alexandre Castagna wrote:
> Hi group,
> 
> I'm trying to read a NetCDF4 file, but I get the following error message:
> 
> fl <- 'L8_OLI_2017_03_18_00_09_19_093086_L2R.nc'
> r <- raster(fl, varname = 'rhos_443')
> 
> Error in (function (cl, name, valueClass)  :
>   assignment of an object of class “numeric” is not valid for @‘unit’ in an
> object of class “.SingleLayerData”; is(value, "character") is not TRUE
> 
> This data is OLI Landsat 8 atmospheric 'corrected' imagery with the ACOLITE
> software (link ).
> In a previous version of the software, exploring the file after nc_open
> function revealed that units was numeric ('num' qualifier was shown in R
> object print); but since, the developer has committed a change for all
> units to be written as characters. The unit in question is '1' (unitless,
> for bihemispherical reflectance). A new exploration after the update to
> check the units type does not show the qualifier 'num' anymore, but the
> error keep the same. Maybe R is translating '1' to 1 automatically?
> 
> I can go around and create a raster directly from data read with ncdf4
> package, like:
> 
> ncfl <- nc_open(fl)
> r <- raster(t(ncvar_get(ncfl, 'rhos_443')))
> 
> But for a number of reasons that is less ideal. A temporary link to
> download the example data file is: https://we.tl/t-nENAV7tmBg
> 
> Kind regards,
> 
> Alexandre Castagna Mourão e Lima
> 
>   [[alternative HTML version deleted]]
> 
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081


pEpkey.asc
Description: application/pgp-keys
___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] raster - units assignment error in reading NetCDF4

2019-04-30 Thread Alexandre Castagna
Hi group,

I'm trying to read a NetCDF4 file, but I get the following error message:

fl <- 'L8_OLI_2017_03_18_00_09_19_093086_L2R.nc'
r <- raster(fl, varname = 'rhos_443')

Error in (function (cl, name, valueClass)  :
  assignment of an object of class “numeric” is not valid for @‘unit’ in an
object of class “.SingleLayerData”; is(value, "character") is not TRUE

This data is OLI Landsat 8 atmospheric 'corrected' imagery with the ACOLITE
software (link ).
In a previous version of the software, exploring the file after nc_open
function revealed that units was numeric ('num' qualifier was shown in R
object print); but since, the developer has committed a change for all
units to be written as characters. The unit in question is '1' (unitless,
for bihemispherical reflectance). A new exploration after the update to
check the units type does not show the qualifier 'num' anymore, but the
error keep the same. Maybe R is translating '1' to 1 automatically?

I can go around and create a raster directly from data read with ncdf4
package, like:

ncfl <- nc_open(fl)
r <- raster(t(ncvar_get(ncfl, 'rhos_443')))

But for a number of reasons that is less ideal. A temporary link to
download the example data file is: https://we.tl/t-nENAV7tmBg

Kind regards,

Alexandre Castagna Mourão e Lima

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo