I have latitude and longitude information like 26.847905 73.9575005 for about 800 points, I need to trim these lat/lon information to say 3 decimal places.

I used the following syntax in R

# Rounding off Coordinates of each of point to 3 decimal places
shp1_DE$lon <- round(shp1_DE$coords.x1, 3)
shp1_DE$lat <- round(shp1_DE$coords.x2, 3)

Now I have many points with lat/lon for example 26.847, 73.957 etc...

I want to summarize data to these points and form point-multipoint shapefile.

After that I need to create convex hull for each of these features. How to go about it in R?

  • Welcome to GIS.se! It's unclear what you mean by 'summarise data' to a 'point-multipoint' geometry. What do your other data look like? What kind of 'summary'? Why are you reducing the decimal places of your coordinates - are you trying to create a grid and calculate average grid values? – Simbamangu Jul 25 '16 at 7:02
  • @Simbamangu I need to form clusters based on distance (to begin with). By reducing from 8 decimal places to 3 decimal places I am trying to group the points, which is not an ideal method. By Summarization I mean grouping, since after the step of rounding off to 3 decimal places there are many points with same lat-lon, I now want one feature class (be it point if it has unique lat-lon or multi-points with same lat-lon) for each of newly formed Lat-lon. In Alteryx this is Summarization in sql this Group by. – Anjali Grover Jul 26 '16 at 22:23

To create a convex hull you can use function chull from grDevices.

NB: This function returns the indices of the points in the input, not the points itself. Furthermore I was using it to draw lines, so I had to add the first point again as last point. The code I used looks like this:

hull <- chull(topo)
hull <- c(hull, hpts[1])
hullpts <- topo[hull,c(1,2)]
  • Thank you Peter, I will try this, but first I need to summarize my data on unique lat/lon. Do you know how to create multi-point feature via summarization? – Anjali Grover Jul 24 '16 at 13:21

It is quite unclear what you attempt to do. For instance summarize and feature are quite vague without further context. So I am guessing here.

With your rounding of the coordinates you in effect moved the points in "square" cells to a central point for each cell. You don't need to. Just imagine the cells, and loop over them, calculating the aggregate you need (count/sum/avg(?)) for the points in each cell.

Every grid-cell could then serve as the complex hull for the points inside it. Use rect() and text() to draw the results into a plot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.