Re: [R-sig-Geo] jitter within polygon

2017-01-27 Thread Paul Lantos
Thanks, will take a look!

Paul

From: obrlsoi...@gmail.com [mailto:obrlsoi...@gmail.com]
Sent: Saturday, January 28, 2017 1:03 AM
To: Paul Lantos ; r-sig-geo@r-project.org; obrl_soil 

Subject: RE: [R-sig-Geo] jitter within polygon

Maybe try this sampler - 
https://gist.github.com/obrl-soil/839b192da46978351733483421db22f8

You’d want to run it multiple times and cycle through the outputs, if I’m 
interpreting your request correctly.

Cheers
@obrl_soil

From: Paul Lantos
Sent: Saturday, 28 January 2017 3:30 PM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] jitter within polygon

I am trying to figure out how to randomly jitter points within an overlying 
polygon structure.

I can easily jitter the points themselves, but I would like this to be 
constrained by the boundaries of polygons containing the points.

This isn't for visualization - I can do that easily enough in GIS. I actually 
need to generate coordinates.

Thanks,
Paul

Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP   Contact
Departments of Internal Medicine and Pediatrics   
919-684-6355 (Pediatric Infectious Diseases)
Pediatric Infectious Diseases   
 919-681-8263 (Hospital Medicine)
General Internal Medicine   
 paul.lan...@duke.edu
Duke University School of Medicine  
   @PaulLantos
Duke Global Health Institute


   [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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

Re: [R-sig-Geo] jitter within polygon

2017-01-27 Thread Paul Lantos
Ok, thanks. It's for about 100,000 points within thousands of polygons, and 
they need to 1) remain within a polygon and 2) retain original attribute data. 
Could be a challenging workflow...
Paul

-Original Message-
From: Baldwin, Jim -FS [mailto:jbald...@fs.fed.us] 
Sent: Saturday, January 28, 2017 1:22 AM
To: Paul Lantos ; r-sig-geo@r-project.org
Subject: RE: jitter within polygon

Point-in-polygon routines are pretty fast and straightforward to use.  If it's 
about reducing computing time, then maybe for "irregular" polygons it would be 
easier to stratify the points into two groups:  those points whose jittering 
would not go outside the polygon and those that might and only use 
point-in-polygon on the potentially outside points.  However, I'd try the 
point-in-polygon route first and see if it is fast enough first.


Jim


-Original Message-
From: Paul Lantos [mailto:paul.lan...@duke.edu] 
Sent: Friday, January 27, 2017 9:49 PM
To: Baldwin, Jim -FS ; r-sig-geo@r-project.org
Subject: RE: jitter within polygon

Thanks, Jim. There isn't a way to specify the polygons a priori in order to 
constrain the jittering?

Paul

-Original Message-
From: Baldwin, Jim -FS [mailto:jbald...@fs.fed.us] 
Sent: Saturday, January 28, 2017 12:47 AM
To: Paul Lantos ; r-sig-geo@r-project.org
Subject: RE: jitter within polygon

Sounds like you need a "point-in-polygon" routine to determine if the jittered 
point is still within the polygon.

R has several such routines.  Here are two:

  pnt.in.poly in the SDMTools package
  point.in.polygon in the sp package

Mathematica has several options, too.

Jim



-Original Message-
From: R-sig-Geo [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Paul 
Lantos
Sent: Friday, January 27, 2017 9:30 PM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] jitter within polygon

I am trying to figure out how to randomly jitter points within an overlying 
polygon structure.

I can easily jitter the points themselves, but I would like this to be 
constrained by the boundaries of polygons containing the points.

This isn't for visualization - I can do that easily enough in GIS. I actually 
need to generate coordinates.

Thanks,
Paul

Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP   Contact
Departments of Internal Medicine and Pediatrics   
919-684-6355 (Pediatric Infectious Diseases)
Pediatric Infectious Diseases   
 919-681-8263 (Hospital Medicine)
General Internal Medicine   
 paul.lan...@duke.edu
Duke University School of Medicine  
   @PaulLantos
Duke Global Health Institute


[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo=CwIFAg=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=i4hWU9_Gy7AChLfLUddISsWbzbyNPkZ_ooonniSZoIY=ner0DbrTVNhQ2EgrDupUQkMsjZKVTOJHFF9CSyjUypU=
 




This electronic message contains information generated by the USDA solely for 
the intended recipients. Any unauthorized interception of this message or the 
use or disclosure of the information it contains may violate the law and 
subject the violator to civil or criminal penalties. If you believe you have 
received this message in error, please notify the sender and delete the email 
immediately.

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


Re: [R-sig-Geo] jitter within polygon

2017-01-27 Thread Baldwin, Jim -FS
Point-in-polygon routines are pretty fast and straightforward to use.  If it's 
about reducing computing time, then maybe for "irregular" polygons it would be 
easier to stratify the points into two groups:  those points whose jittering 
would not go outside the polygon and those that might and only use 
point-in-polygon on the potentially outside points.  However, I'd try the 
point-in-polygon route first and see if it is fast enough first.


Jim


-Original Message-
From: Paul Lantos [mailto:paul.lan...@duke.edu] 
Sent: Friday, January 27, 2017 9:49 PM
To: Baldwin, Jim -FS ; r-sig-geo@r-project.org
Subject: RE: jitter within polygon

Thanks, Jim. There isn't a way to specify the polygons a priori in order to 
constrain the jittering?

Paul

-Original Message-
From: Baldwin, Jim -FS [mailto:jbald...@fs.fed.us] 
Sent: Saturday, January 28, 2017 12:47 AM
To: Paul Lantos ; r-sig-geo@r-project.org
Subject: RE: jitter within polygon

Sounds like you need a "point-in-polygon" routine to determine if the jittered 
point is still within the polygon.

R has several such routines.  Here are two:

  pnt.in.poly in the SDMTools package
  point.in.polygon in the sp package

Mathematica has several options, too.

Jim



-Original Message-
From: R-sig-Geo [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Paul 
Lantos
Sent: Friday, January 27, 2017 9:30 PM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] jitter within polygon

I am trying to figure out how to randomly jitter points within an overlying 
polygon structure.

I can easily jitter the points themselves, but I would like this to be 
constrained by the boundaries of polygons containing the points.

This isn't for visualization - I can do that easily enough in GIS. I actually 
need to generate coordinates.

Thanks,
Paul

Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP   Contact
Departments of Internal Medicine and Pediatrics   
919-684-6355 (Pediatric Infectious Diseases)
Pediatric Infectious Diseases   
 919-681-8263 (Hospital Medicine)
General Internal Medicine   
 paul.lan...@duke.edu
Duke University School of Medicine  
   @PaulLantos
Duke Global Health Institute


[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo=CwIFAg=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=i4hWU9_Gy7AChLfLUddISsWbzbyNPkZ_ooonniSZoIY=ner0DbrTVNhQ2EgrDupUQkMsjZKVTOJHFF9CSyjUypU=
 




This electronic message contains information generated by the USDA solely for 
the intended recipients. Any unauthorized interception of this message or the 
use or disclosure of the information it contains may violate the law and 
subject the violator to civil or criminal penalties. If you believe you have 
received this message in error, please notify the sender and delete the email 
immediately.

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


Re: [R-sig-Geo] jitter within polygon

2017-01-27 Thread obrlsoilau
Maybe try this sampler - 
https://gist.github.com/obrl-soil/839b192da46978351733483421db22f8 

You’d want to run it multiple times and cycle through the outputs, if I’m 
interpreting your request correctly.

Cheers
@obrl_soil

From: Paul Lantos
Sent: Saturday, 28 January 2017 3:30 PM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] jitter within polygon

I am trying to figure out how to randomly jitter points within an overlying 
polygon structure.

I can easily jitter the points themselves, but I would like this to be 
constrained by the boundaries of polygons containing the points.

This isn't for visualization - I can do that easily enough in GIS. I actually 
need to generate coordinates.

Thanks,
Paul

Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP   Contact
Departments of Internal Medicine and Pediatrics   
919-684-6355 (Pediatric Infectious Diseases)
Pediatric Infectious Diseases   
 919-681-8263 (Hospital Medicine)
General Internal Medicine   
 paul.lan...@duke.edu
Duke University School of Medicine  
   @PaulLantos
Duke Global Health Institute


[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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

Re: [R-sig-Geo] jitter within polygon

2017-01-27 Thread Baldwin, Jim -FS
Sounds like you need a "point-in-polygon" routine to determine if the jittered 
point is still within the polygon.

R has several such routines.  Here are two:

  pnt.in.poly in the SDMTools package
  point.in.polygon in the sp package

Mathematica has several options, too.

Jim



-Original Message-
From: R-sig-Geo [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Paul 
Lantos
Sent: Friday, January 27, 2017 9:30 PM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] jitter within polygon

I am trying to figure out how to randomly jitter points within an overlying 
polygon structure.

I can easily jitter the points themselves, but I would like this to be 
constrained by the boundaries of polygons containing the points.

This isn't for visualization - I can do that easily enough in GIS. I actually 
need to generate coordinates.

Thanks,
Paul

Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP   Contact
Departments of Internal Medicine and Pediatrics   
919-684-6355 (Pediatric Infectious Diseases)
Pediatric Infectious Diseases   
 919-681-8263 (Hospital Medicine)
General Internal Medicine   
 paul.lan...@duke.edu
Duke University School of Medicine  
   @PaulLantos
Duke Global Health Institute


[[alternative HTML version deleted]]

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




This electronic message contains information generated by the USDA solely for 
the intended recipients. Any unauthorized interception of this message or the 
use or disclosure of the information it contains may violate the law and 
subject the violator to civil or criminal penalties. If you believe you have 
received this message in error, please notify the sender and delete the email 
immediately.

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


[R-sig-Geo] jitter within polygon

2017-01-27 Thread Paul Lantos
I am trying to figure out how to randomly jitter points within an overlying 
polygon structure.

I can easily jitter the points themselves, but I would like this to be 
constrained by the boundaries of polygons containing the points.

This isn't for visualization - I can do that easily enough in GIS. I actually 
need to generate coordinates.

Thanks,
Paul

Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP   Contact
Departments of Internal Medicine and Pediatrics   
919-684-6355 (Pediatric Infectious Diseases)
Pediatric Infectious Diseases   
 919-681-8263 (Hospital Medicine)
General Internal Medicine   
 paul.lan...@duke.edu
Duke University School of Medicine  
   @PaulLantos
Duke Global Health Institute


[[alternative HTML version deleted]]

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


Re: [R-sig-Geo] R function checking/transforming CRS layer R function

2017-01-27 Thread Hodgess, Erin
Hi again!


Give this bad boy a shot:






CRSfunction<-function(couche)

 {


   prj_couche<-couche@proj4string

   prj_couche_c <- couche@proj4string@projargs

   prj<-CRS("+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3

x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs")

   prj_c <- "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3

x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs"


   if (prj_couche_c != prj_c){

 couche@proj4string <- prj

   }

 }




Erin M. Hodgess
Associate Professor
Department of Mathematics and Statistics
University of Houston - Downtown
mailto: hodge...@uhd.edu

From: Tristan Bourgeois 
Sent: Friday, January 27, 2017 4:39 AM
To: Hodgess, Erin
Cc: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] R function checking/transforming CRS layer R function

Hi Erin !

Yes,   I tried to apply my function to "UH"  which is a shapefile.




2017-01-27 11:28 GMT+01:00 Hodgess, Erin 
>:
Hi Tristan!

I'm looking at your code right now.  What is your input, please; the UH?

Thanks,
Erin


Erin M. Hodgess
Associate Professor
Department of Mathematics and Statistics
University of Houston - Downtown
mailto: hodge...@uhd.edu


From: R-sig-Geo 
> on 
behalf of Tristan Bourgeois 
>
Sent: Friday, January 27, 2017 3:41 AM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] R function checking/transforming CRS layer R function

Dear all,

I'm trying to build up an r function able to check if the projection system
of a layer is in Lambert93 (WSG code : 2154) .
If the condition is false I want to transform the CRS into Lambert 93.

This is what I wrote :

> CRSfunction<-function(couche)
+ {
+   prj_couche<-CRS(couche)
+   prj<-CRS("+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
+x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs")
+   if (prj_couche!=prj)
+ {CRS(couche)="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
+x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs" }
+ }
> CRSfunction(UH)
Error in CRS(couche) : no method for coercing this S4 class to a vector
In addition: Warning message:
In is.na(projargs) : is.na() applied to non-(list 
or vector) of type 'S4'
Called from: CRS(couche)
Browse[1]> Q


Does anybody can help to deal with the mistake I 've made ??

Plus, I'm not sure the function will work with both raster and shapefiles.

Cheers.


Tristan Bourgeois.
R New User

[[alternative HTML version deleted]]

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



--
Tristan Bourgeois

[[alternative HTML version deleted]]

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


Re: [R-sig-Geo] R function checking/transforming CRS layer R function

2017-01-27 Thread Tristan Bourgeois
Hi Erin !

Yes,   I tried to apply my function to "UH"  which is a shapefile.




2017-01-27 11:28 GMT+01:00 Hodgess, Erin :

> Hi Tristan!
>
> I'm looking at your code right now.  What is your input, please; the UH?
>
> Thanks,
> Erin
>
>
> Erin M. Hodgess
> Associate Professor
> Department of Mathematics and Statistics
> University of Houston - Downtown
> mailto: hodge...@uhd.edu
>
> 
> From: R-sig-Geo  on behalf of Tristan
> Bourgeois 
> Sent: Friday, January 27, 2017 3:41 AM
> To: r-sig-geo@r-project.org
> Subject: [R-sig-Geo] R function checking/transforming CRS layer R function
>
> Dear all,
>
> I'm trying to build up an r function able to check if the projection system
> of a layer is in Lambert93 (WSG code : 2154) .
> If the condition is false I want to transform the CRS into Lambert 93.
>
> This is what I wrote :
>
> > CRSfunction<-function(couche)
> + {
> +   prj_couche<-CRS(couche)
> +   prj<-CRS("+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
> +x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs")
> +   if (prj_couche!=prj)
> + {CRS(couche)="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
> +x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs" }
> + }
> > CRSfunction(UH)
> Error in CRS(couche) : no method for coercing this S4 class to a vector
> In addition: Warning message:
> In is.na(projargs) : is.na() applied to non-(list or vector) of type 'S4'
> Called from: CRS(couche)
> Browse[1]> Q
>
>
> Does anybody can help to deal with the mistake I 've made ??
>
> Plus, I'm not sure the function will work with both raster and shapefiles.
>
> Cheers.
>
>
> Tristan Bourgeois.
> R New User
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Tristan Bourgeois

[[alternative HTML version deleted]]

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


Re: [R-sig-Geo] R function checking/transforming CRS layer R function

2017-01-27 Thread Hodgess, Erin
Hi Tristan!

I'm looking at your code right now.  What is your input, please; the UH?

Thanks,
Erin


Erin M. Hodgess
Associate Professor
Department of Mathematics and Statistics
University of Houston - Downtown
mailto: hodge...@uhd.edu


From: R-sig-Geo  on behalf of Tristan 
Bourgeois 
Sent: Friday, January 27, 2017 3:41 AM
To: r-sig-geo@r-project.org
Subject: [R-sig-Geo] R function checking/transforming CRS layer R function

Dear all,

I'm trying to build up an r function able to check if the projection system
of a layer is in Lambert93 (WSG code : 2154) .
If the condition is false I want to transform the CRS into Lambert 93.

This is what I wrote :

> CRSfunction<-function(couche)
+ {
+   prj_couche<-CRS(couche)
+   prj<-CRS("+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
+x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs")
+   if (prj_couche!=prj)
+ {CRS(couche)="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
+x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs" }
+ }
> CRSfunction(UH)
Error in CRS(couche) : no method for coercing this S4 class to a vector
In addition: Warning message:
In is.na(projargs) : is.na() applied to non-(list or vector) of type 'S4'
Called from: CRS(couche)
Browse[1]> Q


Does anybody can help to deal with the mistake I 've made ??

Plus, I'm not sure the function will work with both raster and shapefiles.

Cheers.


Tristan Bourgeois.
R New User

[[alternative HTML version deleted]]

___
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] R function checking/transforming CRS layer R function

2017-01-27 Thread Tristan Bourgeois
Dear all,

I'm trying to build up an r function able to check if the projection system
of a layer is in Lambert93 (WSG code : 2154) .
If the condition is false I want to transform the CRS into Lambert 93.

This is what I wrote :

> CRSfunction<-function(couche)
+ {
+   prj_couche<-CRS(couche)
+   prj<-CRS("+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
+x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs")
+   if (prj_couche!=prj)
+ {CRS(couche)="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
+x_0=70 +y_0=660 +ellps=GRS80 +units=m +no_defs" }
+ }
> CRSfunction(UH)
Error in CRS(couche) : no method for coercing this S4 class to a vector
In addition: Warning message:
In is.na(projargs) : is.na() applied to non-(list or vector) of type 'S4'
Called from: CRS(couche)
Browse[1]> Q


Does anybody can help to deal with the mistake I 've made ??

Plus, I'm not sure the function will work with both raster and shapefiles.

Cheers.


Tristan Bourgeois.
R New User

[[alternative HTML version deleted]]

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