When convert data/polygon from coordinates to km

Here you can suggest new features to be added to RGeostats package.

When convert data/polygon from coordinates to km

Postby radillon » Wed Jul 19, 2017 3:57 pm

I am working on a small scale (a reservoir in Ohio, USA) and ultimately will be modelling with variograms and kriging.

When do I need to transform the coordinates from my base data and polygon into km, and when should I leave it just as coordinates? When I transform to km, do I then not need to ever assign a projection?

Right now I have in my base data: a column with fish density, a column with longitude, and a column with latitude. I have assigned each column as Z, X1, X2 in my db.data object. When I calculate the variograms I want to make sure that the x-axis is actually in km.

I am also having trouble with how to get my polygon to work in general. I want my polygon to be the extent of the reservoir. So, I have a shapefile that I can successfully read into R with readOGR command.

When I plot my base data fish density, and then overlay the shapefile on top, I only see a zoomed in portion of the reservoir outline. How do I expand the plot so that the entire shapefile is shown?

Then when I go to select only the samples that are included in my polygon I get an error:
db.data=db.polygon(db.data, Reservoir)
The input object is of type ' SpatialPolygonsDataFrame '. It should be of type ' polygon '
The function is interrupted
Error: Invalid object type

This seems a crucial step so that I can set up my discretization grid for only the extent of the reservoir.

How do I get my shapefile as a polygon? And, once successful, how do I convert the polygon from coordinates to km?
radillon
 
Posts: 5
Joined: Wed Oct 05, 2016 5:38 pm

Re: When convert data/polygon from coordinates to km

Postby Didier Renard » Tue Jul 25, 2017 9:35 pm

Hello

Your post requires several answers as it contains lots of items...

Units:
RGeostats does not handle units on the coordinates. This means that the user is responsible for providing all data and parameters with the same unit. The results (thos which are distance dependent such as the variogram range) will be provided in the same unit.
As a consequence, if you decide to work in 2-D in kilometers,, you MUST define X and Y in that unit. This is also tru for 3-D case (or higher space dimension). If you work in km, do not forget to specify the polygon vertices in the same unit.

Projection:
This is a non trivial question. My advise is that, as long as the dimensions are not too large (and this seems to be your case), there is no need to apply any projection. The projection is only used to "project" your data set in a planar space where euclidean distances can be used.
In the case of large data set and even more if located close to the poles, it is necessary to apply a projection. Then this definition must be defined from the begining. It is then saved in RGeostats environment so that any subsequent calculations are performed in the projected space. So my advise is that, if you need to work in a projected space, you must set it up as soon as possible and keep it switched ON until the end of the study.
In your case, and as the coordinates of your data are provided in longitude and latitude, you NEED to perform a conversion to km. So, if not too close to the pole, you MUST define a projection (try the simplest one using cosine transform)

Polygons:
The polygons that you manipulate (shapefile) are not the ones the RGeostats handles. As a matter of fact, RGeostats handles its own sort of polygons. Use polygon.create to learn about the internal structure of Polygons within RGeostats. Unfortunately, there is no direct conversion of a shapefile in Polygon.

Graphic
When you wish to represent the data set (db) and the polygon (poly), you can overlay them:
Code: Select all
plot(db)
plot(poly,add=T)


The view is calculated as to contain the first object displayed (i.e. db). You may choose to start by plotting poly instead.
Another possibility is to use the argument xlim and ylim in order to define "by hand" the maximum coordinates of the display.

Hope this will help.
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: When convert data/polygon from coordinates to km

Postby Fabien Ors » Fri Sep 29, 2017 1:20 pm

I move this topic in "Suggestion" forum:
Would it be possible to create RGeostats polygons from SpatialPolygonsDataFrame objects (generated by sp package) ?
Fabien Ors
Administrateur du site
 
Posts: 226
Joined: Thu Sep 20, 2012 1:07 pm


Return to Global suggestions

Who is online

Users browsing this forum: No registered users and 6 guests

cron